Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select
Okay, so I have my page "List Customers" which then links to "List Jobs" adding on ?custID=
into the URL, then on List jobs I have used $_GET["custID"]
so my query uses the custID
from the URL. that works fine, lists out my jobs for said customer using their ID.
My problem comes up now, I need the links on this page to give my third page the techID
as well. But the techID
is in jobDetails
, so my query cannot give them the techID
as it is querying my job
section.
This is my "ListJobs.php" page, which upon choosing a customer in the page before it, loads this page with the url ListJobs.php?custID=001
(001 being an example, it will give the number depending on your choice of customer).
<?php
// Get data from the database depending on the value of the id in the URL
mysql_select_db($database_con_sim5, $con_sim5);
$query_Recordset1 = "SELECT * FROM job WHERE custID=" . $_GET["custID"] ;
$Rs1 = mysql_query($query_Recordset1);
// Loop the recordset $rs
while($row = mysql_fetch_array($Rs1)) {
$strName1 = $row['jobID'] . " " . $row['jobDesc'] . " " . $row['computerName'];
$strLink = "<a href = 'jobDetails.php?jobID=".$row['jobID']."'>".$strName1."</a>";
// Write the data of the person
echo "<li>" . $strLink . " </li>";
}
// Close the database connection
mysql_close();
?>
Then on pressing one of the links, link to jobDetails.php?jobID=
with the job number.
I am able to show all the details in Job Detail with this, but I also need my Tech Name
to appear, Tech Name
is not in Job Details
, but Tech ID
is.
Here is my Job Details page coding :
<?php
// Get data from the database depending on the value of the id in the URL
mysql_select_db($database_con_sim5, $con_sim5);
$query_Recordset1 = "SELECT * FROM jobDetail WHERE jobID=" . $_GET["jobID"] ;
$query_Recordset2 = "SELECT technician.techName FROM technician
WHERE techID=" . $query_Recordset1["techID"] ;
$Rs1 = mysql_query($query_Recordset1);
$Rs2 = mysql_query($query_Recordset2);
while($row1 = mysql_fetch_array($Rs1)) {
while($row2 = mysql_fetch_array($Rs2)) {
echo "<dt><strong>Job Note ID:</strong></dt><dd>".$row1["jobNoteID"]."</dd>";
echo "<dt><strong>Job Notes:</strong></dt><dd>".$row1["jobNotes"]."</dd>";
echo "<dt><strong>Date Completed:</strong></dt><dd>".$row1["dateCompleted"]."</dd>";
echo "<dt><strong>Time Spent:</strong></dt><dd>".$row1["timeSpent"]."</dd>";
echo "<dt><strong>Job ID:</strong></dt><dd>".$row1["jobID"]."</dd>";
echo "<dt><strong>Technician ID:</strong></dt><dd>".$row1["techID"]."</dd>";
echo "<dt><strong>Technician Name:</strong></dt><dd>".$row2["techName"]."</dd>";
}
}
// Close the database connection
mysql_close();
?>
The error I am getting is:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\Sim5Server\Pages\jobDetails.php on line 129
That line is:
while($row2 = mysql_fetch_array($Rs2)) {
I hope I am making any sense AT ALL.
To sum up, I need my final page to show data from mysql technician using the Primary/index key techID. Some way to add techID onto either listJobs' links to job details or in job details' second Recordset.
EDIT: I should probably state this will never be used on the net, I only need it to work for an assignment. in future, thanks to a comment, I will no longer be using mysql_* I am jsut using them as my entire workbook tells us to use it.