For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > March 2007 > Re: [PHP-DB] Using multiple submits on a page and retaining $POST data









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Using multiple submits on a page and retaining $POST data
Onochie Anyanetu

2007-03-16, 6:58 pm

solved.

Thanks Dan, this was pretty much the solution I came up with. Thank you
Gunawan for the idea that got the ball rolling as well

Onochie

On 3/16/07, Dan Shirah <mrsquash2@gmail.com> wrote:
>
> Try something like this:
>
> ****Your query here to get your dropdown values****
> **
> *// This first option value will set your default dropdown to display as
> blank*
> echo "<OPTION value=\"\">--SELECT--</OPTION>\n";
>
> *// This will create a loop to return each option of your dropdown*
> foreach ($query_result as $q)
> {
> *// This if statement says that IF the value in your database matches your
> $_POST(selected) value then mark it as SELECTED*
> if ($q['my_column_value'] == $_POST['my_selected_value'])
> echo "<OPTION value=\"{$q['my_column_value']}\"
> SELECTED>{$q['my_column_value']}</OPTION>\n";
> *// This else statement will return your default(unselected) dropdown list
> if it can't match the selected value with a value in your database*
> else
> echo "<OPTION
> value=\"{$q['my_column_value']}\">{$q['my_column_value']}</OPTION>\n";
> }
>
> Hope that helps.
>
> On 3/16/07, Onochie Anyanetu <ubernoch@gmail.com> wrote:
>
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com