Hi people of Webmaster World, atb for 2011.
In summary I'm inserting form data into mysql whereby one req number can have 3 item lines. DB schema is each item line also has the req number.
I'm trying to echo out the contents of a variable but only on the lowest item number. Code is:
$reqquery = "SELECT * FROM `porders` WHERE `username` = '$username' AND `type` = 'request' ";
$userreqs = mysql_query($reqquery) or die(mysql_error());
while ($row = mysql_fetch_row($userreqs)) {
$reqno = $row[6]; $item = $row[8];
if ($item <= 1) {
echo $reqno;
}
echo $item;
}
The above only echos out the $reqno if the item number is 1.
The problem I've got is another page has the following select.
$reqquery = "SELECT * FROM `porders` WHERE `username` = '$username' AND `type` = 'request' AND `status` = 'rejected' ";
$userreqs = mysql_query($reqquery) or die(mysql_error());
And because I've stipulated rejected and some rejected reqs are not item 1 it doesn't echo out the $reqno.
Its like I need to say:
if $reqno = $reqno echo reqno on lowest item number.
I've been thinking down the following angles but I can't get anything to work.
// if item 1 is present echo $reqno.
// if item 2 is present echo $reqno else echo $reqno on lowest item number.
// if item 3 is present echo $reqno else echo $reqno on lowest item number.
// echo $reqno on lowest item number only.
Any help would be much appreciated.
Cheers O.