semi-advanced forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mabufo
Forum Commoner
Posts: 81
Joined: Thu Jul 10, 2003 11:11 pm
Location: Orland Park, IL
Contact:

semi-advanced forms

Post by mabufo »

I want to have a page for managing database entries. It's easy enough to list the entries, and to delete them one at a time... but what I would like to do is output all of the entries in my 'quotes' table, and have the user select which ones need to be deleted (the user should be able to somehow check them off, and then be able to click 'delete selected'). How do I do this sort of thing? I have an idea about how this is done, it's just the implementation that is throwing me off, could anyone show me - or point me in the direction of a tutorial that could? Also, say I want to edit an entry... is it possible to get my php script to load the item of data in a textbox with a sort of submit button next to it? Once again, querying the database for the info is doable for me - it takes like 5 seconds of looking at the documentation for that one, but it's the practical application of this sort of form trickery that I have to learn by example.

Anything other than text input in forms is something I don't know how to do.

Thanks again.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Think checkboxes and arrays, then search for form handling and multiple inputs.
User avatar
mabufo
Forum Commoner
Posts: 81
Joined: Thu Jul 10, 2003 11:11 pm
Location: Orland Park, IL
Contact:

Post by mabufo »

Thanks, I'm not really on board with the terminology.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Reg. multiple selects, have a look at this one http://www.javascripttoolbox.com/lib/se ... amples.php
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Sometimes trying something can be worth a ton...

Code: Select all

<?php
if (!empty($_POST))
{
    echo '<pre>'; var_dump($_POST); echo '</pre>';
}
?>
<form action="<?php echo basename(__FILE__); ?>" method="post">
<input type="checkbox" name="check[]" value="1" checked="checked" />Check 1<br />
<input type="checkbox" name="check[]" value="2" />Check 2<br />
<input type="checkbox" name="check[]" value="3" checked="checked" />Check 3<br />
<input type="checkbox" name="check[]" value="4" />Check 4<br />
<input type="submit" name="submit" value="Send Test" />
</form>
User avatar
mabufo
Forum Commoner
Posts: 81
Joined: Thu Jul 10, 2003 11:11 pm
Location: Orland Park, IL
Contact:

Post by mabufo »

Much appreciated. For me, it's just easier to learn by example. With what you posted, if I understand, the array is filled with the name of whatever was checked off(the button's 'value'), and from there I can iterate through the array and deal with each element(form value).

I think I get it, and that greatly helps.

EDIT: I'll be sure to post what I have when I'm finished so people can see a cool working example.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You got it.
Post Reply