can use some help have the php function appear in new page.

Discussion in 'PHP' started by xboxundone, Apr 7, 2006.

  1. #1
    The code below is kept in a file called search.php I call this file with an include to the index page performing a search function. The issue is the search is in the top right corner and the results end up appearing in the top right corner instead of in the main text part of the page. Any help is Appreciated.




     
    xboxundone, Apr 7, 2006 IP
  2. Slapyo

    Slapyo Well-Known Member

    Messages:
    266
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Rather than echoing the output of the search why don't you store it in a variable and then you can echo that variable anywhere on the page that you want.
     
    Slapyo, Apr 7, 2006 IP
  3. xboxundone

    xboxundone Well-Known Member

    Messages:
    1,903
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    103
    #3

    could you provide some insight on this. I am new to the programming with php.
     
    xboxundone, Apr 7, 2006 IP
  4. Slapyo

    Slapyo Well-Known Member

    Messages:
    266
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #4
    This will include the file on whatever file you included it on.
    <?php
    	require_once("myfile.php");
    ?>
    Code (markup):
     
    Slapyo, Apr 7, 2006 IP
  5. xboxundone

    xboxundone Well-Known Member

    Messages:
    1,903
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    103
    #5

    Yeas that is using an include maybe i didn't explain myself clear enough. I have a file called search.php that contains the code in the above posts. I use and include to make the search work on my main index page.

    The problem is when someone searches it replaces the search box with the results in the same section when i want it to post the results in the main section... hope this clarifies your help is appareciated.
     
    xboxundone, Apr 10, 2006 IP
  6. rszrama

    rszrama Peon

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Something along the lines of the following...

    Don't just echo your output. Store it in a variable, like $search_output or something. Then, in your index, you've presumably already included this search.php so $search_output should have something in it if a search was performed. So, throw something like this in where the output should show:

    
    <?php
      if ($search_output) echo $search_output;
    ?>
    
    PHP:
    You're just not putting it in the included file. Because you're outputting HTML in the included file, it's wanting to echo the same code right up there in the box. This should be a start..
     
    rszrama, Apr 10, 2006 IP
  7. xboxundone

    xboxundone Well-Known Member

    Messages:
    1,903
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    103
    #7
    ok guys i have tried and i just can't seem to figure it out. I need to get this done. If someone can help me i am willing to pay them $10 via paypal once it is complete. PM me. Esp rszrama as u seem to know what u are talkin about.
     
    xboxundone, May 2, 2006 IP
  8. drugoon

    drugoon Guest

    Messages:
    702
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Well, the problem is not with the search script,so you should give the search script as well as the code of the page that includes the search.php file.... if I find some time and you send me the 2 files I guess I can help you... Good luck
     
    drugoon, May 3, 2006 IP
  9. xboxundone

    xboxundone Well-Known Member

    Messages:
    1,903
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    103
    #9
    xboxundone, May 3, 2006 IP