Jump to content

Php Switch


walapu

Recommended Posts

Ok this is the php at the bottom of my page.switch ($search) { case 1: if (!isset($results)) { $results = ""; } $search_results = get_search_results($query, $start, $category, $type, $results, $domain); require("$template_dir/$template/search_results.html"); break; default: if ($show_categories) { if ($_REQUEST['catid'] && is_numeric($catid)) { $cat_info = get_category_info($catid); } else { $cat_info = get_categories_view(); } require("$template_dir/$template/categories.html"); } break; }My problem is that I would like case 1 to stay placed at the bottom of my page, but at the same time I would like the default at the top of my page not at the bottom. Is there any other way of doing this?

Link to comment
Share on other sites

Well it is a very long story. I want the categories at the top left of my page. It can not be placed at the top left of the page without relative or absolute in the css. The problem is that when I do use relative or absolute and I have an occasional announcement (which is a bar directly placed at the top of my page) the categories will not move down with the announcement. That is why I need the actual html at the top of my page not the bottom with the results (aka case 1)Any ideas?

Link to comment
Share on other sites

Put your PHP before all of your HTML and have the switch statement assign the include files to variables, then down in the HTML just include those files where you want them. It's best to have all of your PHP before your HTML.

Link to comment
Share on other sites

<?php$file1 = '';$file2 = '';if (your condition here){  $file1 = 'include1.php';}if (some other condition){  $file2 = 'include2.php';}?><html>......<div><?phpif ($file1 != '')  include $file1;?></div>...<div><?phpif ($file2 != '')  include $file2;?></div></body></html>

Link to comment
Share on other sites

EDIT: I know you think I may sound crazy but it has to be like this. Is it possible this way?

<div><?phpif ($file1 != '')  include $file1;?></div>...<div><?phpif ($file2 != '')  include $file2;?></div><?php$file1 = '';$file2 = '';if (your condition here){  $file1 = 'include1.php';}if (some other condition){  $file2 = 'include2.php';}?><html>

Thanks for all of your help

Link to comment
Share on other sites

If you have echo statements in weird places have a look at Output Buffering (PHP site seems to be down so no link).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...