| Mailing List | | Home | | MySQL General - General MySQL discussion | | MaxDB - Everything about MaxDB, formerly known as SAP DB | | MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP | | Java Help - Mostly related to the MySQL Connector/J driver | | ODBC - ODBC with the MySQL Connector/ODBC driver | | Perl - Perl support for MySQL with DBI and DBD::mysql | | MySQL++ - Programming with the C++ API to MySQL |
|
|
  | |  | Update problem | Update problem 2004-06-17 - By Daniel Clark
Back echo $updatequery to screen and see what the sql looks like.
> I am trying to update a table from results generated from a select query,
> but can 't seem to get the queries running right. The select query works
> fine, but when I try to use the results for an update it error out. Here
> is
> my query:
>
>
> db_connect();
>
> $query = "SELECT cst_SiteID FROM customers WHERE cst_Offer = 1 ";
>
> echo $query;
> echo " <br/ > ";
> $result = mysql_query($query);
> $numofrows = mysql_num_rows($result);
> $numofcols = mysql_num_fields($result);
>
> echo " <table >\n ";
>
> for ( $r = 0; $r < $numofrows; $r++)
> {
> $row = mysql_fetch_array($result);
> echo " <td >$row[0] </td > ";
>
> $updatequery = "UPDATE assets " .
> "SET asset_Managed = '2 ' " .
> "WHERE asset_SiteID = $row[0] ";
>
> $result = mysql_query($updatequery) or die ( "Query Failed:
> $updatequery ");
> $numofrows = mysql_num_rows($result);
>
> for ($i = 0; $i < $numofrows; $i++)
> {
> $row = mysql_fetch_array($result);
> echo " <td >$row[0] </td > ";
> }
> }
>
--
MySQL General Mailing List
For list archives:
http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=mysql
@(protected)
|
|
 |