Jump to content

selliott

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

selliott's Achievements

Member

Member (2/5)

0

Reputation

  1. 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>';
  2. 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;
  3. 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?
  4. 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>'; ?>
  5. 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");
  6. 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>'; ?>
  7. I ended up using ORDER BY NEWID() instead of ORDER BY RAND() and it works now.
  8. 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.
  9. 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?
  10. 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 ')'
  11. 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";
  12. 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.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.