Re: newbie MySQL question

From: Date: Sun, 20 May 2001 02:19:02 +0000
Subject: Re: newbie MySQL question
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-9470@lists.php.net to get a copy of this message
this would work, and does for the day, but for the month it doesn't. also, is there code to have: $result = mysql_query("select * from shows ORDER BY date DESC"); (or whatever code works) and $result = mysql_query("select * from shows where id >= $show order by id limit 8"); combined together to make it so that there's only 8 rows per page and yet it displays the date (ex, May 19, 2001) in descending format ? Also, is there a way to have the PHP figure out when to go the next page after 8 rows, or to not put a link if there's 7 or less rows? like http://www.thesite.com/shows/main.php?show=1 when it has 8 rows, it displays a link to http://www.thesite.com/shows/main.php?show=12, but when there's 7 or less rows, it displays no link? There's probably some if/else statement to run, but I have no idea what it would be. If I sound confusing, I'm really sorry, I'm pretty bad at explaining things well, so ask if you don't understand what i mean by something. Thanks again, Matt > > $result = mysql_query("select * from shows"); > Change to > > $result = mysql_query("select * from shows ORDER BY date DESC"); > > > On Saturday 19 May 2001 21:45, Matt Nigh wrote: > > hi, i'm building a website right now with a shows page on it which will > > scroll horizontally in a window. i have each show listed in a table called > > shows (db is called almavale_board) with the following fields: > > > > id - bandplaying - venue - date - time - cover - description > > > > > > what i need to do is have the shows listed by date, having the latest date > > listed first. here's the code i have presently: > > > > > > <table bgcolor=white cellpadding=0 cellspacing=0 border=0><tr> > > <?php > > $link = mysql_connect("localhost","almavale","violet"); > > if(!$link) die ("Could not connect to MySQL!"); > > mysql_select_db("almavale_board",$link); > > $result = mysql_query("select * from shows"); > > $num = mysql_numrows($result); > > for($x=0;$x<$num;$x++) { > > $row = mysql_fetch_object($result); > > print "<td valign=top><table width=200 bgcolor=white cellpadding=4 > > cellspacing=4 border=0><tr><td bgcolor=white valign=top><font face=verdana > > size=1> > > <b>$row->bandplaying</b><br>$row->venue<br>$row->date<br>$row->time<br>$row > >- > > > > > > >>cover<br>$row->description<br><br></font></td></tr></table> > > > > </td> > > "; > > } > > mysql_close($link); > > ?> > > </tr></table> > > > > > > > > oh and the date is in this format : Month-Day-,Year (ex. May 19, 2001) > > > > if anyone can help me out on this at all (or has any questions about my > > problem), please reply to this post, i'd be very appreciative.

« previous php.db (#9470) next »