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);

Recommended Answers

All 2 Replies

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'];

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.