Web Development

General discussion


PHP & MySQL: Print selected record(s)?

By hoylakeinfo ·
Hello Republic!

I am able to query a table for all of it's records, and display the results within an HTML form, with each record appearing beside a checkbox control.

I would like to be able to select single, multiple, or all records via the checkbox for each record returned, and then merge the fields from the record returned with a .txt document template.

Currently, I am able to select as many records as I like, but only the first selected record's fields are merged with the .txt file.

If there are any examples that you can point me to, I'd very much appreciate it.

Or, if you're a PHP super-hero and willing to take on this challenge, send me an email (hoylakeinfo@yahoo.com) and I will send the code, txt file, and a script for defining the mySQL tables that the program requires.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by mac1ne In reply to PHP & MySQL: Print select ...

sounds like you do not have the form checkbox and other values named defined as arrays? i.e. make sure they are named with a [].

<input type='checkbox' name='record_uid[]' value='incremental value'>
<input type='text' name='username[]' value='J Smith'>
<input type='text' name='address[]' value='123 main'>

your code to get the selected values would need to loop through the array.

foreach ($_POST['record_uid[]'] as $uid) {
/* the row with this $uid was checked */
echo $_POST["username[".$uid."]"];
echo $_POST["address[".$uid."]"];


Related Discussions

Related Forums