Re: Help Please



On Jun 15, 12:21 am, jsd219 <i...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
I am going crazy over here. here is my code:

$query = "SELECT SEC_TITLE, SEC_ID
FROM section
WHERE SEC_TITLE != ''";

$result = mysql_query($query);

echo "<form action='#'>\r\n<select name='id'>";
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
$section = $line[0];
$id = $line[1];

//echo " <option value=$section>$section\r\n";

echo " <option value='$id'>$section</option>\n";

}

I need to pull both a name=id & name=section. and then send both via
the option value. What this does is it pulls all the section titles
for the table section and places them into a drop down box, when you
select one of the sections and send the form it places that section
title in the section field of the category table. i need it to not
only send the section title but also the section id to the id field of
the category table.

I am at a complete loss, Please someone help me

God bless
jason


just combine both id and section into a single variable!

echo '<form method="get">';
echo '<select name="combined">';
echo ' <option value="'.$id.'|'.$section.'">$section</option>'."\n";
#etc...
echo '</select>';
echo '</form>';


<?php

if( isset($_GET['combined'] && ($_GET['combined']!='') )
{
$arrayIdAndSection = explode( '|', $_GET['combined'] );
$id = $arrayIdAndSection[0];
$section = $arrayIdAndSection[1];
}

?>



.



Relevant Pages

  • Re: Newbie PHP question: hiding code on server from View Source
    ... I never was able to figure out CGI on a remotely hosted web server the ... few times I tried, but PHP is working fine...at ... You can use it much like an "include" command to pull in PHP routines ...
    (comp.lang.php)
  • Re: PHP equivalent of perls HTML::TreeBuilder;
    ... So I need to pull out the navigation blocks and page display ... convenience in PHP? ... Once you have a DOMDocument object, you can even feed it to the SimpleXML functions and do cool stuff like this: ... // Fetch titles: ...
    (comp.lang.php)
  • Re: mySQL Query with varchar(5000) fields will not pull data from thesefields
    ... When run in mySQL console I can see it pull the data from the varcharok but when the same query is executed under PHP I cannot get any information from the varcharfields. ...
    (comp.lang.php)
  • Re: [PHP] Authentication
    ... Within PHP, is there a way to pull the name of the user that is currently ... I know with some of the _SERVER functions you can pull the IP of the machine ... had success employing it.... ...
    (php.general)
  • Re: [PHP] can a session be used in a query?
    ... I have the session working, and can echo it to see that .. ... in the query to pull only that users data I also on the login page where I ... the query UserName = $UserName I get an undefined variable error... ...
    (php.general)