I don't know how mysql_fetch_array() works. I think you have to handle this
by yourself
by putting something in the loop. You can also make a query for it (SELECT
sum(*) FROM time)

Coert

"César l . aracena" <[EMAIL PROTECTED]> schreef in bericht
002901c1feed$5695b2c0$94c405c8@gateway">news:002901c1feed$5695b2c0$94c405c8@gateway...
Thanx for the help. I have it almos finished. Now, the script throws all the
colums for all the rows of the table. My only problem now is how to print
the TOTAL for the column named time. Can I use mysql_fetch_array() instead
of mysql_fetch_row() to accomplish this? How can I add it?

Here's what I made so far:

<html>
<head>
 <title>Connection Time</title>
</head>
<body>
<form action="<?php PHP_SELF ?>" method="post">
<?php

if (isset($clear))
{
 $date = "";
 $time = "";
}

// Connect to Database
$db = mysql_connect("localhost", "admin", "xxxxxxxxx");
mysql_select_db("contime");
$query = "select * from time";
$result = mysql_query($query);

// Displays all the rows of the table
while ($row = mysql_fetch_row($result))
{
 foreach ($row as $column)
 {
  echo "<SPAN style=\"FONT-FAMILY: arial; FONT-SIZE:
14px\">$column&nbsp;&nbsp;&nbsp;</SPAN>";
 }
 echo "<BR>";
}

// Insert new values into the table
if ($time <> "")
{
 $query = "insert into time " . "(date, time) values ('$date', '$time')";
 $result = mysql_query($query);
 $id = mysql_insert_id();
 $message = "Record Added (id = $id)";
}

if (isset($message))
{
 echo "<BR><BR><SPAN style=\"FONT-FAMILY: arial; FONT-SIZE:
14px\">$message</SPAN>";
}
?>
<BR><BR>
<SPAN style="FONT-FAMILY: arial; FONT-SIZE: 14px">Clear the Form?</SPAN>
<input type="checkbox" value="clear">
<BR><BR>
<input type="submit" name="submit" value="Refresh">

</form>
</body>
</html>

I added the "Clear the Form?" checkbox, so if I refresh using the PHP_SELF
won't insert the same data again. Is that ok?

Thanx and sorry for the trouble.

Cesar Aracena
[EMAIL PROTECTED]
Neuquen, Argentina




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to