RE: [PHP] RE: [PHP-DB] MySQL (2 tables)
| From: | Jason Cox | Date: | Tue, 17 Oct 2000 20:41:23 +0000 |
| Subject: | RE: [PHP] RE: [PHP-DB] MySQL (2 tables) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20705@lists.php.net to get a copy of this message | ||
Sorry, in order to be correct, you would need to do the subselect then * so
you could pull $query_data[0] as the subselected value.
Jason
> -----Original Message-----
> From: Jason Cox [mailto:jasonc@webpipe.net]
> Sent: Tuesday, October 17, 2000 2:39 PM
> To: php-general@lists.php.net
> Subject: [PHP] RE: [PHP-DB] MySQL (2 tables)
>
>
> You could do a subselect as well. Something like:
>
> SELECT *,(SELECT 1 FROM auth WHERE username='$username' AND
> password='$password') FROM users;
>
> $query_data = EXECUTE QUERY;
> if ($query_data[0] == "1")
> {
> display data
> }
> else
> {
> display error
> }
>
> That's obviously not code, just another way to do it in a single SQL
> statement.
>
> Jason
>
> > -----Original Message-----
> > From: John Guynn [mailto:John.Guynn@telescan.com]
> > Sent: Tuesday, October 17, 2000 2:28 PM
> > To: bryan
> > Cc: Php-Db (E-mail)
> > Subject: RE: [PHP-DB] MySQL (2 tables)
> >
> >
> > Why not (not actual code...just a quick brainstorm)
> >
> > SELECT * FROM auth
> >
> > If ((username == $username) && (password == $password)){
> > SELECT * FROM users
> > display info
> > } else {
> > tell them they entered something wrong and are unauthorized
> > }
> >
> > or if you wanted to do it in one SELECT
> >
> > SELECT users.*,auth.username,auth.password FROM users, auth
> >
> > John Guynn
> >
> > -----Original Message-----
> > From: bryan [mailto:bryan@concept-factory.com]
> > Sent: Tuesday, October 17, 2000 3:14 PM
> > To: php-db@lists.php.net
> > Subject: [PHP-DB] MySQL (2 tables)
> >
> >
> > I have 2 tables in my database (users, and auth). My query is SELECT *
> > FROM users; but I only want to show that query if the user is a member
> > (from the auth table)
> >
> > I have a $PHP_SELF function in my form so when the user logs
> in, if it is
> > valid, they are shown the data from the users table. Could
> > someone tell me
> > how to validate the username && password from the AUTH table
> and show the
> > data from the USERS table..
> >
> > Thanks...
> > bryan
> >
> > eg.
> >
> > <?php
> > If (($username == username) && ($password == password)) {
> >
> > print "<TABLE $table_params>";
> >
> > print "<TR>";
> >
> > if ((!$result) || ($numrows < 1)) {
> > echo "<H1>ERROR - no rows
> > returned</H1><P>"
> >
> > }
> >
> > print "</TR>";
> >
> > while ($row = mysql_fetch_array ($result)) {
> >
> > print "<TR>";
> >
> > echo "<TD><U><B>ID
> > Number:</TD></U></B>".
> > "<TD>".$row[0]."</TD>";
> >
> > echo "<TD><U><B>Name:</U></B></TD>
> >
> > "."<TD>".$row[1]." ".$row[2]."</TD>";
> >
> > print "<TD><a
> > href=\"mailto:" . $row[3] . "\">".
> > "E-mail
> > me</a>";
> >
> > print "</TR>";
> > }
> > print"</TABLE>";
> >
> > mysql_free_result ($result);
> >
> > ?>
> >
> > Today's Date (according to the web server) is:
> >
> > <?php
> >
> > echo( date("F dS Y.") );
> >
> > } else {
> > echo "<a href=login.html>LOG-IN</a>";
> > }
> >
> > ?>
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-db-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-db-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
>
>
> _______________________________________________________
> Site Design, Hosting, and E-Commerce at www.webpipe.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
_______________________________________________________
Site Design, Hosting, and E-Commerce at www.webpipe.net