|
-
Apr 5th, 2004, 01:31 AM
#1
Combo box
If I submit some variables to a php page. How can I get the values into a combobox. Isn't the combo box declared in HTML? So how do I get the variables there....or is there something that I don't know about here?
-
Apr 5th, 2004, 02:13 AM
#2
This does not seem to work, and I am not surprised...just had to test...
Code:
<select name="sNavn" >
<?php
$db=mysql_connect ("localhost", "klub_note", "motvekt") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("klub_info");
if (!$db){
echo 'I cannot connect to the database because: ' . mysql_error();
exit;
}
mysql_select_db ("klub_info");
$resultat = mysql_query("SELECT sNavn FROM Sted",$db);
$innkode = mb_internal_encoding();
while ($rekke = mysql_fetch_array($resultat)) {
mb_convert_variables($innkode, "ASCII, UTF-8, ISO-8859-1", $rekke);
$id = $rekke["id"];
$sNavn = stripslashes($rekke["sNavn"]);
?>
<option value="<?php sNavn ?>"><?php sNavn ?></option> <?php
}
?>
</select>
-
Apr 5th, 2004, 03:34 AM
#3
uh, well, first off your code doesn't get submitted variables and put them into a combo box, it takes stuff from a MySQL database.. so, I'll just build around that.
PHP Code:
<select name="opt">
<?
$qry = mysql_query("SELECT snavn FROM sted");
while($arr = mysql_fetch_array($qry)){
echo " <option value=\"$arr[snavn]\">$arr[snavn]\n";
}
?>
</select>
-
Apr 5th, 2004, 04:22 PM
#4
Originally posted by kows
uh, well, first off your code doesn't get submitted variables and put them into a combo box, it takes stuff from a MySQL database.. so, I'll just build around that.
PHP Code:
<select name="opt">
<?
$qry = mysql_query("SELECT snavn FROM sted");
while($arr = mysql_fetch_array($qry)){
echo " <option value=\"$arr[snavn]\">$arr[snavn]\n";
}
?>
</select>
I must have been really tired this morning when I said that they where going to be submitted. I will have that on a page too. But not the first one.
After some debuggin here..I dinaly manage to change all the variable names right. And now it works like a dream here....
Thanks a lot kows. You have saved my day. I would never have guessed that I had to echo the whole combo box.
Thanks ØØ.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|