Hi.. I'am encountering a problem with this code.
I have combo boxes that submits information once an item was selected. The information I needed, correctly displayed on the screen but the problem is when I add another combobox the information on the first combox doesn't show. I can't figure out the problem. Can someone help me with this? Any suggestion or help will always be appreciated.
Thanks,
Seven
Code:
<form method="post" action="http://bytes.com/jf.php"> <select name="category" onchange="this.form.submit()"> <option value="" selected>Select a category</option> <?php
mysql_connect("localhost","root","");
mysql_select_db("test");
$category = "SELECT * FROM achievercollege";
$query_result = mysql_query($category);
while($result = mysql_fetch_assoc($query_result))
{
?> <option value = "<?php echo $result['id']?>"><?php echo $result['id']?></option> <?php
}
?> <?php
mysql_connect("localhost","root","");
mysql_select_db("test");
$query = "SELECT * FROM achievercollege where id = '".$_POST['category']."'";
$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result); ?> <?php
$row = $rows;
for ($j=0;$j<$row;++$j){
$rows=mysql_fetch_row($result);
?> <?php };?> </select> <input type="text" value="<?php echo $rows[1]; ?>" /> <td>*</td> <input type="text" value="<?php echo $rows[2]; ?>" /> <td>*</td> <input type="text" value="<?php echo $rows[3]; ?>" /> <select name="jean" onchange="this.form.submit(1)"> <option value="" selected>Select a category</option> <?php
mysql_connect("localhost","root","");
mysql_select_db("test");
$category = "SELECT * FROM achievercollege";
$query_result = mysql_query($category);
while($result = mysql_fetch_assoc($query_result))
{
?> <option value = "<?php echo $result['id']?>"><?php echo $result['id']?></option> <?php
}
?> <?php
mysql_connect("localhost","root","");
mysql_select_db("test");
$query = "SELECT * FROM achievercollege where id = '".$_POST['jean']."'";
$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result); ?> <?php
$row = $rows;
for ($j=0;$j<$row;++$j){
$rows=mysql_fetch_row($result);
?> <?php };?> </select> <input type="text" value="<?php echo $rows[1]; ?>" /> <td>*</td> <input type="text" value="<?php echo $rows[2]; ?>" /> <td>*</td> <input type="text" value="<?php echo $rows[3]; ?>" /> </form>
I have combo boxes that submits information once an item was selected. The information I needed, correctly displayed on the screen but the problem is when I add another combobox the information on the first combox doesn't show. I can't figure out the problem. Can someone help me with this? Any suggestion or help will always be appreciated.
Thanks,
Seven
Comment