[PHP-DB] Query qizzle quackarooney! :|
Hey there fellow querieres I summon your power! (eh..) well.. enough with the nonsense :) I have a littlebit of problem: I am displaying 15 different newsarticles on a page. The articles are displayed in three different tables. First there`s one article (the main-top-story) that is shown in the top of the page. Then there is an ad. And then. Below this ad, there are two columns, each displaying 7 articles each. To avoid running multiple queries I do a $i = 0, and a $i++ before I end the while statement... ($i increments for each time the while loops) The articles can be divided into two distinct groups. smallnews, and news, and this is stored in the article table in a field named Kategory! Here is the thingy: I can`t have any smallnews desplaying their ugly faces in the first four while loops... That is: smallnes cannot be shown before 4 "real" newsarticles has been displayed. How do I go about this without having to write a huge bunch of if/elses (I`m not sure if that would even work). some notes below to give you an idea of how I am thinking while (.) { if (($i 4) ($kategory == "smallnews")) { $i == $i continue ; } // Go around another time. if (($i == 0) ($kategory == "newsarticle")) { echo "trtd etc etc..." ; } // End writing if it is the first article Just some scribling here if ($kategory == "smallnews") continue ; } } What do YOU think? -Trond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Query qizzle quackarooney! :|
On 13 Feb 2001, at 11:41, Trond Erling Hundal wrote: Hey there fellow querieres I summon your power! (eh..) well.. enough with the nonsense :) I have a littlebit of problem: I am displaying 15 different newsarticles on a page. The articles are displayed in three different tables. First there`s one article (the main-top-story) that is shown in the top of the page. Then there is an ad. And then. Below this ad, there are two columns, each displaying 7 articles each. The articles can be divided into two distinct groups. smallnews, and news, and this is stored in the article table in a field named Kategory! That is: smallnes cannot be shown before 4 "real" newsarticles has been displayed. What do YOU think? Divide your query in two part. Supposing you're ordering them by freshness, something like: "select * from news where Kategory=bignew order by date desc limit 4" and "select * from news where Kategory=smallnew order by date desc limit 3" likewise, do 2 cicles, the first showing major news, the second showing small ones. This way you don't need a single "if" nor complicated flow control structure... I've always liked KISS predicate :-) HTH, bye /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Fabrizio Ermini Alternate E-mail: C.so Umberto, 7 [EMAIL PROTECTED] loc. Meleto Valdarno Mail on GSM: (keep it short!) 52020 Cavriglia (AR) [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]