numtre Posted October 31, 2008 Share Posted October 31, 2008 Hello fellow phpfreakers i got this situation. I'm making a php website for a friend who plays in a band. I want to show the next upcoming 8 shows on the webpage and I am wondering how to do it. here is my code: <?php $con = mysql_connect("localhost","inteoria_crash","****"); if (!$con) { die ('Could not connect.'.mysql_error()); } mysql_select_db ("inteoria_vera",$con) or die(mysql_error()); $result=mysql_query("SELECT gigs_ID, DATE_FORMAT(date, '%d/%m/%Y') as formatted_date, venue FROM tblGigs WHERE date > now() ORDER BY date ASC"); $row=mysql_fetch_array($result); mysql_close($con); $num=mysql_numrows($result); $i=0; while ($i < $num) { $date=mysql_result($result,$i,"formatted_date"); $content=mysql_result($result,$i,"venue"); echo "<span class='bold'>$date</span>:<br>$content<br><br>"; $i++; } ?> With the above code i get to display all of the gigs, and what i want to do is to limit my output to 8 gigs. of course if there are no gigs i dont want an error msg either Ive been wondering how to achieve this for a few hours now and cant find a solution, hopefully someone in the forum will be able to pint me in the right direction. thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/130880-solved-how-do-i-limit-my-results/ Share on other sites More sharing options...
SeanHarding Posted October 31, 2008 Share Posted October 31, 2008 "SELECT gigs_ID, DATE_FORMAT(date, '%d/%m/%Y') as formatted_date, venue FROM tblGigs WHERE date > now() ORDER BY date ASC LIMIT 1" Quote Link to comment https://forums.phpfreaks.com/topic/130880-solved-how-do-i-limit-my-results/#findComment-679341 Share on other sites More sharing options...
numtre Posted October 31, 2008 Author Share Posted October 31, 2008 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/130880-solved-how-do-i-limit-my-results/#findComment-679343 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.