Page 1 of 1

PHP Variable in mySQl Statement

Posted: Fri Apr 27, 2007 5:39 pm
by SYLVESTER
Hi

Can anyone tell me if its possible to combine a php variable & an sql statement

I have a standard SQl selct statement such as "Select * from table"
the following lines of code then results in a php variable such as
$totalnumber_rows table blah blah

how can I select the primary key from a table that corresponds to the row number returned above.

cheers folks

Tim

Posted: Fri Apr 27, 2007 7:19 pm
by bdlang
Unless I'm simply not understanding you, your SQL statement needs to be altered a bit, e.g.

Code: Select all

SELECT column1, column2 FROM table WHERE ID= {PHP_VARIABLE}
The `ID` field mentioned is your PRIMARY KEY.

Is that what you're looking for?

PHP Variable in mySQl Statement

Posted: Sat Apr 28, 2007 4:46 am
by SYLVESTER
Thats almost what I'm aiming at,

based in what u said I have now got my SQL statement as follows

Code: Select all

$query_rstruehighestID = "select itineraryID From itinerary where rownumber ="{$totalRows_rshighestID}
cheers again

Tim