The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> PHP, MySQL, Displaying tow tables having one similar colume
akeredolujosh
post Mar 3 2014, 08:40 AM
Post #1





Group: Members
Posts: 1
Joined: 3-March 14
Member No.: 20,460



Please I have two different tables namely Land owners and property respectively with the following columes:
table 1: Land owners > Columes are: id, fileno, type of ownership, firstname, last, sex.
table 2: Property > Columes are: id, fileno, doe, plotno, location.
Please how can i use php to display the data on both tables of which the data on fileno colume on both table are the same

This post has been edited by akeredolujosh: Mar 3 2014, 08:43 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Mar 3 2014, 01:37 PM
Post #2


This is My Life
*******

Group: Members
Posts: 1,128
Joined: 24-August 06
From: t-dot
Member No.: 16



There's 2 parts to this.

The query itself which is a MYSQL task
assuming id is the primary key. A mysql join something like the following should get you started.

SELECT * L.id, L.fileno, L.type of ownership, L.firstname, L.last, L.sex, P.doe, P.plotno, P.location from Land owners as L join Property as P on L.id = P.id

and if your columns and table names really have spaces in them you're going to need to use some form of quotes or back ticks.



Then you have to figure out how to use PHP mysql, and nowadays people are generally recommended to use mysqli or mysqlPDO, but you can still use the mysql interface.
You connect to the database.
You make a variable that is the query.
You pass the query variable to mysql.
You iterate through the result set and print it out, or whatever it is you want to do with it.

hope that gets you started.

This post has been edited by jimlongo: Mar 3 2014, 01:40 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 20th April 2024 - 01:03 AM