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
https://forums.phpfreaks.com/topic/201638-set-amount/#findComment-1057765
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
https://forums.phpfreaks.com/topic/201638-set-amount/#findComment-1057839
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.