Re: Help with POSTing variable array names from a PHP script please.

From: Date: Sat, 15 Feb 2003 10:38:26 +0000
Subject: Re: Help with POSTing variable array names from a PHP script please.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-135649@lists.php.net to get a copy of this message
Jason Thanks for your help . I've implemented you advice. The problem persists in that I'm trying create the following situation: When the posted action php script runs I want the retrieved $_POST array to contain such information that the action script can find out what checkboxes were clicked and from there the library books to retrieve. So what do I need to write: 1. for the checkbox line in the driving script, e.g. type="checkbox" name="???" value ="ON" 2. in the action script, e.g. $result = $_POST[???]; Mike --- Jason Wong wrote:
On Saturday 15 February 2003 17:05, Michael Eacott wrote:
<? php # 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)) {
Your while loop is loop at the wrong place. Look at the HTML source of your page ...
$booksid = $rowarray["booksid"]; $title = $rowarray["title"]; print '<html>'; print '<head>'; print '<meta http-equiv="Content-Language" content="en-us">'; print '<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">';
[snip] ... these are all repeated for each book. Clearly that's not what you want.
print '<p>Click box get following book retrieved.
Your loop should start here:
<input type="checkbox" name="book[1][$booksid]" value ="ON" ><br>';
You've setup a counter ($count) so make use of it: <input type="checkbox" name="book[$count][$booksid]" value ="ON" >


« previous php.general (#135649) next »