İlişkisel tablolar: ilişkileri ile 3 tablo

0 Cevap php

Ben kullanıcı bir form alanına onun / telefon numarasını girdiğinde bir özel banner gösterecek bir php sayfası inşa ediyorum.

Yani burada veritabanı için benim mantık:

Table phones with fields: id, name of user and phone number. Table banners with fields: id, banner's name/title and banner (path to the image). Table relation with fields: here's where the phone number should be related to a banner and where I need your help :)

Ve burada php sayfası için benim mantık:

-form gets the phone number -I query the data base -I show the banner related to the phone number entered in the form.

Aşağıdaki tablo oluşturulması için kod şimdiye kadar .. Eğer ilerlemek için nasıl bilmiyorum görürsünüz gibidir.

Bir milyon teşekkürler

    CREATE TABLE phones(

id_phone INT NOT NULL AUTO_INCREMENT,

nombre VARCHAR(30),

number INT (9),

PRIMARY KEY (id_phone)

) TYPE = INNODB;


CREATE TABLE banners (

id_banners INT NOT NULL AUTO_INCREMENT,

id_phone INT NOT NULL,

name VARCHAR(250),

banner VARCHAR(250),

PRIMARY KEY(id_phone),

INDEX (id_phone),

FOREIGN KEY (id_phone) REFERENCES clientes(id_phone)

) TYPE = INNODB;

0 Cevap