Forum Moderators: coopster

Message Too Old, No Replies

ORDER by name rand() LIMIT

How to do to do not repeat

         

romzinho2k7

7:31 am on Apr 30, 2006 (gmt 0)

10+ Year Member



Hey friends, all right?

I am doing a system by cars and would like that the database data came of aleatory form. I used the code below and worked, however it had any what if would repeat( the same id ). Have how to do it do to them of them do not repeat?( In other words, when one enter the list that they are going to appear, he do not appear at the same page).


<?php
$id = @$_GET["id"];
$query = mysql_query("SELECT * FROM cars WHERE id='$id' ORDER by name rand() LIMIT 5");
?>

Sorry my English. Still am learning to write in English and these translating do not translate right

Thanks

wheelie34

10:02 am on Apr 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?php
$id = @$_GET["id"];
$query = mysql_query("SELECT * FROM cars WHERE id='$id' ORDER by name rand() LIMIT 5");
?>

Try
<?php
$id = @$_GET["id"];
$query = mysql_query("SELECT DISTINCT FROM cars WHERE id='$id' ORDER by name rand() LIMIT 5");
?>