Author |
Message |
ThePiston
Worker


Joined: Dec 22, 2004
Posts: 135
|
Posted:
Tue Sep 27, 2005 3:14 pm |
|
I have this code in the beginning of my "edithome" function of "Your Account" index.php fileCode:$sql = "select u.user_id, u.name, o.user_id, o.offname, o.add1, o.add2, o.city, o.state, o.zip, o.phone, o.fax FROM nuke_users u, offices o WHERE username='$check'";
| Shouldn't that only pull those specific data points from the DB where username = "whoever the cookie is set to"? Right now, it pulls info from all members and not just the specific "username" from cookie. I tried to use WHERE userID='$check', but Igot an error.
PS - i know NOTHING about PHP, I am pretty much cutting and pasting my way around this problem and now I'm stuck.... |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Sep 27, 2005 6:32 pm |
|
Not the way it is written. This has nothing at all to do with PHP. It is an SQL issue. When you join 2 tables and you do not cross reference the two tables by a common column, you wil get what is called a Cartesian join, or all members from both tables that match any of the criteria. You are matching the username to $check but I can't see where you are matching the users table to the office table. You need to do something like
where u.username='$check' and u.SOMEFIELD=o.SOME_OTHERFIELD; |
|
|
|
 |
ThePiston

|
Posted:
Tue Sep 27, 2005 8:30 pm |
|
d***! i knew this would be harder than I thought. What's the best "SQL and PHP for dummies" book? |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Tue Sep 27, 2005 8:40 pm |
|
I have had great luck with the "Bible" series of books such as "The Javascript Bible" and "PHP and mySQL Bible", etc... never had a bad book from this series.
Regards,
montego |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
ThePiston

|
Posted:
Wed Sep 28, 2005 9:21 am |
|
I havn't learned code since Apple II... it's addictive and I have a new bidness and a new baby on the way... could be trouble. |
|
|
|
 |
montego

|
Posted:
Wed Sep 28, 2005 7:50 pm |
|
Yup, you are in trouble! I can say that from experience, however, I've been coding in one form or the other for over 20 years... and, yes, it is very addictive!
Don't worry, the Baby and wife will "help" you with the priorities...
montego |
|
|
|
 |
|