Ive been searching alot lately but couldnt come up for a solution about this problem of looping...
i am currently workin on a page that would display transactions from database and would let you pay using a button.
i made a table and put a button in the last column of every row using while($row = mysql_fetch_array($query)).
i made use of isset that everytime the button is clicked some session will store corresponding to the values of the row...but the problem is whichever button i clicked whether its in the first, second, or third row the values that i get comes from the last row.
Is there a way to get the value of the variables of each row? here are the codes:
$qry1=mysql_query("SELECT * FROM request WHERE client_id ='".$_SESSION['client_id']."'");
$check = mysql_num_rows($qry1);
if ($check == 0) { echo "There are no recent transactions to display."; }
else{
$table = "<table align= 'center' border='1' bordercolor='#ccc' cellpadding='20'>";
$table .= "<tr><th>REQUEST #</th><th>DATE</th><th>TIME</th><th>EVENT</th><th>PRICE</th><th>STATUS</th><th></th></tr>";
while($row = mysql_fetch_array($query)){
print_r($row);
$rid = $row['request_id'];
$reid = $row['event_id'];
$raid = $row['addons_id'];
$reprice = $row['request_price'];
$redate = $row['event_date'];
$retime = $row['event_time'];
$restatus = $row['event_status'];
if($reid==1 || $reid==2 || $reid==3){
$debut="Standard Debut";
}
else { $debut="Kids Party";
}
$table .= "<tr><td align = center># ".$rid."</td><td>".$redate."</td><td>".$retime."</td><td align= center>".$debut."</td><td align=center>P".$reprice.".00</td><td align=center>".$restatus."</td>";
if($restatus=='PENDING')
{
$table .= "<td align=center>";
$table .= "<form method='post'>";
$table .= "<input type='submit' name='btnSubmit' id='btnSubmit' value='Pay' tabindex='0' />
</form>
</td>";
include "../pages/my_reqsubmit.php";
}
else
{
$table .= "<td align=center>--</td>";
}
$table .= "</tr>";
}
$table .= "</table>";
echo $table;
code for my_reqsubmit.php :
if(isset($_POST["btnSubmit"]))
{
include("../pages/config.php");
$URL= "../request/view.php";
$_SESSION['RequestUser']="asd";
$_SESSION['dtRequest'] = $redate;
$_SESSION['tmRequest'] = $retime;
$_SESSION['etype'] = $debut;
$_SESSION['addons_id'] = $raid;
if($reid==1){
$_SESSION['epack']= "Package A";
}
else if($reid==2){
$_SESSION['epack']= "Package B";
}
else if($reid==3){
$_SESSION['epack']= "Package C";
}
else if($reid==4){
$_SESSION['epack']= "Package A";
}
else if($reid==5){
$_SESSION['epack']= "Package B";
}
else if($reid==6){
$_SESSION['epack']= "Package C";
}
$qrry2 = mysql_query("SELECT * FROM addons WHERE addons_id =$raid");
while($row = mysql_fetch_array($qrry2)){
$_SESSION['pservice'] = $row['addons_ps'];
$_SESSION['pbooth'] = $row['addons_pb'];
$_SESSION['mbar'] = $row['addons_mb'];
$_SESSION['phprice'] = 3500;
$_SESSION['pbprice'] = 5000;
$_SESSION['mbprice'] = 11000;
}
$qrry3 = mysql_query("SELECT * FROM event WHERE event_id =$reid");
while($row = mysql_fetch_array($qrry3)){
$_SESSION['eprice'] = $row['event_price'];
}
$_SESSION['price'] = $reprice;
header ("Location: $URL");
}
?>
Please help me...id really appreciate it!