* * * HELP!! My UPDATE Doesn't! * * *
The coding below does everything programmed to do with the exception of the UPDATE query. Sometimes it updates all rows but with the same array value.
The purpose is to update all records in a table with 5 categories in order to test certain situations. That's the loop with $ix1.
All combinations of quotes, single, double, - plus other variations - have not succeeded. An offer of a $25 reward on Sitepoint didn't help deliver a solution. The offer is still available
I await with bated breath.
And thanks in advance,
Mike
<?php
include('misc.inc');
$connection = mysql_connect($host,$user,$password)
or die ('No connection');
$db = mysql_select_db($database,$connection)
or die ('No selection');
$query = "SELECT * FROM books ORDER BY booknumber";
$result = mysql_query($query)
or die('mysql error gevonden ' . mysql_error() . ' in query ' . $query);
$ct1 = array('Kunst','Kinderbüchen','Literatur','Geography','Photography');
$ix1 = -1;
while ($row = mysql_fetch_array($result))
{
extract($row);
$ix1++;
$cat = $ct1[$ix1];
echo $cat,"<br>";
$query = "UPDATE books SET catalog='$ct1[$ix1]'";
// and this version tried
// $query = "UPDATE books SET catalog='$cat'";
$result2 = mysql_query($query)
or die('mysql error ' . mysql_error() . ' in query ' . $query);
echo $booknumber,"<br>",$catalog,"<br>";
if ($ix1 == 4)
$ix1 = -1;
};
exit;
?> booknumber varchar(6) NOT NULL DEFAULT '1234'
Author varchar(50) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT 'none'
title varchar(30) CHARACTER SET latin1 COLLATE latin1_german2_ci NOT NULL DEFAULT 'tytel'
keywords varchar(100) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT ' '
catalog varchar(25) DEFAULT NULL
UNIQUE KEY `booknumber` (`booknumber`)
* * * * My site * * * *
* * * * My paintings * * * *