jesushax Posted April 16, 2009 Share Posted April 16, 2009 hi all, im after some ideas on how to order a directory of companies, at the moment they are ordered by alphabetical company name A-Z with pagnation of 10 to a page. thing is that doing that, only the companies beginging with A are going to get first page exposure when users are searching the directory can anyone think of a fairer way to do this so all compaines get some exposure? i cant use RAND as im using pagnation on clicking page 2 you would get a completely new random set of companies Thanks for any help i know this is a tough one Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/ Share on other sites More sharing options...
MasterACE14 Posted April 16, 2009 Share Posted April 16, 2009 show some code? I know with my pagination it doesn't matter what the SELECT query is, it will always get results. I don't know why yours won't work the same? Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811282 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Author Share Posted April 16, 2009 my code below, if i order by RAND everytime i click page 2 or 3 then another random set or results are gonna be displayed instead of the first queries results <?php session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/directory_header.php'); $Trade = urldecode($_GET["Trade"]); $max = 10; $p = @$_GET['p']; if(empty($p)){ $p = 1; } $limits = ($p - 1) * $max; $SQL = mysql_query("SELECT * FROM tblDirectory2 WHERE Sect1_2 LIKE '%$Trade%' ORDER BY Sect1_4 ASC LIMIT ".$limits.",$max") or die (mysql_error()); $totalres = mysql_result(mysql_query("SELECT COUNT(CompanyID) AS tot FROM tblDirectory2 WHERE Sect1_2 LIKE '%$Trade%' "),0); $totalpages = ceil($totalres / $max); ?> <div id="navigation"> <div style="float:left;"><?php echo $Trade; ?></div> <div style="float:right;"> <strong>Page:</strong> <?php for($i = 1; $i <= $totalpages; $i++){ echo "<a href='".$_SERVER['PHP_SELF']."?Trade=".urlencode($Trade)."&p=$i'>$i</a>\n"; } ?> </div> <div style="float:right; width:375px; text-align:left;"> <a class="boldlink" href="/new_directory/contents.php">Directory Contents</a> | <a class="boldlink" href="/default.php">Main Website</a> </div> </div> <?php if (mysql_num_rows($SQL) <1) { echo "<p>Sorry there are currently no members under the category $Trade, <a href=\"/new_directory/contents.php\">click here</a> to go back to the contents</p>\n"; } else { while ($row = mysql_fetch_array($SQL)) { ?> <div class="trade"> <h3><a href="record.php?title=<?php echo urlencode($TTitle)."&T=".$T."&ID=".$row["CompanyID"]; ?>"><?php echo $row["Sect1_4"]?></a></h3> <div class="trade-left"> <table width="100%" border="0"> <tr> <td style="width:29%" class="top-right"><strong> </strong></td> <td style="width:71%"><?php echo $row["Sect1_7a"]."<br />\n"; echo $row["Sect1_7b"]."<br />\n"; echo $row["Sect1_7c"]."<br />\n"; echo $row["Sect1_7d"]."\n"; ?></td> </tr> <tr> <td class="right">Tel:<strong> </strong></td> <td><strong><?php echo $row["Sect1_5"]?></strong></td> </tr> <tr> <td class="right">CHAS: </td> <td><?php echo YN($row["Sect1_10"])?></td> </tr> </table> </div> <div class="trade-right"> <table width="100%" border="0"> <tr> <td class="right">Pl Insurance Cover: </td> <td>£<?php echo $row["Sect2_1"]?></td> <td class="right">El insurance Cover: </td> <td>£<?php echo $row["Sect2_2"]?></td> </tr> <tr> <td class="right">Risk insurance Cover: </td> <td><?php echo $row["Sect2_3"]?></td> <td> </td> <td> </td> </tr> <tr> <td class="right">Planning Supervisor Indemnity: </td> <td>£<?php echo $row["Sect2_5"]?></td> <td class="right">Design Work Indemnity: </td> <td>£<?php echo $row["Sect2_4"]?></td> </tr> <tr> <td class="right">Turnover for Previous Year: </td> <td><?php echo $row["Sect3_3"]?></td> <td class="right">CIS Type: </td> <td><?php echo $row["Sect3_5"]?></td> </tr> <tr> <td colspan="4" class="right" style="padding:3px 0;"><a href="record.php?Trade=<?php echo urlencode($Trade)."&ID=".$row["CompanyID"]; ?>" style="color:#CC0033;">Full Company Details</a></td> </tr> </table> </div> </div> <?php } } ?> <div class="clear"></div> <div id="lower-navigation"> <strong>Page:</strong> <?php for($i = 1; $i <= $totalpages; $i++){ echo "<a href='".$_SERVER['PHP_SELF']."?Trade=".urlencode($Trade)."&p=$i'>$i</a>\n"; } ?> </div> <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811296 Share on other sites More sharing options...
soak Posted April 16, 2009 Share Posted April 16, 2009 You could display a random page as the first page displayed to the user but again that's not ideal. TBH, if it were me I think I would just start with the A's as you are doing at the moment. It's what the user would expect, they will expect the results to be in order (probably alpha) and that the first page will be displayed first. Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811301 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 U mean like adding user Ratings, Comments, Popularity (hits)? I guess it depends on how u want to cycle/rotate the directory. if there arent that many, u can just retreive the id's shuffle em, and then use the query. storing the shuffles id's in a cookie/session (so its different for every user). to save space, u can use the pack function. Edit: U can also just have 2-3 companies at the top, a featured or similar concept. Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811304 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Author Share Posted April 16, 2009 no i dont need to add anything else to them its just as it is its just when browsing, the A's always come first and i guess not all companies are getting full exposure so would you suggest leaving it as is, becuase thats what they expect or doing as laffin said? i could swap pagnation for alphabetical? eg. A B C D instead of Page 1 2 3 4 what you think? Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811317 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 I think a combination of the two would work. Its hard trying to find L's when ya got numbers. and its a pain to have to go throu a page of 200 entries so if ya have both, Letters on top, pagination below, it shud be a nice directory navigation system Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811325 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Author Share Posted April 16, 2009 if i used both though wouldnt it confuse a user? or do you mean like pages for the letter A which i would obviously need so it could be A B C D E... then after clicking a letter EG A Pg 1 2 3 4 of As that would be more effcient yes? Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811326 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 Yes But I was thinking of 2 rows | A B C D E F | 1 2 3 4 5 of A's something like that, which isnt hard to do Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811340 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Author Share Posted April 16, 2009 then when you click b it would be 1 2 3 4 5 of B's ? Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811350 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 Exactly Quote Link to comment https://forums.phpfreaks.com/topic/154318-solved-ordering-a-directory-ideas/#findComment-811356 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.