The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
![]()
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"); $query="SELECT * FROM tablename"; $results=mysql_query($query); $numrows=mysql_numrows($results); $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(); ?> If you can see anything wrong please let me know. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|