Re: Function fill dropdown
So you want this to be able to change dynamically or load once when the page loads?
Either way, assuming that you don't need to worry about people manually modifying the branch number, you could have a php page that serves this up and grabs the branch number from the querystring.
If you need to have it change dynamically, then you would want to look into AJAX. A good starter tutorial can be found here
Re: Function fill dropdown
Quote:
Originally Posted by
kfcSmitty
So you want this to be able to change dynamically or load once when the page loads?
Either way, assuming that you don't need to worry about people manually modifying the branch number, you could have a php page that serves this up and grabs the branch number from the querystring.
If you need to have it change dynamically, then you would want to look into AJAX. A good starter tutorial can be found
here
no what i mean i am making a function out of that code...i created somtthing like this
Code:
function filldropdown($tbname,$drpname,$rowid,$rowname,$rowsel){
$query4="SELECT * FROM $tbname";
$result4 = mysql_query ($query4);
echo "<select name=$drpname id=textbox value=''>$drpname";
// printing the list box select command
while($nt=mysql_fetch_array($result4)){//Array or records stored in $nt
echo '<option '.($nt['$rowid'] == $rowsel ? 'selected':'').' value="'.$nt['$rowid'].'" >'.$nt['$rowid'].'-'.$nt['$rowname'].'</option>';
}
if i do a function like the code above...it doesn't select a value, colored red is the code for selecting value
Re: Function fill dropdown
if you have any variables encased in single quotes, PHP will take those variables as a literal string rather than processing them. eg.
PHP Code:
$hello = "Greetings!";
echo '$hello'; //echos: $hello
echo "$hello"; //echos: Greetings!
echo $hello; //echos: Greetings!
so, every time you reference $nt['$rowid'], PHP is looking for the key (LITERAL STRING) $rowid, rather than the actual value of $rowid. reference $nt[$rowid] instead. likewise for $nt['$rowname']; use $nt[$rowname].