Troxy Posted February 15, 2007 Report Share Posted February 15, 2007 (edited) Kāds varētu izskatīties inserts,select, pie šādas struktūras? Vienk nesaprotu ka to komentu piekabinat klat rakstam ar pienemsim id 1 un pectam izvadit rakstam id 1 komentus Tabula news id|virs|text|autor Tabula comments news_id|id|username|comment|ip|date|time varbut kas pietruks shinis tabulas? sakara ar id vai ka savadaak palasijos tos citus topikus bet taa isti nesaprotu ko dod shis lauks news_id un ka tur iedabuut to news id Edited February 15, 2007 by Troxy Link to comment Share on other sites More sharing options...
andrisp Posted February 15, 2007 Report Share Posted February 15, 2007 Iekš news_id liec iekšā attiecīgā jaunuma id, kam šim koments ir. Parasts inserts. Selekts ari parastāks par parastu. Piemēram, gribam dabūt komentārus rakstam ar id = 2; SELECT * FROM `coments` WHERE news_id = 2 PS. Tu šim postam nejēdzigi daudz enterus beigās esi saspiedis ? Link to comment Share on other sites More sharing options...
Troxy Posted February 15, 2007 Author Report Share Posted February 15, 2007 nezinu ko daru nepareizi bet tas news_id man paliek tuksh nepieskaitaas news_id vienkarshi kad ielieku kadu komentaaru tad tur paliek 0 kaukas ar insertu nesaprotu laikam neprotu uztaisiit insertu varbuut uzmet kads kadu piemeru kads buutu manam gadijumam jabuut inserts? Paldies Link to comment Share on other sites More sharing options...
andrisp Posted February 15, 2007 Report Share Posted February 15, 2007 Tev pašam tas news_id ir jāieliek. Piem., lietotājs grib pievienot komentāru ziņai ar id = 5. Kad lietotājs ir aizpildījis formu un nosūtījis to php. Tad php izpilda apt. šādu kveriju: INSERT INTO `comments` ( news_id, author, text, date ) VALUES ( 5, 'Zigis', 'bla bla bla', NOW() ) Link to comment Share on other sites More sharing options...
Troxy Posted February 16, 2007 Author Report Share Posted February 16, 2007 (edited) Man tads jautajums piemeram tagad tas krutais users raksta to komentu Virsraksts datums Shite kruts komentars. andrisp Tu saki Tev pašam tas news_id ir jāieliek. Tas ir forma cik nopratu bet ar kaukaadu hidden variantu ? vai pareizi sapratu nejau pats komenteeetaajs liks news_id :)) vai nejau es ieshu un DB likshu id numuru :))) ka tas notiek cik saprotu tad raksta id ir jadabuu ar kaukaadu hidden funkciju nja Sakuma vis gaaja raiti bet esmu iespruudis pie tiem stulbajiem komentiem ta jau arii domaju ka bus suudi :)) Edited February 16, 2007 by Troxy Link to comment Share on other sites More sharing options...
Kristabs Posted February 16, 2007 Report Share Posted February 16, 2007 A kā pēc Tu zini, kurš raksts ir atvērtais? Link to comment Share on other sites More sharing options...
Troxy Posted February 16, 2007 Author Report Share Posted February 16, 2007 Man ir shadi, shis ir jaunumi.php lapas links http://localhost/main.php?sv=jaunumi <? include("inc/config.php"); ?> <?php $result = mysql_query("SELECT * FROM news"); while ($row = mysql_fetch_assoc($result)) { ?> <body> <p align="center"><?php echo $row['virs']; ?></p> <p align="center"><b><?php echo $row['text']; ?></b></p> <p align="left"><i><?php echo $row['autor']; ?></i></p> <?echo '<a href="main.php?sv=id&id='.$row['id'].'">Komentari</a>';?> </body> <?php } ?> Kad uzpiezu komentari atveras lapa kur ir attiecigais jaunuma id shita http://localhost/main.php?sv=id&id=1 un te ir forma plika bez raksta Link to comment Share on other sites More sharing options...
Troxy Posted February 16, 2007 Author Report Share Posted February 16, 2007 nja tiku gan galaa luk shadi http://paste.php.lv/5156 varbuut var vienkarshak bet nu tas taa ka liek to parbaudi? savadak milijos pa tuksho ieraksti sakriit bazeee Link to comment Share on other sites More sharing options...
localhero Posted February 17, 2007 Report Share Posted February 17, 2007 Uzkombinee ar isset formas handlesanu, savadak tev sobrid ikreiz kad atversies tas komentesanas skriipts tiks ievaditas taas veertiibas(tuksumi). if (isset($_POST['Submit']) { ... formas vertibu ierakstisana tabula ... } Link to comment Share on other sites More sharing options...
Recommended Posts