Php code create and connect a table

The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we solve previous year question papers for you.
See Our team
Wondering how we keep quality?
Got unsolved questions?

Ask Questions
PHP-->View question


Php code create and connect a table.

i have to display two tables 1.customer 2.product details

so how can i write query to select all fields in the two tables and display it in table

my database is like this

CREATE TABLE customer
(
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(32) NOT NULL,
    phone VARCHAR(10) NOT NULL,
    email VARCHAR(32) NOT NULL,
    address varchar(100) NOT NULL,
    state varchar(20) NOT NULL,
    city VARCHAR(30) NOT NULL,
    pincode int NOT NULL
    );


CREATE TABLE product_details
(
    p_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    full_name_of_phone VARCHAR(32) NOT NULL,
    ph_model VARCHAR(32) NOT NULL,
    ph_color VARCHAR(32) NOT NULL,
    ph_quantity VARCHAR(32) NOT NULL,
    cost VARCHAR(32) NOT NULL,
    rv_no int NOT NULL,
    payment_type  VARCHAR(32) NOT NULL
    
    );

my last question was answerd by Rajiv now im getting output correctly so how can i put that out put in a table



By:PerumalS

Taged users:


Likes:
Be first to like this question

Dislikes:
Be first to dislike this question

Talk about thisDelete|Like|Dislike|


Answers

If the databases are not having any relation means you can simply use UNION to join both the data bases. Suppose you want to retrieve name from the table customer and same time you want to retrieve  full_name_of_phone From product_details.


Then you can executive the query like this

SELECT name
FROM  customer
UNION SELECT bfull_name_of_phone
FROM produc_detail

Like this or you can retrieve the data in to two separate queries like this.

$sql1="1query"

$sql2="2query"

And you can display the result using any of the php variables


arunwebber

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer
Talk about this|Once you have earned teacher badge you can edit this questionDelete|Like|Dislike|
------------------------------------

Can you help us to add better answer here? Please see this



Not the answer you're looking for? Browse other questions from this Question paper or ask your own question.

Join eduladder!