We help IT Professionals succeed at work.
Get Started

Insert Blank Record into MySQL after query

michael789 asked
Last Modified: 2013-12-12

I have a search page that gives an array of results to the next page where I filter the specific table for results. However each time I am on this page it will insert a blank record into the "products" table.

Any ideas why this could be? There is no insert record in this page?

$currentPage = $_SERVER["PHP_SELF"];
$maxRows_products = 12;
$pageNum_products = 0;
if (isset($_GET['pageNum_products'])) {
  $pageNum_products = $_GET['pageNum_products'];
$startRow_products = $pageNum_products * $maxRows_products;
  $keyword_sql = '1=1'; # dummy condition when there are no keyword parameter
elseif(is_array($_GET['tradeshow'])) { # array keyword parameter
  $keyword_sql = array();
  foreach($_GET['tradeshow'] as $kw) {
    $kw = mysql_real_escape_string($kw);
    $keyword_sql[] = "tradeshows.showname LIKE '%$kw%'";
  $keyword_sql = '('.implode(' or ',$keyword_sql).')';
} else { # single keyword parameter
  $kw = mysql_real_escape_string($_GET['keyword']);
  $keyword_sql = "tradeshows.showname LIKE '%$kw%'";
mysql_select_db($database_inburn, $inburn);
$query_products = "SELECT * FROM products_trade
LEFT JOIN products ON products.id = products_trade.ID_product_trade
LEFT JOIN tradeshows ON tradeshows.id_show = products_trade.tradeshowID 
WHERE $keyword_sql
GROUP BY products_trade.ID_product_trade";
$products = mysql_query($query_products, $inburn) or die(mysql_error());
$row_products = mysql_fetch_assoc($products);
$totalRows_products = mysql_num_rows($products);

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE