Reply to Re: Drop Down Box

Your name:

Reply:


Posted by strawberry on 03/31/06 15:16

Here's how I do it...


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация