I'm trying to echo tables from MySQL database to browser using php 4.2.2. The following reads the correct number of tables in my database [entries], but I get a syntax error in my 'for' loop. I know the problem is with my 'rows' variable, but I've tried many variations and am back to this: (this page is called help.php)
<?php
session_start();
if(!$_SESSION['count'])
{
echo "Not Registered<br>" ;
$_SESSION['count'] = 1;
$_SESSION['conn'] = mysql_pconnect("localhost", "user", "password"
;
mysql_select_db("database"
;
$qry = "show tables";
$result = MYSQL_QUERY($qry);
$_SESSION['entries'] = mysql_num_rows($result);
$row = mysql_fetch_array($result);
}
else
{
echo "Registered<br>" ;
$_SESSION['count']++;
}
?>
<body>
<?php
echo "<br>Number of Tables: ".$_SESSION['entries']."<br>";
for ($i = 0; $i<$_SESSION['entries']; $i++)
{
echo "$_SESSION['row[$i]']" ;
}
?>
</form>
<br>Number of Clicks: <? echo $_SESSION['count']; ?><br />
<br />
<a href="help.php">Submit this page</a><br />
<a href="destroy.php">Destroy Session</a><br />
</body>
Thanks - Keith
<?php
session_start();
if(!$_SESSION['count'])
{
echo "Not Registered<br>" ;
$_SESSION['count'] = 1;
$_SESSION['conn'] = mysql_pconnect("localhost", "user", "password"
mysql_select_db("database"
$qry = "show tables";
$result = MYSQL_QUERY($qry);
$_SESSION['entries'] = mysql_num_rows($result);
$row = mysql_fetch_array($result);
}
else
{
echo "Registered<br>" ;
$_SESSION['count']++;
}
?>
<body>
<?php
echo "<br>Number of Tables: ".$_SESSION['entries']."<br>";
for ($i = 0; $i<$_SESSION['entries']; $i++)
{
echo "$_SESSION['row[$i]']" ;
}
?>
</form>
<br>Number of Clicks: <? echo $_SESSION['count']; ?><br />
<br />
<a href="help.php">Submit this page</a><br />
<a href="destroy.php">Destroy Session</a><br />
</body>
Thanks - Keith