koochy
asked on
Printing from two table within a loop
Help please .....
I am printing data using a loop form one table ... this wirks fine .. now I need to print data based on the record I'm printing at the time .. my code pulls data from the second table but it pulls the same data for every record ... I'm sure I need a loop within the loop but I can't get it to work .. HELLLLLLLLLLLLP !!!
here is my existing code
$query = "SELECT * FROM horses WHERE status = 'accepted' ORDER BY lot_num";
$results = mysql_query($query)
or die(mysql_error());
?>
<table cellpadding="10" cellspacing="0" border="0">
<tr><td><b>Lot</b></td><td ><b>Horse< /b></td><t d><b>Bid</ b></td><td ><b>Status </b></td>< td><b>Clos ing Time</b></td></tr>
<?php
while ($row = mysql_fetch_array($results )) {
echo "<tr>\n";
echo "<td valign=top rowspan=2>" . $row['lot_num'] . "</td>\n";
echo "<td valign=top rowspan=2><a href='details.php?horse_na me=" . $row['horse_name'] . "'>" . $row['horse_name'] . "<br>\n";
echo "<img src='foalpics/" .$row['main_pic']. "' width='75px' alt='" . $row['main_pic'] . "'></td>\n";
echo "<td valign=top height=15>$" . $row['bid'] . "</td>\n";
echo "<td valign=top height=15>" . $row['bidding_status'] . "</td>\n";
echo "<td valign=top height=15>". $row['closing_date'] . " " . $row['closing_time'] . "</td>\n";
echo "</tr>\n";
$pedquery = "SELECT * FROM pedigree, horses WHERE pedigree.horseID = '" . $_SESSION['horseID'] . "' AND horses.horseID = '" . $_SESSION['horseID'] . "'";
$pedresults = mysql_query($pedquery)
or die(mysql_error());
$ped = mysql_fetch_array($pedresu lts);
echo "<tr><td colspan=3 height=55>" . $ped['S_Name'] . " X " . $ped['DS_Name']. " X " . $ped['DDS_Name'] . " </td></tr>\n";
next($bids);
}
?>
I am printing data using a loop form one table ... this wirks fine .. now I need to print data based on the record I'm printing at the time .. my code pulls data from the second table but it pulls the same data for every record ... I'm sure I need a loop within the loop but I can't get it to work .. HELLLLLLLLLLLLP !!!
here is my existing code
$query = "SELECT * FROM horses WHERE status = 'accepted' ORDER BY lot_num";
$results = mysql_query($query)
or die(mysql_error());
?>
<table cellpadding="10" cellspacing="0" border="0">
<tr><td><b>Lot</b></td><td
<?php
while ($row = mysql_fetch_array($results
echo "<tr>\n";
echo "<td valign=top rowspan=2>" . $row['lot_num'] . "</td>\n";
echo "<td valign=top rowspan=2><a href='details.php?horse_na
echo "<img src='foalpics/" .$row['main_pic']. "' width='75px' alt='" . $row['main_pic'] . "'></td>\n";
echo "<td valign=top height=15>$" . $row['bid'] . "</td>\n";
echo "<td valign=top height=15>" . $row['bidding_status'] . "</td>\n";
echo "<td valign=top height=15>". $row['closing_date'] . " " . $row['closing_time'] . "</td>\n";
echo "</tr>\n";
$pedquery = "SELECT * FROM pedigree, horses WHERE pedigree.horseID = '" . $_SESSION['horseID'] . "' AND horses.horseID = '" . $_SESSION['horseID'] . "'";
$pedresults = mysql_query($pedquery)
or die(mysql_error());
$ped = mysql_fetch_array($pedresu
echo "<tr><td colspan=3 height=55>" . $ped['S_Name'] . " X " . $ped['DS_Name']. " X " . $ped['DDS_Name'] . " </td></tr>\n";
next($bids);
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah ha ... you pointed me directly where I needed to go ... all I had to do was take out the session ans replace it with the row variable ... thank you thankyou ..I was smacking my head and just couldn't see it ...
No problem =)
Your code looked so clean and efficient that I thought it would be something simple like that.
I like to see clean code like you have there, keep it up.
Joe P
Your code looked so clean and efficient that I thought it would be something simple like that.
I like to see clean code like you have there, keep it up.
Joe P
ASKER