[PHP-DB] Re: database update question

2002-11-15 Thread Coert Metz
You can let PHP create all the update Statements into
a while loop. Or is that wat you don't want to do?

Coert

Chip Wiegand wrote:

I have a database with several hundred entries of file names that end with
.pdf. I have converted
all those docs to .zip, now I need to change all the entries in the
database to .zip. I tried to use
update table_name set col_name='%.zip' where col_name like '%.pdf' && id
= '11'
but of course that changed the file name for id 11 to %.zip. Is there a way
to change all the
entries from .pdf to .zip without writing an update statement for each
individual row?

--
Chip Wiegand
Computer Services
Simrad, Inc
www.simradusa.com
[EMAIL PROTECTED]

"There is no reason anyone would want a computer in their home."
 --Ken Olson, president, chairman and founder of Digital Equipment
Corporation, 1977
 (They why do I have 8? Somebody help me!)





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




Re: [PHP-DB] upload data to MySql

2002-11-14 Thread Coert Metz
Hi

Never forget to include enctype="multipart/form-data" into your formtag

Bye

Coert

Jason Wong wrote:

On Thursday 14 November 2002 04:47, Seabird wrote:


Hi everyone,

I don't get my upload to work properly. It's a tutorial of the web, but it
doesn't function (unless I made a mistake). 


HOW doesn't it function?



Please help me...



You have to provide more information, like what you see when you submit the 
form and whether there were any error messages etc.

For starters, you should always set error reporting to MAX, and log errors to 
a file (if you're not displaying it to screen). These can be set in php.ini.

Next use print_r() on all your important variables at strategic places in your 
code so you can verify that they contain what you expect them to contain.



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




[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:



 Connection Time



$column   ";
 }
 echo "";
}

// 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 "$message";
}
?>

Clear the Form?








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 Coert Metz

Hello

The problem is that you only apply mysql_fetch_row one time to the result.
The query 'select * from time where id>0' gives an array which can have
multiple rows.
For every row you have to apply mysql_fetch_row.

So you have to do something like this:

$total=0;
while ($row = mysql_fetch_row($result) {
  $id  = $row[0];
  $date = $row[1];
  $time = $row[2];

  echo "$id $date $time";  // you can put variables into the string when you
use double quotes!
  echo "";
  $total+=$time
}
echo $total;

What also can be usefull is to use the function list. You then can do
something like:
while (list ($id, $date, $time) = mysql_fetch_row ($result) 
and then skip the $id = $row[0] and so on.

If the time isn't in seconds you have to apply some functions to calculate
te total correctly

Success!!

Coert Metz

ps. My excuses when my English doesn't fit all the rules ;)


 0";
$result = mysql_query($query);
$row = mysql_fetch_row($result);

function totalsum()
 {
  if($row[2] > 0)
   {
$totalsum1 = sum($row[2]);
echo $totalsum;
   }
 }

if ($row[0] > 0)
 {
  $id  = $row[0];
  $date = $row[1];
  $time = $row[2];

  echo $row[0] . " " . $row[1] . " " . $row[2];
  echo "";
  echo "Total:";
  echo totalsum();
 }

?>

As I mentioned in a past mail, the purpose of this script, is to manage
values sent from a form, with the current date and the total amount of time
I spent on my Dial Up connection. Then it should display the last 30 days
connections (not implemented yet) and a total of the connection time (which
isn't working) for those days or current month.

Actually it displays only the first one of the records and doesn't display
the total. Can anybody help me out here? I know it's just a try, but it's
very important for my learning in order to see what I'm missing here.

Thanx in advance.

Cesar Aracena




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