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

  • SEARCH
  • Home
  • 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 8657761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:36:06+00:00 2026-06-12T15:36:06+00:00

I am currently trying to complete a project where the specifications are to use

  • 0

I am currently trying to complete a project where the specifications are to use a search form to search through a packaging database. The database has lots of variables ranging from Sizes, names, types and meats. I need to create a search form where users can search using a number of different searches (such as searching for a lid tray that is 50 cm long).

I have spent all day trying to create some PHP code that can search for info within a test database I created. I have had numerous amounts of errors ranging from mysql_fetch_array errors, boolean errors and now currently my latest error is that my table doesn’t seem to exist. Although i can enter data into it (html and php pages where I can enter data), I don’t know what is causing this and I have started again a few times now.

Can anyone give me some idea or tips of what I am going to have to do currently? Here is just my small tests at the moment before I move onto the actual sites SQL database.

Creation of database:

 <body>
  <?php
     $con = mysql_connect("localhost", "root", "");
      if (!$con)
     {
      die('Could not connect: ' . mysql_error());
     }
      if (mysql_query("CREATE DATABASE db_test", $con))
     {
  echo "Database created";
     }
      else
    {
  echo "Error creating database: " . mysql_error();
    }


  mysql_select_db("db_test", $con);
  $sql = "CREATE TABLE Liam
   ( 
  Code varchar (30),
  Description varchar (30),
  Category varchar (30),
  CutSize varchar (30),
   )";

 mysql_query($sql, $con);
     mysql_close($con);
 ?> 
   </body>

HTML search form page:

<body>

      <form action="form.php" method="post">
        Search: <input type="text" name="term" /><br />
      <input type="submit" name="submit" value="Submit" />
      </form>

</body>

The PHP code I am using to attempt to gather info from the database
(I have rewritten this a few times, this code also displays the "table.liam doesn’t exist")

  <body>
   <?php
 $con = mysql_connect ("localhost", "root", "");
 mysql_select_db ("db_test", $con);

  if (!$con)
    { 
    die ("Could not connect: " . mysql_error());
    } 
    $sql = mysql_query("SELECT * FROM Liam WHERE Description LIKE '%term%'") or die
        (mysql_error());

       while ($row = mysql_fetch_array($sql)){
    echo 'Primary key: ' .$row['PRIMARYKEY'];
    echo '<br /> Code: ' .$row['Code'];
    echo '<br /> Description: '.$row['Description'];
    echo '<br /> Category: '.$row['Category'];
    echo '<br /> Cut Size: '.$row['CutSize']; 
  }
 
  mysql_close($con)
   ?>
     </body>
  • 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-06-12T15:36:08+00:00Added an answer on June 12, 2026 at 3:36 pm

    try this out let me know what happens.

    Form:

    <form action="form.php" method="post"> 
    Search: <input type="text" name="term" /><br /> 
    <input type="submit" value="Submit" /> 
    </form> 
    

    Form.php:

    $term = mysql_real_escape_string($_REQUEST['term']);    
    
    $sql = "SELECT * FROM liam WHERE Description LIKE '%".$term."%'";
    $r_query = mysql_query($sql);
    
    while ($row = mysql_fetch_array($r_query)){ 
    echo 'Primary key: ' .$row['PRIMARYKEY']; 
    echo '<br /> Code: ' .$row['Code']; 
    echo '<br /> Description: '.$row['Description']; 
    echo '<br /> Category: '.$row['Category']; 
    echo '<br /> Cut Size: '.$row['CutSize'];  
    } 
    

    Edit: Cleaned it up a little more.

    Final Cut (my test file):

    <?php
    $db_hostname = 'localhost';
    $db_username = 'demo';
    $db_password = 'demo';
    $db_database = 'demo';
    
    // Database Connection String
    $con = mysql_connect($db_hostname,$db_username,$db_password);
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db($db_database, $con);
    ?>
    
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <title></title>
        </head>
        <body>
    <form action="" method="post">  
    Search: <input type="text" name="term" /><br />  
    <input type="submit" value="Submit" />  
    </form>  
    <?php
    if (!empty($_REQUEST['term'])) {
    
    $term = mysql_real_escape_string($_REQUEST['term']);     
    
    $sql = "SELECT * FROM liam WHERE Description LIKE '%".$term."%'"; 
    $r_query = mysql_query($sql); 
    
    while ($row = mysql_fetch_array($r_query)){  
    echo 'Primary key: ' .$row['PRIMARYKEY'];  
    echo '<br /> Code: ' .$row['Code'];  
    echo '<br /> Description: '.$row['Description'];  
    echo '<br /> Category: '.$row['Category'];  
    echo '<br /> Cut Size: '.$row['CutSize'];   
    }  
    
    }
    ?>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to complete a project using Qt4 and C++. I am
I'm currently trying to build a more or less complete set of unit tests
I'm currently trying this: using DocumentFormat.OpenXml.Packaging; using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(fileNameDocx as string, true))
I'm currently trying to get the most popular productID from my MSSQL Database. This
I'm trying to complete the Project Euler problem found here. For some reason my
first question here. I am trying to learn python by stepping through project euler,
I have a project which has lots of modules, each one has different running
I am currently trying to run Doctrine in a custom (own) project, which isn't
I am trying to choose the right technology to use for updating a project
I am currently trying to decide between using JOGL and JMonkeyEngine on a project

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.