Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020576
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:14:43+00:00 2026-05-20T10:14:43+00:00

I have three files; index.php, searchbar.php and search.php now when i have search.php show

  • 0

I have three files; index.php, searchbar.php and search.php

now when i have search.php show its results on its own page its fine but when i try to include the search page in index.php i get nothing.

so i include the searchbox.php in index.php so i have a search bar, i then search for something and include the search.php page by using the $_GET[‘p’] on the index.php but the search always come up blank, if i just leave search.php as its own page and dont try to include it then i get my results but id like for them to be included on the page they were searched from.

index.php

<?php

if (isset($_GET['p']) && $_GET['p'] != "") {

$p = $_GET['p'];

if (file_exists('include/'.$p.'.php')) {

@include ('include/'.$p.'.php');

} elseif (!file_exists('include/'.$p.'.php')) {

echo 'Page you are requesting doesn´t exist<br><br>';

}

} else {

@include ('news.php');

}

?>

searchbox.php

<div id="searchwrapper"><form action="?p=search" method="get">
<input type="text" class="searchbox" name="query" value=""  id="query"/>
<input type="image" src="search.png" class="searchbox_submit" value=""  ALT="Submit Form" id="submit"/>
</form>
</div>

search.php

<?php
include 'connect.php'; 
$searchTerms = $_GET['query'];
$query = mysql_query("SELECT * FROM misc WHERE itemname LIKE  '%$searchTerms%' ORDER BY itemname ");

{
echo "<table border='1' cellpadding='2' cellspacing='0' width=608 id='misc' class='tablesorter'><thead>";
echo "<tr> <th> </th> <th>Item Name</th> <th>Desc.</th></tr></thead><tbody>";
// keeps getting the next row until there are no more to get

while($row = mysql_fetch_array( $query )) {

    // Print out the contents of each row into a table
    echo "<tr><td width=50>";
    echo $row['image'];
    echo "</td><td width=150>";
    echo $row['itemname'];
    echo "</td><td width=250>";
    echo $row['desc'];
    echo "</td></tr>"; 
}

echo "</tbody></table>";;
}
if (mysql_num_rows($query) == 0)
{
  echo 'No Results';
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:14:44+00:00Added an answer on May 20, 2026 at 10:14 am

    When I reproduced your code, the “p=search” wasn’t carrying over. The better way to set it up is to have the action just go to your index.php file and have a hidden input with:

    <input type="hidden" name="p" value="search" />
    

    That will work properly for you!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem, can't understund anyway. i have three files - index.php ,
I've been trying my hand at OO PHP, and currently have three files. I
Say I have three files (template_*.txt): template_x.txt template_y.txt template_z.txt I want to copy them
I have two XML files. They are similar, but there are two nodes of
Is there any way to list all the files that have changed between two
There is a data file and some image files that I have to download
I have a couple of header files, which boil down to: tree.h: #include element.h
Is there a way to unlock Windows files without downloading a utility? I have
If I have a comma separated file like the following: foo,bar,n ,a,bc,d one,two,three ,a,bc,d
I have to include many header files, which are in different sub-directories. Is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.