On Thu, Dec 18, 2003 at 01:39:57PM +1100, Eric Holmstrom wrote: > > What im trying to do is read the information from a field in a table called > PARTNO. Then add RU to the front of whatever is in the PARTNO field. > > So far i have this. > > //connect details rarara > //query > $query= "SELECT PARTNO FROM russell2 ";
Didn't you say the table was called "PARTNO", not "russell2"? > // make a query to get old stuff from DB col > $oldstuff = mysql_query($query, $conn) or die(mysql_error()); > while ($new = mysql_fetch_array($oldstuff)){ > $final = $new['PARTNO']; > //new infomation i want to add infront of PARTNO data > $newstuff = 'RU'; > //Combining the two resluts together > $results = $newstuff.$final; > // just use this to check it was going through properly > print_r($results<br>); > } > > The problem i have to get it to update. If i add this (see below) inside the > while statement it continually loops, and outside it doesnt work. > > $update = "UPDATE rocket SET PARTNO = '$results''"; > mysql_query($update); > > I know the answer is simple but i seem to be stuck on it. I don't think you can just update a row that you just fetched within the same query. If you do this in PHP, you should split the update into a separate loop. Of course, it would be faster and more efficient to have MySQL do it for you: UPDATE rocket SET PARTNO = CONCAT('RU',PARTNO) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php