walapu Posted July 12, 2009 Share Posted July 12, 2009 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 More sharing options...
justsomeguy Posted July 13, 2009 Share Posted July 13, 2009 Why does it matter where the code shows up? What are you trying to accomplish? Link to comment Share on other sites More sharing options...
walapu Posted July 14, 2009 Author Share Posted July 14, 2009 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 More sharing options...
justsomeguy Posted July 14, 2009 Share Posted July 14, 2009 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 More sharing options...
walapu Posted July 14, 2009 Author Share Posted July 14, 2009 Could you give me an example? I am a noob because I am just starting phpThanks so much Link to comment Share on other sites More sharing options...
justsomeguy Posted July 14, 2009 Share Posted July 14, 2009 <?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 More sharing options...
walapu Posted July 15, 2009 Author Share Posted July 15, 2009 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 More sharing options...
Synook Posted July 15, 2009 Share Posted July 15, 2009 Why? Link to comment Share on other sites More sharing options...
walapu Posted July 15, 2009 Author Share Posted July 15, 2009 LOL because I have a bunch of code in between that does not allow me to move the if statements or switch statement (depends what I will do) to the top of my page. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 15, 2009 Share Posted July 15, 2009 That's not true, you can always rearrange code. If you want to post all of your code I'll show you how. Link to comment Share on other sites More sharing options...
Synook Posted July 16, 2009 Share Posted July 16, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.