PDA

Click to See Complete Forum and Search --> : Sql Help


RameshChaudhary
Sep 3rd, 2006, 01:47 AM
$rec ="SELECT tbltracks. * FROM tbltracks,tblcollection WHERE tbltracks.FT_SuplProdID=tblcollection.suplprodid and tblcollection.barcode='$barCode' ORDER BY tbltracks.ID Limit ".($trackOrder).",1";

mysql_query("UPDATE tbltracks SET (Sound_Links='$SoundLink') WHERE tbltracks.ID ='{$row['ID']}'");



Don't know how to take ID from record source.

modpluz
Sep 5th, 2006, 09:43 AM
sorry pls but what r u trying to do?
where or when did you execute the first SQL string assigned to the variable $rec?

well i think you should execute that first and then assign $row['ID'] to a variable.

ex: $id = $row['ID'];

then in your second query, you have something like;

mysql_query("UPDATE tbltracks SET (Sound_Links='$SoundLink') WHERE tbltracks.ID =$id);

hope this helps...

The Hobo
Sep 6th, 2006, 09:02 PM
You need to assign the result of the query to a variable, and then pull records/rows from the variable one-by-one.

// random example:
$sSQL = "SELECT name, age, sex, email FROM t_user WHERE age > 15";

$rUsers = mysql_query( $sSQL ) or
trigger_error( "<i>Failed on Query: " . $sSQL . "</i>", E_USER_ERROR );

while( $aUser = mysql_fetch_array( $rUsers ) )
{
echo $aUser[ "name" ] . "<br />";
}

Hope this helps.

Edit: Looking at your code, you're going to need to execute your first query, pull the required data, and then run your update query:

$sSQL = "UPDATE t_user SET age = " . $iAge . " WHERE user_id = " . $iUser_ID;

$rResult = mysql_query( $sSQL ) or
trigger_error( "<i>Failed on Query: " . $sSQL . "</i>", E_USER_ERROR );

if( !$rResult )
{
echo "Update failed<br />";
}