Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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