|
Posted by Jeff North on 07/21/07 01:08
On 21 Jul 2007 00:30:17 GMT, in comp.lang.php "Larry L [in Honolulu]"
<larry@no-place.org>
<46a15399$0$20594$4c368faf@roadrunner.com> wrote:
>| NC <nc@iname.com> wrote in news:1184973751.142209.176900
>| @d30g2000prg.googlegroups.com:
>|
>| > On Jul 20, 4:07 pm, "Larry L [in Honolulu]" <la...@no-place.org>
>| > wrote:
>| >>
>| >> I have a dropdown list dynamically created in a form
>| >> by PHP from a MySql table. This is the only element
>| >> on the page. For some records there is only a single
>| >> selection, and if that's the case I'd like to just
>| >> post that and go to the next page. Is there a simple
>| >> way to do that using POST?
>| >
>| > Yes, but it's got nothing to do with PHP:
>| >
>| > <form method="POST" action="[your_action_goes_here]">
>| > <select name="mySelect" id="mySelect"
>| > onChange="mySelect.form.submit()">
>| > <option value="">Select an option
>| > <option value="1">Option 1
>| > <option value="2">Option 2
>| > <option value="3">Option 3
>| > <option value="4">Option 4
>| > </select>
>| > </form>
>| >
>| > Cheers,
>| > NC
>|
>| Well thanks, but maybe I didn't explain it well enough. I have pretty
>| much exactly what you show, but sometimes when the page loads, and the
>| options list is created, there is only one item there. If that's the
>| case, then I don't want to even show it, I just want the one option
>| posted to the next page.
>|
>| Larry
PHP Manual example:
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);
$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);
echo "$num_rows Rows\n";
?>
instead of echoing the number you would use
if( $num_rows == 1 )
header("location: pag2.php");
This is provided you haven't sent any information to the browser
already.
-- -------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
-- -------------------------------------------------------------
Navigation:
[Reply to this message]
|