Page 1 of 1

two word variable

Posted: Tue Mar 09, 2010 5:44 am
by bakon
Hello, I hope someone can help me with this...
I have a dynamic drop down menu where items ( addresses ) are pulled from sql table.
However,I have a problem to post value when address has two words, like "New Avenue".
What I`m getting on next page is only "New", which is not good for me. I would need both words. Code is below..
THANKS !

<!-------------begin form------------>
<form method="post" action="scoe_v.php">
<input type="Hidden" name="send" value="true">
<TABLE>
<TD> <font size="2" face="Verdana">Address:</font> </td><td>

<?php

$query="select address from contacts order by address";

$result = mysql_query ($query);

echo "<select name=t1 value=''>Select one</option>";

while($nt=mysql_fetch_array($result)){
echo "<form method=post action=scoe_v.php>

<option value=$nt[address]>$nt[address]</option>";

}
echo "</select>";// Closing of list box

?>


</TABLE> <br>
<TABLE>
<TR> &nbsp
<TD> <input type="submit" value="Search" name="Submit"></TD>
</TR>
</TABLE>
</FORM>
<!-------------end form------------>

scoe_v.php -->

$t1=mysql_real_escape_string ($_POST['t1']);

echo "Address: $t1<br>";

With this code, only "New" is showing, even though i would need "New Avenue"..

Re: two word variable

Posted: Tue Mar 09, 2010 6:03 am
by papa
Might work:

Code: Select all

 
<option value={$nt['address']}>{$nt['address']}</option>";
 
 
Your HTML is invalid. You have a <form> element inside a <select> tag.

Re: two word variable

Posted: Tue Mar 09, 2010 6:16 am
by michaeru
Maybe you meant something like this on the form?

Code: Select all

 
<form method="post" action="scoe_v.php">
 
  <input type="Hidden" name="send" value="true">
 
  <table>
 
    <td>
 
      <font size="2" face="Verdana">Address:</font>
 
    </td>
 
    <td>
       
      <select name="t1">
        
        <?php
 
          $query="select address from contacts order by address";
 
          $result = mysql_query ($query);
 
          while($nt=mysql_fetch_array($result, MYSQL_ASSOC)) {
 
        ?>
 
          <option value="<?php echo $nt[address]; ?>"><?php echo $nt[address]; ?></option>
 
        <?php
 
          }
 
        ?>
 
      </select>
 
    </td>
 
    <td>
      
      <input type="submit" value="Search" name="Submit">
 
    </td>
 
  </table>
 
</form>