i want to make a website something like popurls.com, but I will use static data stored in MySQL database. Btw I use php/mysql.
In each list i want to show around 10 links (just like on popurls). In that case, if I would have 20 lists, i would need to make 20 ‘for’ loops (for each particular list).
My question is; is there some better way to print that 20 lists instead of using 20 ‘for’ loops in php.
i want to make a website something like popurls.com, but I will use static
Share
a
forloop or aforeachloop will work fine, but it will be a lot less coding if you just create a single for loop and push content into an array of arrays or an array of strings… you can then do whatever you’d like with the actual content (assuming we’re grouping by a columncategory. I’ll use an example that uses an array of strings (and the query that I reference is explained here: http://explainextended.com/2009/03/06/advanced-row-sampling/)Now we have an array where the block of HTML for each section is stored in an array keyed by the name of the category. To output each block, just: