Jump to content

Set amount


leeh14

Recommended Posts

So yeah i want the while to run 4 times then stop?

 

	$query = "select * from videos"; 

	$result = mysql_query($query) or die(mysql_error());
	while($row = mysql_fetch_array($result)){

		$tit_1 = $row["title"];
		$des_1 = $row["des"];
		$len_1 = $row["length"];
		$url_1 = $row["URL"];
		$img_1 = $row["image"];
		$sli_1 = $row["slider"];
		$del = $row["ID"];	

		echo "<li><a href='$page?\"?goto=true&id=".$del."'><img src='Tutorials/slider_thumbnails/$sli_1' width = '960px' height='400px' alt='CssTemplate Preview' /></a></li>";
	}
			?>

Link to comment
Share on other sites

A field for date added would be better than using the ID, but with what you have:

 

//First four
$query = "SELECT * FROM videos ORDER BY ID ASC LIMIT 4";

//Last four
$query = "SELECT * FROM videos ORDER BY ID DESC LIMIT 4";

 

Of course the last four will be in reverse order. If you need them in ascending order I think this will do it

 

//Last four in ascending order
$query = "SELECT *
          FROM (SELECT * FROM videos ORDER BY ID DESC LIMIT 4)
          ORDER BY ID ASC";

Link to comment
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.