Code trouble probably simple
Posted: Mon May 15, 2006 12:59 pm
Hi,
I am trying to use three select boxes together, each of which update the next one.
All of the data for all of them is from a mySQL database.
What I am doing is resubmitting the form each one is changed, now, to stop the selected values from going, I am writing them to a variable and recieving them as they are posted. Then when filling the select box after the form has been submitted I make the varialbe the selected value. The only problem is that it is only storing the first word of the selected entry. e.g. for "Isle of Man" it gets "Isle", this seems bazarre.
Here is the code, I hope you guys can help..
First is right at the top of the code where the value is saved:
Then is where the select box is populated from the database..
I am trying to use three select boxes together, each of which update the next one.
All of the data for all of them is from a mySQL database.
What I am doing is resubmitting the form each one is changed, now, to stop the selected values from going, I am writing them to a variable and recieving them as they are posted. Then when filling the select box after the form has been submitted I make the varialbe the selected value. The only problem is that it is only storing the first word of the selected entry. e.g. for "Isle of Man" it gets "Isle", this seems bazarre.
Here is the code, I hope you guys can help..
First is right at the top of the code where the value is saved:
Code: Select all
//remember value of region box
$reg = "";
if (isset($_POST['selid']))
{
$reg = $_POST['selid'];
}Then is where the select box is populated from the database..
Code: Select all
<?php
$query="select instRegion from instregions_details";
$result = mysql_query ($query);
$num_results=mysql_num_rows($result);
echo '<input type="hidden" name="a" value="1">';
echo '<select name="selid" onChange="form1.submit();">';
for($i=0; $i<$num_results; $i++)
{
$row=mysql_fetch_array($result);
if ($row['instRegion'] == $reg)
{
//value was saved
echo "<option selected>".$row["instRegion"]."</option>";
}
else
{
echo '<option value='.$row["instRegion"].'>';
}
echo htmlspecialchars(stripslashes($row["instRegion"]));
echo "</option>";
}
echo '</select>';
?>[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.