Results 1 to 3 of 3

Thread: Sql Help

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    Sql Help

    PHP Code:
    $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.

  2. #2
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: Sql Help

    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...
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Sql Help

    You need to assign the result of the query to a variable, and then pull records/rows from the variable one-by-one.

    PHP Code:
    // 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:

    PHP Code:
    $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 />";

    Last edited by The Hobo; Sep 6th, 2006 at 09:05 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width