Forum Moderators: coopster
If anyone has the energy to take a look and offer their suggestions, it would be greatly appreciated. Here is my script. PS. I can add a record and view all the records through other scripts with no problem.
<?php # Script 11.6 - md_seaauthor.php
// This page searches titles by author.
// Set the page title and include the HTML header.
$page_title = 'Search Mother Daughter Bookclub by Author';
include_once ('header4.html');
require_once ('Connections/mysql_connect.php');
// Connect to the database.
$query = "SELECT * FROM mdbookclub
WHERE author ='$author'";
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result)) {
$md = $row['md_id'];
$title = stripslashes($row['title']);
$author = stripslashes($row['author']);
$f_author = stripslashes($row['f_author']);
$pub_year = stripslashes($row['pub_year']);
$call_number = ($row['call_number']);
$display_block .= "<p><strong>Author:</strong> $author <strong>Title:</strong> $title<br />
<strong>Publication year:</strong> $pub_year <br />
<strong>Call number:</strong> $call_number </p>";
}
?>
to rule out some common issues, as LM pointed out make sure mysql returns a dataset for the query generated by your search page. then replace $author by a raw value to see if it does any good. use mysql_num_rows() to see how many records are being returned
echo mysql_num_rows($result);
$result = mysql_query ($query) or die(mysql_error());
Thanks to both of you. I learnt some more important PHP stuff, such as testing it in my PHPMyAdmin.
I think this forum is the best.
Every time I've posted a question, I got such prompt and wise replies.