Adjusting listbox size
Posted: Mon Dec 15, 2003 2:48 pm
My (dropdown) listbox only shows 11 records. I would like it to show all the records when the user opens it.
Any advice?
Any advice?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
function createSelect ( $Sname, $table, $select_id="", $name ) {
# $Sname is the name to be applied to the select control.
# $table is the name of the table to query.
# NOTE: This function assumes you are using a lookup table that has 2 fields (id,name) or you only name those 2 fields in your sql statement.
# $any 0=Without the "Any" option, 1=With the "Any" option, this is a NULL value.
# $curr_id is used to set the "SELECTED" flag on the select control.
include("config.php");
$sql = "SELECT * FROM $table ORDER BY $name";
$results = mysql_query($sql);
printf("<select name="$Sname">\n");
while ($row = mysql_fetch_array($results)):
if ($Sname == "urgency") {
$id = $row["urgency_id"];
$name = $row["description"];}
if ($id == $select_id) {
printf("<option SELECTED value="$id">$name\n");
} else {
printf("<option value="$id">$name\n");
}
endwhile;
printf("</select>\n");
}
?>Code: Select all
<?php
function createSelect ( $Sname, $table, $select_id="", $name ) {
# $Sname is the name to be applied to the select control.
# $table is the name of the table to query.
# NOTE: This function assumes you are using a lookup table that has 2 fields (id,name) or you only name those 2 fields in your sql statement.
# $any 0=Without the "Any" option, 1=With the "Any" option, this is a NULL value.
# $curr_id is used to set the "SELECTED" flag on the select control.
include("config.php");
$sql = "SELECT * FROM $table ORDER BY $name";
$size = mysql_num_rows($results);
$results = mysql_query($sql);
printf("<select name="$Sname" size="$size">\n");
while ($row = mysql_fetch_array($results)):
if ($Sname == "urgency") {
$id = $row["urgency_id"];
$name = $row["description"];}
if ($id == $select_id) {
printf("<option SELECTED value="$id">$name\n");
} else {
printf("<option value="$id">$name\n");
}
endwhile;
printf("</select>\n");
}
?>I was assuming from this that is what gator wanted. I think I am confused.gator wrote:Yes they are being displayed. The user just has to use the scroll bar.
Bah, it's not you, it's me. Trust me.gator wrote:I think Microthick has got it.
Paddy your solution works but it changes the listbox from a dropdown listbox to a listbox.
please forgive my teminology.
Thanks guys