PHP Knowledge Base Update -- August 5th, 1999

From: Date: Fri, 06 Aug 1999 19:36:11 +0000
Subject: PHP Knowledge Base Update -- August 5th, 1999
Groups: php.kb 
Request: Send a blank email to php-kb+get-20@lists.php.net to get a copy of this message
Wai-Sun "squidster" Chia announced today the creation of a mailing list for phpslash development. PHPSlash is a PHP implementation of the system used at http://slashdot.org. Send a message to phpslash-request@lists.netuse.de with the word "subscribe" in the body to join the list and help out. Cheers, Nathan ------------------------------------------------------------ How can I store user information in a database? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/544 ------------------------------------------------------------ M.Brands Why not create one table with information about each user. Use the username as a unique index (primary key). In a second table, start adding records identified by the username (could be used as a foreign key). Then, you can simply retrieve all records from the second table with a single SQL statement. Something like: create table users(username char(10),email text); create table logins(username char(10), time datetime); (You probably want an index on the username column. It should really speed things up.) In the first table, you would insert one record for each user. Example data could look like: users: username | email -----------+------------------------------------ jarjar | shrike@il.fontys.nl kibo | pesh@tosh.net benny | bfore@sugarshack.com logins: username | time -----------+------------------------------------ jarjar | 11:17 - 9 september 1998 benny | 0:43 - 29 july 1999 benny | 0:44 - 29 july 1999 benny | 12:50 - 1 august 1999 Get a list of logins for benny: select time from logins where username = 'benny' This maintains a list of login times and dates. It's just an example though. You probably want to do something more useful ;) ------------------------------------------------------------ How can I make two cases in a switch do the same thing? Does PHP switch work the same as C switch? http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/545 ------------------------------------------------------------ halim@admin1.mlcc.com.my, Rasmus Lerdorf, Aaron Leon Kaplan PHP switch works basically the same as C switch. switch ($table) { case '1' : statement; break; case '2' : statement; break; } To have two statements execute the same code simply do: switch ($table) { case '1': case '2': statement; break; }

« previous php.kb (#20) next »