jquery - Dynamic drop down menus using CSS and PHP/MySQL -
i want create dynamic drop down menu using php , mysql. menus ok not way wanted.
i want menu below (sorted vertically , limiting number of items vertically , horizontally)
i tried achieving per below code:
<?php foreach ($result $riw) { ?> <div class="four columns"> <li><a href="<?php echo $riw['fmprmlink']; ?>"><?php echo $riw['remedy_name']; ?></a> </li> </div> <?php } ?>
by above approach getting result not rquired
and without using <div class="four columns">
result below again not required
i want items arranged , shown alphabetically vertically.
a simple possibility of sorting first, second, etc. column.
can improved.
shows 1 of many possibilities.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>4 columns</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php function setline($conte,$i,$count,$ilines){ $act1 = $i; $act2 = 1*$ilines + $i; $act3 = 2*$ilines + $i; $act4 = 3*$ilines + $i; echo "<li>".$conte[$act1]."</li>\n"; // 0 if ($act2 < $count){ echo "<li>".$conte[$act2]."</li>\n";} if ($act3 < $count){ echo "<li>".$conte[$act3]."</li>\n";} if ($act4 < $count){ echo "<li>".$conte[$act4]."</li>\n";} } //-----------main--------------- echo "<ul id=\"quad\">"; $anarry = array("css","xhtml","semantics","accessibility","usability","web standards","php","typography","grids","css3","html5"); sort($anarry); $count = count($anarry); $idiv = (int)($count/4); if ($count - ($idiv * 4)>0) {$ilines = $idiv+1;} else {$ilines = $idiv;} ($i = 0; $i < $ilines; $i++) { setline($anarry,$i,$count,$ilines); } echo "<ul/>"; ?> </body> </html>
next normal standard of 4 column list
.
changed for loop
.
sorted left right ( not op wants)
for ($i = 0; $i < $count; $i++) { echo "<li>".$anarry[$i]."</li>\n"; }
now know matrix ...
1| 0-2 3-5 6-8 9-11 col| 1 2 3 4 ---|--------------- r 1| 0 3 6 9 o 2| 1 4 7 10 w 3| 2 5 8 11
... can write simpler function.
function sortfor4c($cont,$i,$ilines,&$icol,&$irow){ echo "<li>".$cont[$icol * $ilines - $ilines + $irow -1]."</li>\n"; $icol++; if ($icol > 4) { $icol = 1; $irow++; } } .... $icol = 1; $irow = 1; ($i = 0; $i < $count; $i++) { sortfor4c($anarry,$i,$ilines,$icol,$irow); }
style.css
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6{ margin:0; padding:0; } ol,ul{ list-style:none; } body{ font-family:georgia, "times new roman", times, serif; color:#333; } ul{ width:760px; margin-bottom:20px; overflow:hidden; border-top:1px solid #ccc; } li{ line-height:1.5em; border-bottom:1px solid #ccc; float:left; display:inline; } #quad li { width:25%; }
Comments
Post a Comment