•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 456,555 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,528 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 820 | Replies: 3
![]() |
| |
•
•
Join Date: Oct 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I have script that is almost done, I just need
help with one more thing.
I'll describe the relevant structure the best I can, then explain what I need.
TABLE carlot
FIELDS trackpt, id
TABLE cars
FIELD userid, carid
TABLE grpusers
FIELD id
Field id from table carlot = field carid from table cars
Field userid from table cars = field id from table grpusers
The value I need to display is in the field trackpt, what PHP code do I need to get this value (associated with the userid).
What I am trying to do is add that value to other values in the grpusers table.
Any suggestions? I'm sure this isn't difficult for people that work with php and mysql a lot but this is day 3 for me with no formal training and I'm basically tweaking code to make this work.
Any help is greatly appreciated!
help with one more thing.
I'll describe the relevant structure the best I can, then explain what I need.
TABLE carlot
FIELDS trackpt, id
TABLE cars
FIELD userid, carid
TABLE grpusers
FIELD id
Field id from table carlot = field carid from table cars
Field userid from table cars = field id from table grpusers
The value I need to display is in the field trackpt, what PHP code do I need to get this value (associated with the userid).
What I am trying to do is add that value to other values in the grpusers table.
Any suggestions? I'm sure this isn't difficult for people that work with php and mysql a lot but this is day 3 for me with no formal training and I'm basically tweaking code to make this work.
Any help is greatly appreciated!
Last edited by Lucky13MN : Oct 19th, 2007 at 11:49 am.
Presumably you want an inner join?
Let's assume the table
And the table
Now you want to link the two by carlot(id) and cars(userid).
Thus...
Let's assume the table
carlot is:+---------+----+ | trackpt | id | +---------+----+ | blah | 1 | | wah | 2 | | woot | 3 | +---------+----+
And the table
cars is:+--------+-------+ | userid | carid | +--------+-------+ | 1 | 3 | | 2 | 5 | | 3 | 5 | +--------+-------+
Now you want to link the two by carlot(id) and cars(userid).
Thus...
mysql> SELECT trackpt, carid FROM carlot
-> INNER JOIN cars ON carlot.id = cars.userid;
+---------+-------+
| trackpt | carid |
+---------+-------+
| blah | 3 |
| wah | 5 |
| woot | 5 |
+---------+-------+
3 rows in set (0.01 sec) Last edited by iamthwee : Oct 20th, 2007 at 9:08 am.
... the hat of 'is this a cat in a hat?'
•
•
Join Date: Oct 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Thank you very much, you make it look so easy.
I get this:
Parse error: syntax error, unexpected T_STRING in /home/l1376/public_html/folder/citizens.php on line 4
Line 4 is/was:
mysql> SELECT trackpt, carid FROM carlot
Also, once this is working what code is needed to use 'trackpt' in an equation? Such as HP + trackpt = $challengerpts
Thank you so much...
I get this:
Parse error: syntax error, unexpected T_STRING in /home/l1376/public_html/folder/citizens.php on line 4
Line 4 is/was:
mysql> SELECT trackpt, carid FROM carlot
Also, once this is working what code is needed to use 'trackpt' in an equation? Such as HP + trackpt = $challengerpts
Thank you so much...
•
•
•
•
Thank you very much, you make it look so easy.
I get this:
Parse error: syntax error, unexpected T_STRING in /home/l1376/public_html/folder/citizens.php on line 4
Line 4 is/was:
mysql> SELECT trackpt, carid FROM carlot
Also, once this is working what code is needed to use 'trackpt' in an equation? Such as HP + trackpt = $challengerpts
Thank you so much...
Try:-
php Syntax (Toggle Plain Text)
<?php $conn = mysql_connect("localhost","username","yourpassword"); //pick the database to use mysql_select_db("test",$conn); //create sql statement $sql = "SELECT trackpt, carid FROM carlot INNER JOIN cars ON carlot.id = cars.userid"; //execute statement $result = mysql_query($sql, $conn) or die(mysql_error()); //go through each row in the result set and display data while ( $newArray = mysql_fetch_array($result) ) { //give a name to the fields $id = $newArray['trackpt']; $testField = $newArray['carid']; //echo the results to screen echo " $id $testField <br>"; } ?>
Obviously replacing
username password with your actual username and password. Last edited by iamthwee : Oct 21st, 2007 at 10:16 am.
... the hat of 'is this a cat in a hat?'
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Apache (Linux Servers and Apache)
- WANTED : PHP/Mysql programmer (US time zone) (Web Development Job Offers)
- PHP Programmer needed on contract basis (Web Development Job Offers)
- Wanted: PHP/MySQL programmer in NY/NJ area (Web Development Job Offers)
- PHP/MySQL Developer Needed (Web Development Job Offers)
- PHP/MySQL Developers, New York, NY (Web Development Job Offers)
Other Threads in the MySQL Forum
- Previous Thread: how to update a field in mysql with txt file.
- Next Thread: I am New In MySQL. Problem With MySQL Database Plz Help.



Hybrid Mode