how can I make query from 2 tables?

A

Anonymous

Guest
hi
I have 2 tables, and I want to make query from them but the query does not work on the second table .
Code:
$query="INSERT INTO  members (Membership_id  ,
   Membership_type  ,
   Member_first_name ,
   Member_second_name  ,
   Member_last_name )  VALUES  ('$member_id',
                              '$member_type',
                              '$member_first_name',
                              '$member_second_name',
                              '$member_last_name')";
$query2="INSERT INTO  access_user(User_name,Password ,Access_level )
	VALUES ('$member_user_name', '$member_user_password1')";
and which is the best for web sites: 1) use 2 tables one for personal Info. and the other for user_name and password, or 2) collect al of them in 1 table?
and how can I make a value "autoincrement" from Database appears automatically in my form "in the text field".
 
Maybe this is what your looking for?
Code:
<?php
$query = "INSERT INTO acces_user ".
			" ( User_name, Password, Access_level ) ".
			" VALUES ".
			" ( '$member_user_name', ".
			" '$member_user_password1', ".
			" '$access_level' ) ";

$member_id = mysql_insert_id();

$query2 = "INSERT INTO members ".
			"( Member_id, ".
			" Membership_type, ".
			" Member_first_name, ".
			" Member_second_name, ".
			" Member_last_name ) ".
			" VALUES ".
			" ( '$member_id', ".
			" '$member_type', ".
			" '$member_first_name', ".
			" '$member_second_name', ".
			" '$member_last_name' )";
?>

Cheers,
Enq.
 
After your first insert statement of course there should be if statement then if the insert statement is done you will proceed to the next insert statement, if not go to else statement.

Insert into .......

if { everything ok }

Insert into.........

else { do something }

end
 
Back
Top