Can anybody please help.
I have images listed in a database, I select random images but would like not to select one certain image, is there anyway to do that? My code is listed below.
********************
<?
$db = MYSQL_CONNECT("localhost",xxxxx,xxxxx) OR DIE ("Unable to connect to database");
@mysql_select_db(attorney_images,$db) or die ("Unable to select database");
$result = mysql_query("SELECT * FROM all_images order by RAND()LIMIT 3");
if($myrow = mysql_fetch_array($result))
{
do{
echo"<td><table width='100%'><tr><td align='center'><table border='1'><tr><td><img src=http://xxxxxx/images/attorneys/$myrow[0]
</td></tr></table></td></tr><tr><td align='center' valign='middle'><b><font size='-2'><b>$myrow[2]<br><a href='http://$myrow[4]'><font size='-2'>$myrow[4]</font></a><br>$myrow[3]</b></font></td></tr></table>";
}while ($myrow = mysql_fetch_array($result));
}else{
echo "bad image";
}
?>
********************************
Thanks
omitting one record
Moderator: General Moderators
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
$result = mysql_query("SELECT * FROM all_images order by RAND()LIMIT 3");
to
to
Code: Select all
$result = mysql_query("SELECT * FROM all_images WHERE `img` != 5 order by RAND()LIMIT 3");-
steve@oeic.net
- Forum Newbie
- Posts: 8
- Joined: Wed Feb 18, 2004 2:47 pm
Code: Select all
$result = mysql_query("SELECT * FROM all_images WHERE id != 1 order by RAND()LIMIT 3");
?>