[PHP-DB] Re: First Script

2002-05-20 Thread Coert Metz

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
 titleConnection 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, x);
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\$columnnbsp;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 BRBRSPAN style=\FONT-FAMILY: arial; FONT-SIZE:
14px\$message/SPAN;
}
?
BRBR
SPAN style=FONT-FAMILY: arial; FONT-SIZE: 14pxClear the Form?/SPAN
input type=checkbox value=clear
BRBR
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




[PHP-DB] RE: First Script

2002-05-18 Thread César L . Aracena

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
 titleConnection 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, x);
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\$columnnbsp;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 BRBRSPAN style=\FONT-FAMILY: arial; FONT-SIZE: 14px\$message/SPAN;
}
?
BRBR
SPAN style=FONT-FAMILY: arial; FONT-SIZE: 14pxClear the Form?/SPAN input 
type=checkbox value=clear
BRBR
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