the blatant newbie is here again
im currently trying to write a search script which searches products within my db, i have achieved this and it works, my only problem is i want to be able to offer a notification if no results were returned from teh search
i have copied my code into here of my search.php which returns the results, i know i need to do an if and else statements but i keep geting it very wrong, culd someone please help me to understand what goes where to make this occur?
i hope so, thanks again
phase
[php_man]
<?php
include "includes/head.htm";
include "includes/theme.php";
$title = "<h1>Search Results</h1>";
$search = @$_GET['search'] ;
opentable();
?>
<div align="center">
<table width="100%" cellpadding="1" cellspacing="1"><tr>
<td align="center" background="<? echo $headerimg ?>" width="12">No</td>
<td align="center" background="<? echo $headerimg ?>" width="50">Image</td>
<td align="center" background="<? echo $headerimg ?>" width="300">Product</td>
<td align="center" background="<? echo $headerimg ?>" width="100">Price</td>
<td align="center" background="<? echo $headerimg ?>" width="70">View</td>
<td align="center" background="<? echo $headerimg ?>" width="70">Add</td></tr>
<?
$sql = new MySQLHandler();
$sql->init();
{
$data = $sql->Select("SELECT * FROM products WHERE name LIKE '%$search%'");
for ($i=0; $i < count($data); $i++) {
$row_color = ($row_count % 2) ? $color1 : $color2;
?>
<div align="center">
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<td align="center" bgcolor="<? echo $row_color ?>" width="12"><? echo $i ?></td>
<td align="center" bgcolor="<? echo $row_color ?>"><img border="0" src="<? echo ' '.$data[$i]['img'].''; ?>" width="50" height="40"></td>
<td align="center" bgcolor="<? echo $row_color ?>" width="300"><? echo ' '.$data[$i]['name'].''; ?></td>
<td align="center" bgcolor="<? echo $row_color ?>" width="100"><? echo ' '.$data[$i]['price'].''; ?></td>
<td align="center" bgcolor="<? echo $row_color ?>" width="70"><? echo '<A CLASS=menu href=\new/viewproduct.php?prod_id='.$data[$i]['id'].'>'; ?><img border="0" alt="Find out more info on <? echo ' '.$data[$i]['name'].''; ?>" src="<? echo $more ?>" ></td>
<td align="center" bgcolor="<? echo $row_color ?>" width="70"><? echo '<A CLASS=menu href=\new/addtobasket.php?prod_id='.$data[$i]['id'].'>'; ?><img border="0" alt="Add <? echo ' '.$data[$i]['name'].''; ?> to basket" src="<? echo $basket ?>" ></td>
</tr>
</table>
</div><?
$row_count++;
}}
closetable();
include "includes/foot.htm";
[/php_man]