Hi i want to list my links in 2 columns. currently it lists all links in one column alphabetically like this I want to make it like this HERE IS MY CODE <img src="<? echo URL; ?>templates/imgs/Hd.gif"><br><p> <table border="0" width="100%"> <tr> <td align="center" style="padding-left: 10px; font-size:17px;"><a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=0-9">0-9</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=A">A</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=B">B</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=C">C</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=D">D</a> | <a style="color:#339966;" href="//main.php?id=<?php echo $category; ?>&&l=E">E</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=F">F</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=G">G</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=H">H</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=I">I</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=J">J</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=K">K</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=L">L</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=M">M</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=N">N</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=O">O</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=P">P</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=Q">Q</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=R">R</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=S">S</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=T">T</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=U">U</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=V">V</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=W">W</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=X">X</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=Y">Y</a> | <a style="color:#339966;" href="/main.php?id=<?php echo $category; ?>&&l=Z">Z</a></td> <?php if ($_GET['l'] == "0-9") { $message = "<br>You are viewing titles beginning with a number."; } else if (isset($_GET['l']) && $_GET['l'] !== "0-9" && $_GET['l'] !== "") { $message = "<br>You are viewing titles beginning with the letter " . $_GET['l'] . "."; } else { $message = "<br>You are viewing all titles"; } ?> </tr> <?php landbanner(); echo $message; if ($_GET['l']) { if ($_GET['l'] == "0-9") { $mresult = mysql_query("SELECT * FROM videos where `title` REGEXP '^[0-9]' AND category='".$category."' ORDER BY `title` asc"); } else { $mresult = mysql_query("SELECT * FROM videos where `title` like '".mysql_real_escape_string($_GET['l'])."%' AND category='".$category."' ORDER BY `title` asc"); } } else { $mresult = mysql_query("SELECT * FROM videos WHERE category='".$category."' ORDER BY `title` ASC"); } while($row = mysql_fetch_array($mresult)) { $id = $row['id']; $title = $row['title']; ?> <tr> <td style="padding-left: 10px;"> • <? if($seo == 0) { ?> <a href="<? echo URL; ?>videos.php?id=<? echo $id ?>"><? echo $title ?></a><br><img src="<? echo URL; ?>templates/imgs/spacer.gif"> <? } ?> <? if($seo == 1) { ?> <a href="<? echo URL; ?>videos/<? echo $id ?>"><? echo $title ?></a><br><img src="<? echo URL; ?>templates/imgs/spacer.gif"> <? } } ?></td> </tr> <tr> <td><? echo landbanner(); ?></td></tr> </table> Code (markup): Someone please help. Thanks
I think you can approach this in two ways. One is to store your results in two arrays (one for each column), and then call a for loop to display it. Another, is to use the '%' function to do a comparison on the array index. So on your code, you will need to add a variable to store the index. e.g. set '$k=0;' outside the WHILE loop and put "$k++;" inside the WHILE loop. Once you have an index, you can do the '%' comparison. e.g. if (($k % 2)==0)
Hi thanks for the reply but i dont know anything about php could you please tell me what all things i have to add in the code step by step please... Thanks again
You can try something similiar to the code below. Displaying is more on the HTML side. You might want to read on how to display mulitple columns with tables. Bold text = ADDED $k=0; while($row = mysql_fetch_array($mresult)) { $id[$k] = $row['id']; $title[$k] = $row['title']; $k++; } //end while loop for($i=0;$i<=$k;$i++){ ?> <tr> <td style="padding-left: 10px;"> • <? if($seo == 0) { ?> <a href="<? echo URL; ?>videos.php?id=<? echo $id ?>"><? echo $title ?></a><br><img src="<? echo URL; ?>templates/imgs/spacer.gif"> <? } ?> <? if($seo == 1) { ?> <a href="<? echo URL; ?>videos/<? echo $id ?>"><? echo $title ?></a><br><img src="<? echo URL; ?>templates/imgs/spacer.gif"> <? } } ?></td> <? if (($i%2)==0){?> <td><a href="<? echo URL; ?>videos.php?id=<? echo $id ?>"><? echo $title ?></a><br><img src="<? echo URL; ?>templates/imgs/spacer.gif"></td> <?}else{?> <td></td> <?}?> </tr> <tr> <td colspan="2"><? echo landbanner(); ?></td></tr> <?} //end forloop ?> </table>