On Sat, 2010-07-10 at 11:58 -0400, Jason Pruim wrote:
> 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 `hosting` ORDER BY `hostingSort` ASC";
>
> }
>
> 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.
>
>
>
To avoid duplicating code, use an include file. If you already have some
form of include (for a DB for example) then you can include your other
includes in that.
Also, not sure if it was a type in your email, but I think you want to
use == in your if statement there, instead of = ;)
Thanks,
Ash
http://www.ashleysheridan.co.uk