i want to display the mysql's fetched results with php and html in unordered list and list format as like http://www.miniclip.com/games/en/. you can see in the all games categories in the footer in alphabetical order. the same requirement i do have. i guess i have written the logic its working fine. but i am unable to represent it properly. you can see in the following link above the footer. http://www.playtoongames.com/play1...
code:
<?php
$gameQuery = mysql_query ("SELECT name, LEFT(name, 1) AS first_char FROM games WHERE UPPER(name) BETWEEN 'A' AND 'Z' OR name BETWEEN '0' AND '9' ORDER BY name");
$current_char = '';
while ($gameRow = mysql_fetch_assoc($gameQuery)){
if ($_SESSION['lang'] == 'fr'){
$description = $gameRow['description_fr'];
}else{
$description = $gameRow['description'];
}
?>
<div style='float:left' title="<img src='<?php echo $gameRow['sitePath'];?>games/images/<?php echo $gameRow['img_100x75'];?>' width='230' height='112' class='thumb' alt='<?php echo $gameRow['name'];?>'/>" class='tooltip'>
<ul>
<li>
<a href='<?php echo $gameRow['sitePath'];?>play/<?php echo str_replace(' ','_',$gameRow['name']);?>'><?php echo $gameRow['name'];?></a>
开发者_运维知识库 </li>
</ul>
</div>
can anybody look into this...
Regards, sam.
On the Playtoons site, each <li>
is in its' own individual <ul>
- this means you're creating a new list for each item:
<ul>
<li>13 More Days</li>
</ul>
<ul>
<li>A Bikers Heaven</li>
</ul>
What you should be doing is using one <ul>
which contains all the items as <li>
s:
<ul>
<li>13 More Days</li>
<li>A Bikers Heaven</li>
</ul>
Well, I think the key is that there are 6 columns, which just means you'll need to break your array into 6 different parts.
Here's some psuedocode:
$pArr = $from_sql_array; // I'll let you take care of that.
$itmCount = count($pArr);
$itmsPerCol = ceil($itmCount / 6.0);
for ($ii=0; $ii < 6; $ii++)
{
$pCol = array_slice($pArr, $itmsPerCol * $ii, $itmsPerCol);
echo '<ul class="floatleft"><li>'.implode("</li>\n<li>",$pCol).'</li></ul>';
}
精彩评论