Jump to content

[SOLVED] How do I limit my results!


numtre

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/130880-solved-how-do-i-limit-my-results/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.