
Merlin 🤖
Members-
Posts
39 -
Joined
-
Last visited
Never
Everything posted by Merlin 🤖
-
Hello, I have this code to generate a drop down list of years, but need to adjust it so that when a date is selected, it takes you to /schedule?Year=(selected year here) Thanks $thisYear = date('Y'); $startYear = "2009"; $selectYear = ($thisYear); print 'Year: <select name="Year">'; foreach (range($thisYear, $startYear) as $year) { $selected = ""; if($year == $selectYear) { $selected = " selected"; } print '<option' . $selected . '>' . $year . '</option> '; } print '</select>';
-
[SOLVED] Image gallery repeating same image?
selliott replied to selliott's topic in PHP Coding Help
Thanks for the help guys! I still plan on adding more to the script, but I was stuck here. Note: small typo in printf's post. $coulmns = 3; should be $columns = 3; -
[SOLVED] Image gallery repeating same image?
selliott replied to selliott's topic in PHP Coding Help
Maybe I'm misunderstanding what you're saying (sorry if I am), but changing gallery.php?CatID=1 to gallery.php?CatID=1&time=23423 doesn't change anything. I click on a gallery link on one page (photos.php), which inserts the Category ID in the URL (CatID=1 in this example), then when I get to that gallery page I have the script on that page pulling out the images from the photos table in the db with a category ID (CatID) that matches that category's ID. I'm guessing it just ignores everything in the url string except the CatID? -
I'm putting together a simple image gallery, but I can't figure out how to get it to display ALL the images with a specific CatID. This is what I've pieced together, but it just keeps repeating the same image. <?php $CatID = $_REQUEST['CatID']; $Photos = mysql_query("SELECT ID, Title, ImageURL, CatID, Details FROM Photo WHERE CatID='$CatID'", $connection) or die("error querying database"); $rows_nb = mysql_num_rows($Photos); $pic_num = 0; $pic_code = mysql_fetch_array($Photos); echo '<table width="75%" border="0" align="center">'; while($row = mysql_fetch_assoc($Photos)) { echo '<tr>'; for ($tb_rows=0;$tb_rows<3;$tb_rows++) { if ($pic_num < $rows_nb) { echo '<td><div align="center"><img src="'.$pic_code['ImageURL'] .'" border="1" /></div></td>'; $pic_num++; }else{ echo '<td></td>'; } } echo '</tr>'; } echo '</table>'; ?>
-
Classy.
-
Thanks for the reply. What would I put in place of $array to get this to work with my connection? This is my SELECT statement: $Points = mysql_query("SELECT ID, Name, Points FROM tq_Points ORDER BY Points DESC", $connection) or die("error querying database");
-
Hello, I put together some code that displays ranks, but if two people have the same amount of points (tied) I want them to have the same rank...then the next would skip a number. For example, like this Rank Name Points 1 Joe 105 2 John 101 2 Shawn 101 4 Sam 100 Right now, my code would just list the rankings for these members as 1,2,3,4 Here's my current code: <?php echo '<table cellpadding="3" cellspacing="0" style="width:100%;"> <tr> <td>Rank</td><td>Driver</td><td>Points</td> </tr>'; $rank = 1; while($r = mysql_fetch_array($Points)){ echo ' <tr> <td class="topline">' . $rank . '</td> <td class="topline">' . $r['Name'] . '</td> <td class="topline">' . $r['Points'] . '</td> </tr>'; $rank++; } echo '</table>'; ?>
-
[SOLVED] Need to Limit Rand() QueryString Results on SQL2000
selliott replied to selliott's topic in Microsoft SQL - MSSQL
I ended up using ORDER BY NEWID() instead of ORDER BY RAND() and it works now. -
[SOLVED] Need to Limit Rand() QueryString Results on SQL2000
selliott replied to selliott's topic in Microsoft SQL - MSSQL
I'm going to email my host and see what they say about this. It's acting like the rand() just isn't working. Like it collects the top 1000 without randomizing, then the top 4 from that...which gives me the same top 4 every time...in the same order. I'll post in here after I hear back from them. -
[SOLVED] Need to Limit Rand() QueryString Results on SQL2000
selliott replied to selliott's topic in Microsoft SQL - MSSQL
I made a little progress on this after some trial and error, some more googling and a few minor adjustments. SELECT Top 4 * FROM (Select TOP 1000 * FROM ads WHERE Terminate > GETDATE() ORDER BY RAND()) AS newtbl But I'm still getting the same 4 results? -
[SOLVED] Need to Limit Rand() QueryString Results on SQL2000
selliott replied to selliott's topic in Microsoft SQL - MSSQL
Yeah, I knew the LIMIT command wouldn't work (after some googling before my post), I just didn't know what other options I had to accomplish the same thing on mssql. I tried your code idea and did have to remove the AS subtable (got error) and now it doesn't seem to like the last ")" for some reason. The error reads: Incorrect syntax near ')' -
First, here's my currently functioning code: $QueryString="SELECT Top 4 * FROM ads WHERE Terminate > GETDATE() ORDER BY RAND()"; Now, this limits my results to 4...but it's only showing the same Top 4 every time...and it doesn't appear to be randomizing. If I refresh the xml.php page, I keep seeing the same nodes in the same order. The big issue is, I don't want the Top 4...I want 4 random. What I want this to do is give me 4 Random ads from ALL the ads that haven't expired (have a terminate date > now). I'm guessing something like this would work perfect, if my SQL server recognized LIMIT "SELECT * FROM ads WHERE Terminate > GETDATE() ORDER BY RAND() LIMIT 4";
-
That did it! THANKS!
-
MSSQL
-
When I try that, an error says 'NOW' is not a recognized function name I'm on a windows server if that makes a difference.
-
I'm not real familiar with PHP, so I can quite get this querystring to work. Anyone see what I'm doing wrong? $date='DateTime.Now.ToString("yyyyMMdd")'; $QueryString="SELECT Top 5 * FROM red.apples WHERE Terminate > '$date' ORDER BY ViewCount DESC";
-
In the header, I had to change the From "name" to From "email".
-
Getting closer... This test code works: <?php $sendTo = "[email protected]"; $subject = "Website Inquiry"; $headers = "From: [email protected]\nReturn-Path: [email protected]\nX-Mailer: PHP/" .phpversion(); $messages .= "From: John Smith\r\n"; $messages .= "Email: [email protected]\r\n"; $messages .= "------------------------------------------" . "\r\n"; $messages .= "Testing Form\r\n"; mail($sendTo, $subject, $messages, $headers); ?> But this one is not (that uses the variables from the flash form). Something is wrong with the $headers line: <?php $sendTo = "[email protected]"; $subject = "Website Inquiry"; $headers = "From: " . $_POST["name"] . "\nReturn-Path: " . $_POST["email"] . "\nX-Mailer: PHP/" .phpversion(); $messages .= "From: " . $_POST["name"] . "\r\n"; $messages .= "Email: " . $_POST["email"] . "\r\n"; $messages .= "Phone: " . $_POST["phone"] . "\r\n"; $messages .= "------------------------------------------" . "\r\n"; $messages .= "Message: " . $_POST["message"] . "\r\n"; mail($sendTo, $subject, $messages, $headers); ?>
-
No one can help?
-
I've used this script on linux/unix hosting plans before and it works fine, but it's not working for me now on a windows hosting plan. I have a flash contact form that sends the variables to it. Any ideas why it's not working on the windows server? <?php $sendTo = "[email protected]"; $subject = "Website Inquiry"; $headers = "From: " . $_POST["name"]; $headers .= "<" . $_POST["email"] . ">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-Path: " . $_POST["email"]; $messages .= "From: " . $_POST["name"] . "\r\n"; $messages .= "Email: " . $_POST["email"] . "\r\n"; $messages .= "------------------------------------------" . "\r\n"; $messages .= "Message: " . $_POST["message"] . "\r\n"; mail($sendTo, $subject, $messages, $headers); ?>
-
[SOLVED] Display next 5 dates, greater than or equal to current date
selliott replied to selliott's topic in PHP Coding Help
Awesome, thanks for the help guys! I ended up having to use: SELECT TOP 5 ID, Date, Title, Car FROM Schedule WHERE Date >= GetDate() ORDER BY Date ASC "; -
[SOLVED] Display next 5 dates, greater than or equal to current date
selliott replied to selliott's topic in PHP Coding Help
oops, I didn't mean to say "Won't it just display all dates". I meant the 1st 5 in the db, regardless of the current date. I had a little trouble getting this to display at first, then read around and it looks like I had to change it to read: SELECT TOP 5 ID, Date, ...etc. Since I'm on an SQL server. I kept getting an error whenever I tried putting the LIMIT in there. Using SELECT TOP 5 is only showing me the first 5 dates in the database though. So, since the first date is 11/20/08, it's showing first....but I don't want it to show at all, since that date would be past. So if the site was visited today, I'd want it to only display the next 5 dates that are of 11/15/08 or greater. -
[SOLVED] Display next 5 dates, greater than or equal to current date
selliott replied to selliott's topic in PHP Coding Help
Thanks for the quick reply. This won't limit the results to only dates that are greater than or equal to the current date though, will it? Won't it just display all dates in the db? -
Hello, I need some help adjusting my code to only display dates greater than or equal to the current date. And for it to limit the results to 5. Please help! <?php ini_set('error_reporting', E_ALL | E_STRICT); ini_set('display_errors', 'On'); include('admin/functions.php'); $ConnString="DRIVER={SQL Server};SERVER=;DATABASE="; $DB_User=""; $DB_Passwd=""; $QueryString="SELECT ID, Date, Title, Details, Results, Car FROM Schedule ORDER BY Date"; $Connect = odbc_connect( $ConnString, $DB_User, $DB_Passwd ); $Result = odbc_exec( $Connect, $QueryString ); $nl = "\r\n"; echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" . $nl; echo "<ROOT>" . $nl; while($r = odbc_fetch_array( $Result ) ) { echo '<news ID="' . $r['ID'] . '" Title="' . char_replace($r['Title']) . '" Date="' . $r['Date'] . '" Car="' . $r['Car'] . '">' . $nl; echo '<body><![CDATA[' . stripslashes2($r['Results']) . ']]></body>' . $nl; echo '</news>' . $nl; } echo "</ROOT>" . $nl; odbc_free_result( $Result ); odbc_close( $Connect ); ?>
-
Where do you $_GET this value, "?galleryId=2"? You would need to change your query to: $QueryString="SELECT * FROM $table WHERE gallery_id = $_GET['galleryId']"; Is this what you're looking for? Awesome! Thanks!