hi,for all.
I am new to database programing with php. Can any one help me!
I have three different tables(no commonality,totally different tables) in my DB.
every table contains date field.
Now i have one page on php it displays recently added records of maximum 10 rows among the 3 tables based on the date field whatever the table updated/inserted.
I want to retrieve the data from each table and display the data based on the latest insertions on each table or any one table.(means if data inserted in table A continuously since last 2 days, this table data can be display only. other wise new data can be inserted on 3 tables respectively then that 3 tables data can be displayed).
when ever a new record is inserted in any of the table,the new record will display automatically.
thank u for replying me.
These are the 3 tables i used.
–
– Table structure for table Document
CREATE TABLE IF NOT EXISTS Document
(
DocumentID
varchar(20) default NULL,
DocumentDate
date default NULL,
DocumentKeywords
text,
DocumentTitle
text,
DocumentBody
text,
rec_id
int(11) unsigned NOT NULL auto_increment,
pdfname
varchar(20) default NULL,
img1
varchar(20) default NULL,
img2
varchar(20) default NULL,
img3
varchar(20) default NULL,
img4
varchar(20) default NULL,
category
tinytext,
uname
varchar(20) default NULL,
deleted
char(1) default ‘0’,
company
varchar(40) default NULL,
relative_field
varchar(50) default NULL,
rf_active
int(1) default NULL,
ftured_doc
int(1) default NULL,
visit_count
int(7) default NULL,
PRIMARY KEY (rec_id
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT;
–
– Table structure for table News
CREATE TABLE IF NOT EXISTS News
(
NID
int(10) unsigned NOT NULL auto_increment,
Ndate
date default NULL,
Ntitle
text,
Nbody
text,
Author
tinytext,
email
tinytext,
web
tinytext,
username
varchar(15) default NULL,
deleted
char(1) default ‘0’,
anchored
int(2) default NULL,
visit_count
int(7) NOT NULL default ‘0’,
relative_field
varchar(50) default NULL,
rf_active
int(1) default NULL,
ftured_news
int(1) default NULL,
company
text,
PRIMARY KEY (NID
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT;
–
– Table structure for table products
CREATE TABLE IF NOT EXISTS products
(
ID
varchar(30) NOT NULL default ‘’,
category
varchar(35) default NULL,
proName
varchar(100) default NULL,
ProDiscription
text,
proID
varchar(30) default NULL,
product_url
varchar(250) default NULL,
cost
varchar(30) default NULL,
model
varchar(30) default NULL,
pro_spec
text,
downloadurl
varchar(250) default NULL,
product_r_ID
int(8) unsigned NOT NULL auto_increment,
MyProfile
char(1) default NULL,
vname
tinytext,
vemail
tinytext,
vweb
tinytext,
vcountry
varchar(40) default NULL,
vphone
varchar(20) default NULL,
vfax
varchar(20) default NULL,
Subcategory
varchar(40) default NULL,
image
varchar(30) default NULL,
Uname
varchar(15) default NULL,
deleted
char(1) default ‘0’,
prod_url_count
int(7) default NULL,
prod_dnl_count
int(7) default NULL,
ven_web_count
int(7) default NULL,
relative_field
varchar(50) default NULL,
rf_active
int(1) default NULL,
product_urltxt
varchar(50) default NULL,
downloadurltxt
varchar(50) default NULL,
vwebtxt
varchar(50) default NULL,
ftured_pr
int(1) default NULL,
PRIMARY KEY (product_r_ID
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT;
Can you show a CREATE TABLE for the three tables?
run three separate queries using LIMIT 10
bring all 30 rows into php, and use php logic to decide which are the latest 10 overall
the reason you don’t want to do it in SQL is because the rows are all different, but to return only the latest 10 requires that you shove these different row structures through the UNION meatgrinder
in php, you can display them differently
i’m sorry, but you would have to do that in php, not with queries
ok.thank you for your suggestion.
first of all thank you for replying me.
Give me some sample queries(after selecting 30 records from three tables.From this how to get 10 records based on latest insertion)?