I do not care if I have a select button or not. I have a table, students,
and the drop down box will be based upon the filed, LastName in the table.
Any help is most appreciated.
--
Bob Rice
Navbar has the form:
<form action="redirect.php" method="GET">
<select name="pg">
<option value="0">- Start Here -
<option value="1">Home
<option value="2">Login
<option value="3">Search
<option value="4">Browse by Author
<option value="5">Browse by Title
<option value="7">Browse by Publication
<option value="8">Database Add or Change
<option value="6">Edit Membership Info
<option value="9">Register
<option value="10">Help
<option value="11">Contact Us
</select>
<input type="submit" value=" GO ">
</form>
redirect.php uses it this way:
if (isset($_GET['pg'])) {
$page=$_GET['pg'];
}
switch ($page) {
case 0 :
case 1 : $goto='somepage.php'; break; // home
case 2 : $goto='somepage.php'; break; // login
case 3 : $goto='somepage.php'; break; // search
case 4 : $goto='somepage.php'; break; // browse author
case 5 : $goto='somepage.php'; break; // browse title
case 6 : $goto='somepage.php'; break; // edit membership
case 7 : $goto='somepage.php'; break; // Browse by publication
case 8 : $goto='somepage.php'; break; // database update
case 9 : $goto='somepage.php'; break; // register
case 10 : $goto='somepage.php'; break; // Help
case 11 : $goto='somepage.php'; break; // Contact
case 12 : $goto='somepage.php'; break; // Logout
case 13 : $goto='somepage.php?ak='.$extra; break;
case 14 : $goto='somepage.php?ak='.$extra; break;
case 15 : $goto='somepage.php?tk='.$extra; break;
}
$url='http://' . $_SERVER['HTTP_HOST'] .
dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')){
$url = substr($url,0,-1); // chop off any slash
}
$url .= '/'.$goto;
header("location: $url"); // bail out to the redirect page
exit(); // and stop executing this script
}
Go ye and do likewise.
--gary
> if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')){
spot the error...
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
>
>> if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')){
>
>spot the error...
Ooops, my bad. Not an error.
Memo to self. Don't try to be smart early in the morning.
usage:
<? selectbox("firstnames","john"); ?>
would produce a selectbox with john selected.
The form:
echo "<select name='student'>\n";
echo "<option value=''>Select...\n";
while ($row = mysql_fetch_array ($students,MYSQL_ASSOC))
{
echo "<option value={$row['student_id']}>{$row['f_name']}
{$row['l_name']}\n";
}
echo "</select>\n";
The query that populates this list goes something like this. Apologies
for any errors:
//Get a list of all students (e.g. student_id,f_name,l_name) and order
them by last name.
//Put records with no last name at the bottom of the list.
$query = "SELECT * ,
IF(l_name IS NULL or l_name='', 1, 0)
AS isnull
FROM students
ORDER BY isnull ASC, l_name ASC;";
$students = mysql_query($query) or die ("Couldn't gather a list of
students!!!");
The trick is simply passing the student_id to the 'option value'
statement.
HTH