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 8087517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:48:06+00:00 2026-06-05T18:48:06+00:00

I have a MySQL database with 3 columns: id | articletitle | articleorganization And

  • 0

I have a MySQL database with 3 columns:

id  |  articletitle  | articleorganization

And a simple PHP form with 2 fields and a submit button: search.php

<div class="content">
    <form id="form1" name="form1" method="post" action="searchdb.php">
    <table width="100%" border="0" cellpadding="6">
    <tr>
      <td width="29%" align="right">Article Title:</td>
      <td width="71%" align="left"><input name="title" type="text" id="articletitle" size="50" /></td>
    </tr>
    <tr>
      <td align="right">Author or Organization:</td>
      <td align="left"><input name="organization" type="text" id="articleorganization" size="50" /></td>
    </tr>
      </table>


    <table width="100%" border="0" cellpadding="6">
      <tr>
        <td><input type="submit" name="submit" value="Submit" /></td>
        </tr>
    </table>
    </form>
</div>

The form connects to searchdb.php:

<?php

include('settings.php');

$title = mysql_real_escape_string($_POST['title']);
$organization = mysql_real_escape_string($_POST['organization']);

$sql = "SELECT * FROM articles WHERE 1 "
     . (isset($title) ? "AND articletitle LIKE '$title%' " : "")
     . (isset($organization) ? "AND articleorganization LIKE '$organization%'" : "");

while ($row = mysql_query($sql)){
    echo '<br/> Article Title: '.$row['articletitle'];
    echo '<br/> Article Organization: '.$row['articleorganization'];
    echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
    echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
    echo '<td><a href="entry.php?id=' . $row['id'] . '">View Full Entry</a></td>';
    echo '<br/><br/>';
    }

?>

After some revision with the help of commenters the problem has changed.

Now, upon submitting a search, the results page begins scrolling the table that is created via searchdb.php over and over again, though without any results in the table.

  • 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-05T18:48:09+00:00Added an answer on June 5, 2026 at 6:48 pm

    $_POST[term] becomes an array with key’s like 0,1. Loosing the field reference for your SQL query.

    Use these names in your input fields:

    <input name="articletitle" type="text" id="articletitle" size="50" />
    <input name="articleorganization" type="text" id="articleorganization" size="50" />
    

    You can build your query like this:

    $sql = mysql_query("select * from articles WHERE articletitle LIKE '%".mysql_real_escape_string($_POST['articletitle'])."%' OR articleorganization LIKE '%".mysql_real_escape_string($_POST['articleorganization'])."%'");
    

    Note: Never ever use $_POST (user input) vars in a query without escaping first to prevent mysql injection.

    PS My personal taste on indenting is: Always indent every block of matching HTML elements. So yes, I would indent the table one tab further.

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

Sidebar

Related Questions

If I have about 250 entries with 6 columns in a MySQL database, and
I have a MySQL database with the following columns: id company rating_score rating_place I
I have a MySQL database. All the fields, I assign and I have a
I have table in MySQL database with two integer columns for example: userid |
I have this table in a mysql database: mysql> show columns from wifi_network_config_auth_algorithm; +------------------------+-------------+------+-----+---------+-------+
I have a (mysql) database table with the following columns: NAME | String (Unique)
I have an table in my MySql database that has the following columns: -
I have two database columns in a mysql database, A and B. In a
I have a mysql database with a table of 5 columns. Now I need
I have a mysql database with table 'product' containing columns 'product_id', 'name', 'price' table

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.