troubleshooting Question

Insert Blank Record into MySQL after query

Avatar of michael789
michael789 asked on
PHP
4 Comments1 Solution575 ViewsLast Modified:
Hi:

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;
 
if(!isset($_GET['tradeshow']))
  $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);
ASKER CERTIFIED SOLUTION
djberriman

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros