cip6791 Posted September 3, 2008 Share Posted September 3, 2008 Hi all I hope you can help me with this one. I managed to get categories in alphabetical order from a database. But I don't know how to integrate everything in the page. I wanted to get the categories by the first letter. Now all the categories are all thrown on a page. I am a beginner and promise to start learning php the proper way. But help me with this one first This is my code foreach(range('a', 'z') as $letter) { echo '<div class="alpha"><a href="?cat=' . strtolower($letter) . '">' . $letter . '</a></div>'; } $cat = isset($_GET['cat']) ? $_GET['cat'] : null; if(in_array($cat, range('a', 'z'))) { $result = mysql_query("SELECT * FROM xzclf_cats WHERE catname LIKE '$cat%' ORDER BY catname ASC"); while($row = mysql_fetch_assoc($result)) { echo "<br />"; echo '<a style="text-decoration:none;" href="<?php echo $catlink; ?>"><img src="' . $row['thumb'] . '" /></a>'; echo $row['catname']; echo "<br />"; } } And this is where I want to integrate it // Categories $sql = "SELECT catid, catname AS catname FROM $t_cats WHERE enabled = '1' $sortcatsql"; $rescats = mysql_query($sql) or die(mysql_error()); $catcount = @mysql_num_rows($rescats); $percol_short = floor($catcount/$dir_cols); $percol_long = $percol_short+1; $longcols = $catcount%$dir_cols; $i = 0; $j = 0; $col = 0; $thiscolcats = 0; while($rowcat=mysql_fetch_array($rescats)) { if ($j >= $thiscolcats) { $col++; $thiscolcats = ($col > $longcols) ? $percol_short : $percol_long; $j = 0; echo "<td valign=\"top\" width=\"$cell_width%\">"; } $i++; $j++; $catname_inurl = RemoveBadURLChars($rowcat['catname']); if($sef_urls) $catlink = "{$vbasedir}$xcityid/posts/$rowcat[catid]_{$catname_inurl}/0/"; else $catlink = "?view=ads&catid=$rowcat[catid]&cityid=$xcityid&lang=$xlang"; $adcount = 0+$catadcounts[$rowcat['catid']]; ?> <table border="0" cellspacing="0" cellpadding="0" width="100%" class="dir_cat"> <tr> <?php $category_icon = file_exists("images/category/{$rowcat[catid]}.png") ? "images/category/{$rowcat[catid]}.png" : "images/category.png"; ?> <th width="25" valign="top"></th> <th id="main_image"><a style="text-decoration:none;" href="<?php echo $catlink; ?>"><img class="main_image" src="<?php echo $category_icon; ?>" border="0" align="absmiddle"> <?php echo $rowcat['catname']; ?></a> </th> </tr> <?php There is more code ... something to do with sub categories. If needed I will post it all. Thanks Link to comment https://forums.phpfreaks.com/topic/122619-php-link-help/ Share on other sites More sharing options...
.josh Posted September 3, 2008 Share Posted September 3, 2008 Can you post example output of what it looks like now vs. what you want it to look like? Link to comment https://forums.phpfreaks.com/topic/122619-php-link-help/#findComment-633124 Share on other sites More sharing options...
cip6791 Posted September 3, 2008 Author Share Posted September 3, 2008 Yeah ... oops ... forgot that. When the page opens, it opens with the alphabet on top, and the few categories I have underneath. If you press the letter "a" for ex, you ll get all the categories with the letter "a". I would like to have it start with all the "a" categories. http://www.iheartbrooklyn.com Link to comment https://forums.phpfreaks.com/topic/122619-php-link-help/#findComment-633133 Share on other sites More sharing options...
cip6791 Posted September 3, 2008 Author Share Posted September 3, 2008 anybody ? Link to comment https://forums.phpfreaks.com/topic/122619-php-link-help/#findComment-633169 Share on other sites More sharing options...
cip6791 Posted September 4, 2008 Author Share Posted September 4, 2008 Just moving the post up in the list. Link to comment https://forums.phpfreaks.com/topic/122619-php-link-help/#findComment-633743 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.