Reply to Re: php question. Pls take a look and see if you can help

Your name:

Reply:


Posted by needaticker on 09/30/93 11:26

Thanks for your help so far, I think that I'm getting there and have
come up with what follows which isn't working but maybe you can spot
what's wrong with it.

The basics is that I have a table on the database that has a single
field (i have been trying some other stuff which includes an ID number
field but I wondered if anyone can help me fix the stuff below so I
don't need it).

The single field has about 100 entries so far but this will always
change and at some times there may be no entries (see the if / else
clause).

Otherwise I need to display a random entry from the table.

Here goes...



<?php
$username="dbusername";
$password="dbpassword";
$database="dbname";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");


$chooseall="SELECT * FROM tablename";
$chooseallresults=mysql_query($chooseall);
$numrows=mysql_numrows($chooseallresults);

$randget="SELECT * FROM tablename ORDER BY RAND() LIMIT 1";
$randgetresults=mysql_query($randget);

if ($numrows=0) {echo "Sorry no entries"
} else {
echo "$randgetresults"


mysql_close();
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация