[Wolves] php/mysql wizzards please - sparkes?

Wayne Morris wayne at machx.co.uk
Fri Mar 12 18:18:22 GMT 2004


I've got what should be a really simple operation to do and I just can't
get it, despite hours on google and some posts in the php groups.

All I want to do is this:

I have a contacts database with a table 'phonelist' containing a field
'county' which currently contains numbers referred to in another table
'counties' which contains 'county' and 'oldid'.
I want to get rid of the 'county' table and insert the county names from
it into the 'county' field as a one off.

So i've tried all sorts of stuff like this on the mysql prompt:

Update phonelist.county SET phonelist.county = counties.county WHERE
phonelist.county=counties.oldid

and stuff like this in php

$qy = "SELECT * FROM counties";
$rs = mysql_query ($qy);
while ($r = mysql_fetch_array ($rs))
 {
 $qu = "UPDATE phonelist SET county = '{$r['county']} WHERE county =
{$r['oldid']}";
 mysql_query ($qu);
 }

with no joy.

Anyone tell me what I should be doing?

Cheers.




Wayne Morris
07960 859346
-- 

Live machinery database
www.machx.co.uk/classifieds/
Most recently added items
www.machx.co.uk/classified/recent.php




More information about the Wolves mailing list