I have a table in which shows records from a table called "JOB_TABLE".
In the final column I have a row called "BIDS", which shows the number of bids which were placed on each specific "job".
Here's the thing. Take a look at $query02. If I replace the variable '$jobID' with a static number, it will populate the first row of the table with the proper amount of BIDS from the bid table, although it will only do it for the first record,
AND for the amount of bids for the static number I put into query02.
If I put in '1' the last row shows 6 ( i have six bids for that record)
If I put in '2' the last row shows 3 ( i have three bids for that record)
so it appears that that are two things not working quite right.
why doesnt the inner WHILE loop recognize the value of '$jobID'?
why does the loop only go through once and not for each row that has bids?
any help is greatly appreciated.
http://www.jbai2.com/000/jobs/jobsviewall.php <-- contains the job listing
http://www.jbai2.com/000/bids/bids.php <-- contains the bids for each job....you will see 6 ONES and 3 TWOS
any help is greatly appreciated.
</style>
<script language="JavaScript" type="text/javascript">
<!--
function jbaiJobViewer(jobID)
{
var popPath= "joboptions.php?tool=view&jobID=" + jobID;
// <?php print $jobID; ?> use this if you want a unique window for each position
window.open(popPath,'jobeditor','width=645,height=470,menubar=no,scrollbars=yes, toolbar=no,location=no,directories=no,resizable=no,top=100,left=100');
}
// -->
</script>
<?php
// set up some variables
// server name
$server = "localhost";
// username
$user = "xxx";
// password
$pass = "xxx";
// database to query
$db = "xxx";
// open a connection to the database
$connection = mysql_connect($server, $user, $pass) or die("Invalid server or user");
// $sortmaster is a column sorter
// the data will come in through the URL
// URL format = viewall.php?showit=VALUE
// check to see if sortmaster VALUE is being passed in URL
if($showit == 'job_title') {
$sortmaster = job_title;
}elseif($showit == 'job_client') {
$sortmaster = job_client;
}elseif($showit == 'job_req') {
$sortmaster = job_req;
}elseif($showit == 'crewID') {
$sortmaster = crewID;
}else{
$sortmaster = creation_date;
}
// formulate the SQL query from a specific table in the database
$query = "select * from job_table WHERE job_status = 'active' ORDER BY $sortmaster" or die(mysql_error());
// SQL query for all bids
$query02 = "SELECT bid_table.bidID FROM bid_table INNER JOIN job_table ON bid_table.jobID = job_table.jobID WHERE job_table.jobID = '$jobID'" or die(mysql_error());
// run the query on the database
$result = mysql_db_query($db, $query, $connection) or die(mysql_error());
$result02 = mysql_db_query($db, $query02, $connection) or die(mysql_error());
// display the result
echo "<span style='font:bold 16px arial, sans-serif;'>ALL ACTIVE REQUIREMENTS</span>";
echo "<table border=0 cellspacing=0 cellpadding=3 style=\"font:10 verdana, sans-serif; text-align:left; width:90%;\">";
echo "<tr class=header>
<td><a href=\"jobsviewall.php?showit=job_req\" class=\"headlink\">Job Req #</a></td>
<td><a href=\"jobsviewall.php?showit=job_title\" class=\"headlink\">Job Title</td>
<td><a href=\"jobsviewall.php?showit=crewID\" class=\"headlink\">Recruiter</td>
<td class=\"headlink\">Bids</td>
</tr>";
// ALTERNATE COLOR FOR ALTERNATE ROWS
// alter nate row color after
$max = 1;
// sets int counter value
$counter = 0;
// count up the total number of active records
$total_recs = 0;
// with a while loop
// this loop will iterate as many times as there are records
while($myrow = mysql_fetch_array($result))
{
$jobID = $myrow["jobID"];
// count up and show the number of bids for each jobID
// bid counter variable
$total_bids = 0;
while ($myBid = mysql_fetch_array($result02))
{
$total_bids++;
}
$job_title = $myrow["job_title"];
$job_req = $myrow["job_req"];
$crewID = $myrow["crewID"];
$total_recs++;
if ($counter < $max) {
echo "
<tr class=\"e1\" counter=$counter>";
$counter++;
}else{
echo "
<tr class=\"e5\" counter=$counter>
";
$counter++;
if($counter == $max*2) {
$counter = 0;
}
}
echo " <td>$job_req</td>
<td><a href=\"JavaScript: jbaiJobViewer($jobID)\">$job_title</a></td>
<td>";
// get the recruiter's name
if ($crewID == 4) { print ("Maret");}
elseif ($crewID == 2) { print ("Alex");}
elseif ($crewID == 1) { print ("Ari");}
elseif ($crewID == 3) { print ("David");}
else { print ("<span style=\"color:#990000; font:bold;\">No recruiter selected</span>");}
echo "</td><td>" . $total_bids . "</td></tr>";
}
// memory flush
mysql_free_result($result);
mysql_free_result($result02);
echo "</table><br>";
echo "<span style=\"font:11px verdana, sans-serif;\">Total Active Jobs :<b>$total_recs</b></span>";
?>
</body>
</html>