Forum Moderators: coopster

Message Too Old, No Replies

PHP mySQL Database Operation

         

nakulgoyal

9:30 pm on May 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a mysql database that is updated from a remote XML web Service every 2hrs via cron updatetable.php.

My Table has a field called Name which has Names like

Brett Tabke
Bill Gates
Michael Jackson
Bill Clinton

etc. These are sample names :)

This table is added with the new club members every time the above cron is run.

Now I want to write a code such that, when I run that, it modifies the table above, adds a new field called name2, and copies the names from the table name but replaces all spaces with hyphens.

Any help will be appreciated.

StupidScript

9:51 pm on May 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suggest: Add the new column yourself to set it up for the script.

Then:

$thisname2 = str_replace(" ","-",$thisname);

then insert the second variable (

$thisname2
) into the column that's waiting for it.

You can easily update all of the existing records by

select id,name from table
and then the above replacement then
update table set name2 = '$thisname2' where id = '$currentId'
(in the looping)

nakulgoyal

9:59 pm on May 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the quick response, this looks good. Let me play with it and I will post back here. I appreciate your help.