I'm attempting to "print" to the client's browser a list of book titles
found in a MYSqL table, each with a checkbox on its "printed" line so
that the client can click on the checkboxes to retrieve selected books.
The php script below is included after verification of the fields in an
HTML form.
Global variable $books is the name of the books table in the connected
database.
Variable $title contains the string to be used to search for matching
book titles in the books table of the library.
I was hoping that the checkboxes printed would have different array
indexes when script "booksretrieve" is posted.
There must be a much better way than the following old mainframe style
of scripting I've done.
After the php scripts there is a sample of what was "printed" by the
client browser.
Help please.
Mike
# Show details of BOOKS
# Performing SQL query
$query = "SELECT * FROM `$books` WHERE `title` LIKE '$title' LIMIT 99";
$result = mysql_query($query) or die("Query failed");
$count = 1; $bookslist = "";
while ($rowarray = mysql_fetch_array($result, MYSQL_ASSOC))
{
$booksid = $rowarray["booksid"];
$title = $rowarray["title"];
print '';
print '';
print '';
print '';
print 'Library Search results';
print '';
## NOTE php script to run
#
print '';
print '';
$bookslist to be used by ###
if ($bookslist == "") $bookslist = $booksid;
else $bookslist = $bookslist. ",". $booksid;
print "Book number: $booksid in bookslist $bookslist .";
print 'Click box get following book retrieved. ';
print "";
print "title:. " .$title. " ";
print "-";
$count = $count + 1;
}
# Free resultset */
mysql_free_result($result);
print "Click 'Clear all fields' if you do NOT want us to do
this. ";
print ' ';
print "";
print "";
return;
?>
#
#BOOKSRETRIEVE : Retrieve library books selected by clicked checkboxes.
#
echo "BOOKSRETRIEVE. Array contents print as:";
$result = $_POST['book'];
print_r($result);
return;
?>
Sample of what was "printed" by the client browser (checkboxes shown as #):
Book number: 0 in bookslist 0 .
Click box get following book retrieved. #
title:. Book title A
-
Book number: 3 in bookslist 0,3 .
Click box get following book retrieved. #
title:. Book title C
-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php