PHP Knowledge Base Update -- August 5th, 1999
[email protected] (Nathan Wallace) Fri, 6 Aug 1999 14:36:11 -0500
| Newsgroups | php.kb |
|---|---|
| Message-ID | <[email protected]> |
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
[email protected]
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 | [email protected]
kibo | [email protected]
benny | [email protected]
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
------------------------------------------------------------
[email protected], 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;
}