Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

newbie question : sql 3 different tables

Codes here !

Moderators: macek, egami, gesf

Postby Joan Garnet » Sat Jan 18, 2003 5:41 am

Hi ;)
first off...
why are you using three tables for logins if you check them all at the same time??
I woul do the following -->

table access -->
* Id
* login
* password
* heriarchy --> this would be admin, freinds and mailing


then the code -->

Code: Select all
$table = "access";
$sql = "SELECT login, password FROM ".$table." where login='$user' and password='$passwrd'";
$sql_result= mysql_query($sql,$db) or die ("<h3>Couldn't select information</h3></BODY></HTML>");
if ($row = mysql_fetch_array($sql_result)){
   do{
      echo "You are logged in ".$row["login"];
      switch ($row["login"]){
         case "admin":
            echo "<br> You are the admin";
            break;
         case "friend":
            echo "<br> You are a friend";
            break;
         case "mailing":
            echo "<br> You want to use the mailbox";
            break;
      }

   }while   ($row = mysql_fetch_array($sql_result));
}else{
   echo "Try again, please";
}
mysql_close($db);


bye!
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.