Jump to content

PHP and MYSQL Help


cryp7

Recommended Posts

Hi,
The code I have so far is:
[code]
<?php

mysql_connect("localhost", "HIDDEN", "HIDDEN") or die(mysql_error());
mysql_select_db("HIDDEN") or die(mysql_error());

$category = games;

$totalrows = mysql_query("SELECT * FROM games");
or die(mysql_error());
$totalrowsresult = mysql_num_rows($totalrows);
or die(mysql_error());

srand ((double) microtime( )*1000000);
$randnum = rand(1,'$totalrowsresult');
or die(mysql_error());

$result = mysql_query("SELECT * FROM games WHERE no='randnum'");
while($row = mysql_fetch_array($result))
or die(mysql_error());

echo "$row['no'], $row['id'], $row['data']";
or die(mysql_error());

?>
[/code]

What i want it to do is to count the number of rows in the table "games" then select a random number between 1 and how ever many rows there are in the table, then to select the data from the row, where the random number is equal to the value "no" in a row of the "games" table. Then finally to display this infomation.

Ive written the above and am unsure whats wrong...

The error i get is
[quote]Parse error: syntax error, unexpected T_LOGICAL_OR in HIDDEN/select.php on line 9[/quote]

Any help I could get would greatly be appreciated.

Thanks in advanced

Andy
Link to comment
https://forums.phpfreaks.com/topic/28334-php-and-mysql-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.