|
Posted by J.O. Aho on 12/31/06 06:16
chrisollar wrote:
> I've got two files.
> start.php and finish.php
>
> when I query the mysql database the combo box displays great. But when
> I try to pass the information on to the next page I only get the first
> word of the field if there are more than one words.
> I'm sure that it's something to do with the white spaces. I'm hoping to
> find some simple yet elegant help.
>
> Here's start.php
>
> <html>
> <head>
> <title>Radiator Part Number Search</title>
> </head>
> <body>
> <h3>Start by selecting your Make and then clicking "Submit"</h3>
>
>
> <?php
> mysql_connect("localhost", "login", "password") or die(mysql_error());
> //echo "Connected to MySQL<br />";
>
> mysql_select_db("fotechtx_radiator") or die(mysql_error());
> //echo "Connected to Radiator Database";
>
> $query="SELECT DISTINCT make FROM radiator ORDER BY make ASC";
>
>
> $result = mysql_query ($query);
> echo "<form name=form method=post action=finish.php>";
>
> echo "Make</br>";
> echo "<select name=carmake value=''>Select Make</option>";
> while($nt=mysql_fetch_array($result)){
> echo "<option value=$nt[make]>[make]</option>";
> //\"".$row["adres"]."\">,
> }
> echo "</select>";
>
> echo "<p> <input type=submit name=Submit value=Submit>";
> echo "<input type=reset name=Reset value=Reset>
> </p>";
> echo "</form>";
>
>
> ?>
>
>
>
>
>
>
>
>
> </body>
> </html>
>
>
>
>
>
>
> And here is finish.php:
>
> <html>
> <head>
> <title>Radiator Part Number Search</title>
> </head>
> <body>
> <h3>Now Select your Model and press Submit</h3>
>
> <?php
> // echo "<p>Make: " . $_POST['carmake']."</p>\n";
> //echo "<p>listbox: " . $_POST['listbox'] . "</p>\n";
> $make_value = $_POST["carmake"];
> echo "$make_value";
> //echo "$make_value ";
> //foreach ($values as $a){
> // echo $a;
> //}
> //echo "</p>\n";
> ?>
>
> <?php
> //echo "$make_value ";
> mysql_connect("localhost", "login", "password") or die(mysql_error());
> //echo "Connected to MySQL<br />";
>
> mysql_select_db("fotechtx_radiator") or die(mysql_error());
> //echo "Connected to Radiator Database";
>
> $query="SELECT DISTINCT HEADING FROM radiator WHERE MAKE= '$make_value'
> ORDER BY HEADING";
>
> $result = mysql_query ($query);
> echo "<form name=form method=post action=more.php>";
>
> echo "Make</br>";
> echo "<select name=carmake value=''>Make Selected</option>";
> echo "<option value=$make_value>$make_value</option>";
> echo "</select>";
>
> echo "</br>";
> echo "</br>";
> echo "</br>";
>
> echo "Model</br>";
> echo "<select name=carheading value=''>Select Model</option>";
> while($nt=mysql_fetch_array($result)){
> echo "<option value=$nt[HEADING]>$nt[HEADING]</option>";
This has nothing to do with PHP, but bad HTML, you should always use quotes
around HTML values
echo "<select name=\"carmake\" value=\"\">Make Selected</option>";
echo "<option value=\"$make_value\">$make_value</option>";
echo "<select name=\"carheading\" value=\"\">Select Model</option>";
echo "<option value=\"$nt[HEADING]\">$nt[HEADING]</option>";
echo "<p> <input type=\"submit\" name=\"Submit\" value=\"Submit\">";
echo "<input type=\"reset\" name=\"Reset\" value=\"Reset\">
A whitespace is used in HTML to separate arguments
example:
<input type="text" name="something" value=Hello Big John>
This makes the value to be 'Hello' and you will have two unknown arguments,
'Big' and 'John'
<input type="text" name="something" value="Hello Big John">
Here the value will be 'Hello Big John'.
Why not use single quotes and don't have to use the backslash? There are
browsers that have major problems with single quotes, even if single quotes
are allowed in HTML.
--
//Aho
Navigation:
[Reply to this message]
|