goma smile Posted September 11, 2008 Report Share Posted September 11, 2008 Man ir jautajums ka var piemeram ir jaunumi + komentari a piemeram kad komente rada cilveka rakstu,laiku,niku.... a es gribu lai rada atelu kas ir cita sadala bet taja pasa datubaze piemeram ir datubaze majas ..... ir tabele komentari a komentaros nav lietotaja bilde bet cita sadala kur ir vina personigie dati ka no vinas iznemt un paradit pie atieciga lietotaja ? Link to comment Share on other sites More sharing options...
andrisp Posted September 11, 2008 Report Share Posted September 11, 2008 Šausmas. Speciāli centies uzrakstīt tā, lai būtu pēc iespējams grūtāk saprast ? Link to comment Share on other sites More sharing options...
goma smile Posted September 11, 2008 Author Report Share Posted September 11, 2008 (edited) Šausmas. Speciāli centies uzrakstīt tā, lai būtu pēc iespējams grūtāk saprast ? es nevaru izstastit kr4 man gribetos panakt to ka nokomente jaunumus pie komentara paradas tā avatars ir datubaze majas ......... iekš majas ir tabula komentari vins norada kura lietotaja id, niku,tekstu,laiku (kad ,kas komentejis) un ir cita taja tabula kur ir lietotaji ..... kura ir noradits lietotāja avatars vai var kautka no komentaru table pec id, vai nika tikt uz lietotaj table un uzinat lietotaja avataru Edited September 11, 2008 by goma smile Link to comment Share on other sites More sharing options...
mounkuls Posted September 11, 2008 Report Share Posted September 11, 2008 atkarīgs vai ir sakarība lietotāja id vai nika tajās tabulās. Ja ir, var protams. Ar JOIN varētu paņemt, ja lietotāju tabulā ir tie avataru linki vai kādi id uz avataru. P.S. Izklāstīt savu problēmu Tu tiešām varetu iemācīties labāk:) Tu pārsit Nīči:D Link to comment Share on other sites More sharing options...
goma smile Posted September 11, 2008 Author Report Share Posted September 11, 2008 (edited) :D man ir doma galva :D nevar ta izmo4it ara :D Varetu mazliet precizak pa JOIN ? Edited September 11, 2008 by goma smile Link to comment Share on other sites More sharing options...
mounkuls Posted September 11, 2008 Report Share Posted September 11, 2008 (edited) iedod abas tabulas. Domājams, ka komentāru tabulā id nozīmē pavisam ko citu kā lietotāju, tā ir? andrisp bija labu linku ielicis kur patrenēties SQL, tur ir arī par JOIN tīri labi sākumam. Re kur http://sqlzoo.net/ Edited September 11, 2008 by mounkuls Link to comment Share on other sites More sharing options...
goma smile Posted September 11, 2008 Author Report Share Posted September 11, 2008 (edited) iedod abas tabulas. Domājams, ka komentāru tabulā id nozīmē pavisam ko citu kā lietotāju, tā ir? andrisp bija labu linku ielicis kur patrenēties SQL, tur ir arī par JOIN tīri labi sākumam. Re kur http://sqlzoo.net/ P.s. KOMENTARA TABULA : ir komentara id id un lietotaja id !!!. CREATE TABLE `fusion_profilucomments` ( `comment_id` smallint(5) unsigned NOT NULL auto_increment, `comment_item_id` smallint(5) unsigned NOT NULL default '0', `comment_type` char(2) collate utf8_latvian_ci NOT NULL default '', `comment_name` varchar(50) collate utf8_latvian_ci NOT NULL default '', `comment_message` text collate utf8_latvian_ci NOT NULL, `comment_smileys` tinyint(1) unsigned NOT NULL default '1', `comment_datestamp` int(10) unsigned NOT NULL default '0', `comment_ip` varchar(20) collate utf8_latvian_ci NOT NULL default '0.0.0.0', PRIMARY KEY (`comment_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_latvian_ci AUTO_INCREMENT=12; INSERT INTO `fusion_profilucomments` VALUES (3, 1, 'U', '1', 'tttt', 1, 1217452027, 'IP'); USERU TABLE : CREATE TABLE `fusion_users` ( `user_id` smallint(5) unsigned NOT NULL auto_increment, `user_name` varchar(30) collate utf8_latvian_ci NOT NULL default '', `user_password` varchar(32) collate utf8_latvian_ci NOT NULL default '', `user_email` varchar(100) collate utf8_latvian_ci NOT NULL default '', `user_hide_email` tinyint(1) unsigned NOT NULL default '1', `user_gender` tinyint(1) unsigned NOT NULL, `user_location` varchar(50) collate utf8_latvian_ci NOT NULL default '', `user_birthdate` date NOT NULL default '0000-00-00', `user_aim` varchar(16) collate utf8_latvian_ci NOT NULL default '', `user_icq` varchar(15) collate utf8_latvian_ci NOT NULL default '', `user_msn` varchar(100) collate utf8_latvian_ci NOT NULL default '', `user_yahoo` varchar(100) collate utf8_latvian_ci NOT NULL default '', `user_web` varchar(200) collate utf8_latvian_ci NOT NULL default '', `user_theme` varchar(100) collate utf8_latvian_ci NOT NULL default 'Default', `user_offset` tinyint(1) unsigned NOT NULL, `user_avatar` varchar(100) collate utf8_latvian_ci NOT NULL default '', `user_sig` text collate utf8_latvian_ci NOT NULL, `user_posts` smallint(5) unsigned NOT NULL default '0', `user_joined` int(10) unsigned NOT NULL default '0', `user_lastvisit` int(10) unsigned NOT NULL default '0', `user_ip` varchar(20) collate utf8_latvian_ci NOT NULL default '0.0.0.0', `user_rights` text collate utf8_latvian_ci NOT NULL, `user_groups` text collate utf8_latvian_ci NOT NULL, `user_level` tinyint(3) unsigned NOT NULL default '101', `user_status` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_latvian_ci AUTO_INCREMENT=6; INSERT INTO `fusion_users` VALUES (2, 'smile', '39b254ab889e5c1b3e721323eb4b7a8b', 'karlis116@inbox.lv', 0, 0, 'rajons', '0000-00-00', '', '', '', '', 'web-mod.oo.lv', '', 0, '2008042610022112810[2].jpg', '', 0, 1217435982, 1221163258, 'IP', 'A.AC.AD.B.C.CP.DB.DC.D.FQ.F.IM.I.IP.M.N.NC.P.PH.PI.PO.S.SL.S1.S2.S3.S4.S5.S6 .S7.SU.UG.U.W.WC', '', 103, 0); KOMENTARA TABULA : comment_name ir lietotaja id Edited September 11, 2008 by goma smile Link to comment Share on other sites More sharing options...
mounkuls Posted September 11, 2008 Report Share Posted September 11, 2008 (edited) Atrodi sakarību kā komentāru sapīt kopā ar lietotāju, nu vai abās tabulās piemēram figurē niks? Ja ir tā, tad SELECT avatar FROM lietotaji JOIN komentari ON(komentari.niks=lietotaji.niks) WHERE komentari.id='$komentars' LIMIT1; gribēju jau pielabot, bet nu varbūt pacenties pats pēc šī izlobīt. Ja comment_name=user_name , domāju galā tiksi:) P.S. Es tāds riebīgs tāpēc ka to pirmo postu lasot sanāca škrobe:p To INSERT INTO gan nākamreiz nevajag bez vajadzības postēt te, galu galā tas ir hash ar privātiem datiem, mani neintersē konkrēti ieraksti tabulā, bet tās struktūra:) comment_name ir lietotaja id lietotāja id vai niks? Edited September 11, 2008 by mounkuls Link to comment Share on other sites More sharing options...
goma smile Posted September 11, 2008 Author Report Share Posted September 11, 2008 (edited) $abfrage1 = dbquery( "SELECT user_avatar FROM fusion_users JOIN fusion_profilucomments ON(comment_name=user_id) WHERE komentari.id='$komentars' LIMIT 1 " ); nesaprotu kas tur jaieliekt komentari.id='$komentars' comment_name ir LIETOTAJA ID bet comment_id ir komentara id Edited September 11, 2008 by goma smile Link to comment Share on other sites More sharing options...
mounkuls Posted September 11, 2008 Report Share Posted September 11, 2008 (edited) Tad jau ok. komentari.id='$komentars' Es rakstiju, kad vēl nezināju neko par tabulām. fusion_profilucomments.id='$komentara_id' $komentara_id ir tas konkrētā komentāra id. Kautkā taču to identiīcē php kad ņem no bāzes... Edited September 11, 2008 by mounkuls Link to comment Share on other sites More sharing options...
goma smile Posted September 11, 2008 Author Report Share Posted September 11, 2008 Vienalga nekadigi nesanak Link to comment Share on other sites More sharing options...
mounkuls Posted September 11, 2008 Report Share Posted September 11, 2008 Tāpēc kā SQL nezin kurai tabulai kas ir no tā comment_name=user_id fusion_profilucomments.comment_name=fusion_users.user_id Link to comment Share on other sites More sharing options...
goma smile Posted September 11, 2008 Author Report Share Posted September 11, 2008 (edited) Tāpēc kā SQL nezin kurai tabulai kas ir no tā comment_name=user_idfusion_profilucomments.comment_name=fusion_users.user_id es mazliet sajaucu es censos uztaisit ka komente profilu un lai parada komentetaja avataru kad es ielieku fusion_profilucomments.comment_name=fusion_users.user_id tad vins visos komentaros parada ta lietotaja avataru kuru komenteju Edited September 11, 2008 by goma smile Link to comment Share on other sites More sharing options...
mounkuls Posted September 11, 2008 Report Share Posted September 11, 2008 Grrrrr! Pieturzīmes taču arī ir! Man jau tā savas šeptes un vēl tik super teikumi jalasa:( Normāli ja selektē user_avatar no fusion_users tabulas, tad rezultāts būs tas, kas ir tajā user_avatar. Eju gulēt, rīt 6:30 jāceļas Link to comment Share on other sites More sharing options...
goma smile Posted September 12, 2008 Author Report Share Posted September 12, 2008 (edited) Es stulbenis :D $xresult = dbquery( "SELECT tcm.*,user_name,user_avatar FROM ".DB_PREFIX."profilucomments tcm LEFT JOIN ".DB_PREFIX."users tcu ON tcm.comment_name=tcu.user_id WHERE comment_item_id='$cid' AND comment_type='$ctype' ORDER BY comment_datestamp ASC " ); Edited September 12, 2008 by goma smile Link to comment Share on other sites More sharing options...
Recommended Posts