-1

So I had an idea where i would want other ids to display under the clients search term.

The basic idea what i wanted was to display RANDOMLY 5 other items from the database ( ids ) .

this was my attempt to do so:

<?php 
echo'<table width="200" border="0">
  <br>Other Items:&nbsp;<br></td><marquee behavior="scroll" direction="left">

<img src="http://rs-list.com/tools/items/'.(file_exists('items/'.$row['id'].'.png') ? $row['id'] : 0).'.png" class="img-responsive img-rounded" alt="'.$row['name'].'"">
<p><a href="/html/codes/scrolling_images.cfm">'.$row['name'].'</a>.</p></marquee>';
?>

but of-course all this is going to do is echo the value of id, which in this case was 241. ( Photo : http://prntscr.com/7u40nm )

How can i echo the information for 5 other ids randomized on refresh?

Thanks for any help

halfer
  • 19,824
  • 17
  • 99
  • 186
Ibrahim
  • 23
  • 4
  • pseudo query: select info from table where the id does not equal the item id limit five order by rand (every clause in this query is possible, just search for it) – Abdo Adel Jul 18 '15 at 12:36
  • check [selecting-random-rows-with-mysql](http://stackoverflow.com/questions/6541644/selecting-random-rows-with-mysql) – amdixon Jul 18 '15 at 12:37
  • Ibrahim, do you perhaps have some malware on your computer? I've just reverted a spam edit from your account. – halfer Jul 18 '15 at 13:20

1 Answers1

0

Use this Sql query

SELECT column FROM table
ORDER BY RAND()
LIMIT 5
Saty
  • 22,443
  • 7
  • 33
  • 51