I have been trying for ages to get just a simple search to work
This is the table I want to search
+---------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+------------------+------+-----+---------+----------------+
| entry_id | int(10) unsigned | | PRI | NULL | auto_increment |
| department_id | int(10) unsigned | | | 0 | |
| cat_id | int(10) unsigned | | | 0 | |
| name | varchar(40) | | | | |
| thumbnail | varchar(30) | | | | |
| description | text | YES | | NULL | |
| image | varchar(30) | | | | |
| advert | char(1) | YES | | NULL | |
+---------------+------------------+------+-----+---------+----------------+
I'd like to search the name and description fields.
This is what I have so far, or one of the many I have tried.
Code: Select all
<?php
$db = mysql_connect("localhost");
mysql_select_db("entry", $db);
$query = "select entry.name, entry.thumbnail from entry where name like '%".$name."%'";
$result = mysql_query($query);
while ($record = mysql_fetch_assoc($result){
while (list($fieldname, $fieldvalue) = each($record)){
echo $fieldname.": <b>".$fieldvalue."</B><br>";
}
echo "<br>";
}
?>thanks