You are here: Re: [PHP] generate database driven web pages « PHP « IT news, forums, messages
Re: [PHP] generate database driven web pages

Posted by "Richard Lynch" on 01/20/06 01:44

On Tue, January 17, 2006 4:27 pm, Bing Du wrote:
> Hello everyone,
>
> Here is what I want to accomplish. Query the backend database and
> generate a page listing all the staff members in table format that has
> name, title, phone and office address. Staff name should be a link.
> Clicking the link should query the database again and use the
> information retrieved (e.g. projects, educations, etc.) to generate a
> page for each staff member. A staff list page can be generated pretty
> easily.
>
> Now my question is how to keep the staffID (although it is not shown
> on
> the staff list page, but is queried along with name, title, etc.) so
> that when a staff name is clicked, his/her staffID will then be used
> to
> query the DB for personal information.
>
> Anybody have any handy working examples to give me some hints?

if (isset($_REQUEST['staff_id'])){
$staff_id = (int) $_REQUEST['staff_id']; //crude but effective
filtering / validation
$query = "select * from staff where staff_id = $staff_id";
//next line is BAD CODE, for example purposes only:
$detailed_profile = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_row($detailed_profile);
//this is not so pretty...
echo "<pre>"; var_dump($row); echo "</pre>\n";
}
else{
$query = "select staff_id, name from staff order by name";
//more bad code next line (see above):
$staff = mysql_query($query) or die(mysql_error());
while (list($staff_id, $name) = mysql_fetch_row($staff)){
echo "<a
href=\"$_SERVER[PHP_SELF]?staff_id=$staff_id\">$name</a><br />\n";
}
}

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this 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

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