There has to be a better way!!
| From: | Jason Pruim | Date: | Sat, 10 Jul 2010 15:58:17 +0000 |
| Subject: | There has to be a better way!! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-306814@lists.php.net to get a copy of this message | ||
Okay so I've been fighting with this for awhile now and haven't found a better way yet....
What I want to do, is I have a small portion of my website included into a template. It is displaying hosting plans so on the main site "index.php" I want it to display a little bit of text (Same as on the main hosting page) and just 1 random hosting plan. then if they click on that plan and go into the main hosting section, I want them to see ALL the hosting plans.
Here's the code that I'm using:
if($_SERVER['PHP_SELF'] = "/index.php") {
$sql = "SELECT * FROM hosting ORDER BY RAND() LIMIT 1";
}else{
$sql = "SELECT * FROM} Now... I know there MUST be a better way to do it but I can't see the tree's through the forest. Any other way I could do it? I'm avoiding having lots of duplicate code/text on my pages.hostingORDER BYhostingSortASC";