As of now I have no errors in my program, but I need the primary key for one of the tables for a relation for the following Query. but instead of getting a actual number the value the query is sending back is
Resource id #4
Here is my Code: (The query that I'm having issues with is the $sql_branch, is there a function to change the result from "Resource id #4" to just 4?
$sql_branch = "SELECT BranchNum
FROM Branch
WHERE BranchName = '$_POST[branch]'";
$sql_result = "SELECT AuthorFirst, AuthorLast, OnHand, Title
FROM Inventory i, Wrote w, Author a, Book b
WHERE i.BookCode = b.BookCode AND i.BookCode = w.BookCode
AND a.AuthorNum = w.AuthorNum AND i.BranchNum = 1";
$connect = mysql_connect('students', 'xxxx', 'xxxx') or exit(mysql_error());
mysql_select_db('henrybooks', $connect);
if(mysql_query($sql_branch, $connect)) {
$branch = mysql_query($sql_branch, $connect);
}
else {
echo mysql_error();
}
if(mysql_query($sql_result, $connect)) {
$result = mysql_query($sql_result, $connect);
}
else {
echo mysql_error();
}
echo $branch."<br>";
echo $sql_branch."<br>";
echo "<table>
<tr>
<td>Author</td>
<td>Title</td>
<td>Number Available</td>
</tr>";
while( $row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row['AuthorFirst'].$row['AuthorLast']."</td>";
echo "<td>".$row['Title']."</td>";
echo "<td>".$row['OnHand']."</td>";
echo "</tr>";
}
echo "</table>";
?>
Thanks!