i have this script that is a nice and simple search that works great. except when you only have one result as it wont show it?! Also the first of any string of results it always misses the first one off! any ideas? Its driving me crazzy.
$value is the search field and $where specifies which field to search
<?
$value = $POST['search'];
$where = $POST['search_row'];
$s = @mysql_connect("mysql-1.db.vi.net", "gelpho", "naj1607c")
or die("Couldn't connect to database");
$sql = "SELECT company, contact_name, street_address, city, post_code, country, url, email, tel_number, fax_number, mob_number, tel_code, promo_sent, notes, tel_extension, portfolio_viewed, field
FROM creative_database
GROUP BY company DESC";
$d = @mysql_select_db("gelpho", $s) //change database name
or die("Couldn't selectdatabase");
$result = @("select id, company, contact_name, street_address, city, post_code, country, url, email, tel_number, fax_number, mob_number, tel_code, promo_sent, notes, tel_extension, portfolio_viewed, field FROM creative_database where $where like\"%$value%\""); //change name of column and table
if($myrow = mysql_fetch_array($result)) {
do {
while($row = mysql_fetch_array($result)) {
$id = $row['id'];
$company = $row['company'];
$contact_name = $row['contact_name'];;
$street_address = $row['street_address'];
$city = $row['city'];
$post_code = $row['post_code'];
$image_ref = $row['image_ref'];
$country = $row['country'];
$url = $row['url'];
$email = $row['email'];
$tel_number = $row['tel_number'];
$fax_number = $row['fax_number'];
$mob_number = $row['mob_number'];
$tel_code = $row['tel_code'];
$promo_sent = $row['promo_sent'];
$notes = $row['notes'];
$tel_extension = $row['tel_extension'];
$portfolio_viewed = $row['portfolio_viewed'];
$field = $row['field'];
$display_block .= "<B>$company</b><br>
$contact_name,
$street_address,
$city,
$post_code,
$country,
$url,
$field. <BR><a href=\"cb_edit2.php?id=$id\"target=\"content\">edit</a> | <a href=\"cb_details.php?id=$id\"target=\"content\">details</a><br><br>
";
}
} while ($myrow = mysql_fetch_array($result));
} else {
echo "<h2>Sorry, no records were found!</h2";
}
echo "$display_block"; ?>