0

hi all..

i have a problem. Actually i want to view respond select by MAX(tran_id)...don't know why when i run this code, i do not get the max/ last respond.. it return to me the first respond..for the tran_id it view the max id but not for respond..here the script..hope anybody can help me.. Thank you so much.........

$sqlmax="SELECT MAX(tran_id), reqid FROM transaction AS last_id WHERE reqid='$reqid'";
$rslmax=mysql_query($sqlmax);
$rowmax=mysql_fetch_array($rslmax);
$max=$rowmax['tran_id'];

$sqlmax1="SELECT respond FROM transaction WHERE tran_id='$max'";
$rslmax1=mysql_query($sqlmax1);
$rowmax1=mysql_fetch_array($rslmax1);
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by HasNor
0

This is probably your issue. The column is not named tran_id but MAX(tran_id) but you can give it an alias with AS like this:

$sqlmax="SELECT MAX(tran_id) AS max_tran_id, reqid FROM transaction AS last_id WHERE reqid='$reqid'";
//...
$max=$rowmax['max_tran_id'];
0

Thanks Mr Pritaeas!! You've solved my issue..thank you so much!!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.