[thelist] Random Page Titles is it possible with php/MySQL

Andre Genic g3nic at lycos.co.uk
Thu Sep 18 06:21:23 CDT 2003

Hi All,
	Been trying to get my head around a little problem, I want to add a series
of random page titles into a page from a MySQL table, just really something
so there's a different title on the page everytime it's refreshed or
re-visited, here's the code I cooked up to try and do it.

So far zip!

mysql_connect($server, $user, $pass) or die ("Can't connect!");
mysql_select_db($db) or die ("Can't open database!");
$sql = "SELECT * FROM $t1";
$result = mysql_db_query($db, $sql);
if ($result)
$count = mysql_num_rows($result);

$sqlshow = "SELECT * FROM $t1 ORDER BY RAND() LIMIT 0, 1";
$result = mysql_db_query($db, $sqlshow);

while (($myrow = mysql_fetch_array($result)))
echo "<title>$page_title"</title>;
echo "Error!";

But all I am getting back is this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="favicon.ico" rel="shortcut icon">

Any pointers as to where I'm going wrong?

More information about the thelist mailing list