sayed Posted March 28, 2005 Author Report Posted March 28, 2005 vot kaalai es sitaja iebazu?? echo $dati[0].":<b>".htmlspecialchars($dati[1])."</b> teica - ".htmlspecialchars($dati[2])."<br/>"; 15681[/snapback] visu sapratu thx all
sayed Posted March 29, 2005 Author Report Posted March 29, 2005 Kaa lai so parlabo taa lai rada foruma aktualakas temas?? <? mysql_connect("localhost", "root", "root") or die("Could not connect: " . mysql_error()); mysql_select_db("root"); @$result = mysql_query("SELECT * FROM `phpbb_topics` order by 'post_time' desc LIMIT 0 , 10 "); print("<table width=100% cellspacing=0 cellpadding=1 charset=utf-8>\n"); print(""); while ($row = mysql_fetch_array(@$result, MYSQL_NUM)) { printf ("<tr> <td><b><a href=forum/viewtopic.php?t=%s style=font-family:georgia, verdana, arial, sans-serif; font-size:11;'text-decoration: underline'>%s</a></td></b> <td> [%s] </td> </tr> " ,$row[0] ,$row[2], $row[6]); } print("</table> \n"); mysql_free_result(@$result); ?>
sayed Posted March 29, 2005 Author Report Posted March 29, 2005 Definē jēdzienu "aktuālākā tēma". 15720[/snapback] nu karoce vajag taa lai piem: ir 10 topic piemeram kada ieraxat vins paradas kaa pats pirmais saraxataa
Venom Posted March 29, 2005 Report Posted March 29, 2005 vai nu maini laiku uz jaunāko, vai liec papildus kolonnu ķip 0/NULL ja parasts, 1/whateva ja aktuāls un taisi select * ... order by actual DESC, post_time DESC
sayed Posted March 29, 2005 Author Report Posted March 29, 2005 vai nu maini laiku uz jaunāko, vai liec papildus kolonnu ķip 0/NULL ja parasts, 1/whateva ja aktuāls un taisi select * ... order by actual DESC, post_time DESC 15722[/snapback] varbuut piemeru var ?
Venom Posted March 29, 2005 Report Posted March 29, 2005 tur jau arī ir viss piemērs. liec papildkolonnu `actual` piem tinyint ar length=1. tad, kad gribi uzlikt kādam rakstam "aktualitāti", taisi update set actual=1, att. kad jānoņem - actual=NULL. Vai nu arī, ja gribi lai raksts paliek aktuāls līdz kādam brīdim, actual taisi BIGINT, kurā glabā php uzģenerēto "nākotnes" timestamp (sk. mktime(), strtotime()) vai uzreiz DATE/DATETIME. tad, kad taisi SELECT, no sākumā jānokārto dati pēc šī te lauka, e.g. ORDER BY actual DESC, post_time DESC ... | actual | post_time ... | 1 | 1231233213 ... | 1 | 1231213210 ... | 0 | 1231033213 ... | 0 | 1230033213 ja izmanto bināro slēdzi (0 vai NULL/1 kā iezīmi, ka raksts ir aktuāls)
bubu Posted March 29, 2005 Report Posted March 29, 2005 (edited) A nevar kautkā šādi (īsti nezinu phpbb sql tabulas, bet pieņemu, ka tur ir 1:n relācija komentārs-posts): SELECT * FROM posts JOIN komentars ON posts.id = komentars.posta_id GROUP BY posts.id ORDER BY komentars.laiks DESC LIMIT 10 Protams, pierediģē kveriju savām vajadzībām. edit: Ai nē tā nevar. Šitais nestrādās. Viņš tak sakārtos pēc groupa! A vajag pirms. Edited March 29, 2005 by bubu
sayed Posted March 29, 2005 Author Report Posted March 29, 2005 Jaa ne taja laucinjaa iegaju speleties :( bisku tomer ir smadzenes par isu, jo no taa visa neko nesapratu :( :( :(
bubu Posted March 29, 2005 Report Posted March 29, 2005 Manuprāt šāds kverijs derēs: SELECT posts.* FROM posts JOIN (SELECT DISTINCT(posta_id) As pid FROM komentars ORDER BY laiks DESC LIMIT 10) tmp ON posts.id = tmp.pid;
sayed Posted March 29, 2005 Author Report Posted March 29, 2005 Manuprāt šāds kverijs derēs: SELECT posts.* FROM posts JOIN (SELECT DISTINCT(posta_id) As pid FROM komentars ORDER BY laiks DESC LIMIT 10) tmp ON posts.id = tmp.pid; 15731[/snapback] neiet izmeta error!!!!
bubu Posted March 29, 2005 Report Posted March 29, 2005 Un kādu nepateiksi? Vai mums visiem kārtējo reizi jāzīlē tējas biezumos būs? grrrrr :angry:
Venom Posted March 29, 2005 Report Posted March 29, 2005 arī 4.0 laikam ne īpaši (īsti neatceros, bet pagaidām izvairos no subselectiem)
Recommended Posts