polorboy
03-22-2007, 09:28 AM
Ok, This code should look familiar to some of you:
<?php
$query = "SELECT Company FROM Customer WHERE Sales_Rep = '$salesrep';";
$result = mysql_query($query) or die("SQL Error: " . $query . "<br/>" . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $key => $val) {
$msg .= "<option value='".$val."' >".$val."</option>";
}
}
?>
I was having a problem with getting php to make a form with a select box in it. I got it to work, and I can load a list from MySQL and make a selection box out of it. The wierd thing is that when I make a selection from the list and submit it through my form:
<form enctype='application/x-www-form-urlencoded' method='post' target='<?php echo $_SERVER['PHP_SELF']; ?>'>
<select name='clients' id='clients'>
<option selected="selected" value="">-Select One-</option>
<?php
print $msg;
?>
</select><br />
<input type="submit" value="Search" name="search" id="search" />
<input type="submit" value="Update" name="update" id="update2" />
</form>
It always opens in a new window. I do not have any code anywhere on that page or any other page that tells the browser to open a new window. It will only open a new window when I pick my first selection, any other selection after that opens in the same "new" window. Can anyone think of a reason why this would happen? It doesn't make any sense to me. Thanks.
Also, if I open a new window and make another selection from the list, it will open the selection in the original window it was opened in. I don't know how on earth I did this, but it is kind of annoying.
<?php
$query = "SELECT Company FROM Customer WHERE Sales_Rep = '$salesrep';";
$result = mysql_query($query) or die("SQL Error: " . $query . "<br/>" . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $key => $val) {
$msg .= "<option value='".$val."' >".$val."</option>";
}
}
?>
I was having a problem with getting php to make a form with a select box in it. I got it to work, and I can load a list from MySQL and make a selection box out of it. The wierd thing is that when I make a selection from the list and submit it through my form:
<form enctype='application/x-www-form-urlencoded' method='post' target='<?php echo $_SERVER['PHP_SELF']; ?>'>
<select name='clients' id='clients'>
<option selected="selected" value="">-Select One-</option>
<?php
print $msg;
?>
</select><br />
<input type="submit" value="Search" name="search" id="search" />
<input type="submit" value="Update" name="update" id="update2" />
</form>
It always opens in a new window. I do not have any code anywhere on that page or any other page that tells the browser to open a new window. It will only open a new window when I pick my first selection, any other selection after that opens in the same "new" window. Can anyone think of a reason why this would happen? It doesn't make any sense to me. Thanks.
Also, if I open a new window and make another selection from the list, it will open the selection in the original window it was opened in. I don't know how on earth I did this, but it is kind of annoying.