airbus Posted August 29, 2009 Report Share Posted August 29, 2009 Tātad man ir jaunums/i zem linka http://*.lv/?p=news&id=1 un http://*.lv/?p=news&id=2 Gribu uztaisīt komentārus katrā jaunuma savs komentārs. Piemēram ieieju http://*.lv/?p=news&id=2 un ierakstu komentāru, viss parradas tajā jaunumā, bet es gribu lai viņš neparādas http://*.lv/?p=news&id=1 Quote Link to comment Share on other sites More sharing options...
mickys Posted August 29, 2009 Report Share Posted August 29, 2009 Kāds ir vaicājums, kas iegūst komentārus no datubāzes? Quote Link to comment Share on other sites More sharing options...
krikulis Posted August 29, 2009 Report Share Posted August 29, 2009 Tabula ar foreign key`u uz jaunuma ID. Aptuveni šitā CREATE TABLE comments ( id int(10) unsigned not null auto_increment primary_key, post_id int(10) unsigned not null, author varchar(20) not null, content text not null, index(post_id), foreign key post_id references posts(id)) engine = InnoDB; komentāru atlase SELECT id, author, content FROM comments WHERE post_id = :post Quote Link to comment Share on other sites More sharing options...
airbus Posted August 29, 2009 Author Report Share Posted August 29, 2009 (edited) Un lai pievienot kas insertā jaliek? "INSERT INTO comments (autors, laiks,ip,koments)VALUES('$_POST[autors]','$_POST[laiks]','$_POST[ip]','$_POST[koments]')" Edited August 29, 2009 by airbus Quote Link to comment Share on other sites More sharing options...
marcis Posted August 30, 2009 Report Share Posted August 30, 2009 Varbūt jaunuma id varētu pieglabāt, ne? Nešķiet, ka tad izveidotos loģiska saikne starp jaunumu un komentāru? Quote Link to comment Share on other sites More sharing options...
Kemito Posted August 30, 2009 Report Share Posted August 30, 2009 Saglabā jaunumu ID pie kura iet koments, respektīvi - ID(news) lai kad velc laukā tu ņem tā ziņu ID un komentus ar to ziņu ID! &id=3232 tad izvelc visus koementus kas ir ar ziņu ID 3232 un lieta darīta :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.