LJackson
08-17-2012, 12:53 AM
Hi All
I have the following function which populates list boxes with a list of names
function playerSelect()
{
$sql = "SELECT staffName, staffID, staffType FROM tbl_staff WHERE staffType = 'player' ORDER BY staffName ASC";
$rs = mysql_query($sql);
for($i = 0; $i < mysql_num_rows( $rs ); $i++)
{
$tmp = mysql_fetch_row( $rs );
print("<OPTION value=\"$tmp[0]:$tmp[1]\">$tmp[0]</OPTION>\n");
}
}
a couple of questions if i may.
1/ how do i have the default value set to "Please Select" instead of the first name in the db?
2/ what does $tmp[0] and $tmp[1] do in the following code? <OPTION value=\"$tmp[0]:$tmp[1]\">
3/ is it possible to remove selections from the list once they have been selected so that once the function is run again the name that has already been selected in no longer available to select again?
many thanks
Luke
I have the following function which populates list boxes with a list of names
function playerSelect()
{
$sql = "SELECT staffName, staffID, staffType FROM tbl_staff WHERE staffType = 'player' ORDER BY staffName ASC";
$rs = mysql_query($sql);
for($i = 0; $i < mysql_num_rows( $rs ); $i++)
{
$tmp = mysql_fetch_row( $rs );
print("<OPTION value=\"$tmp[0]:$tmp[1]\">$tmp[0]</OPTION>\n");
}
}
a couple of questions if i may.
1/ how do i have the default value set to "Please Select" instead of the first name in the db?
2/ what does $tmp[0] and $tmp[1] do in the following code? <OPTION value=\"$tmp[0]:$tmp[1]\">
3/ is it possible to remove selections from the list once they have been selected so that once the function is run again the name that has already been selected in no longer available to select again?
many thanks
Luke