This is the section of code that i am using, if i take out the where clause of the select it returns values fine.
Essentially what i am trying to do is to search for a surname or part of surname, ie. someone can enter ker which will match kerwick, skerwin etc(eg %ker% or %k% in the code here)
BTW thanks for the help.
<?php
include( 'dbinfo.php' );
$conn = mysql_connect( $dbhost, $dbuser, $dbpass );
mysql_select_db($dbname);
$sql = 'SELECT * FROM test4 where surname like '%k%'';
$test4Result = mysql_query( $sql ) or die( mysql_error() );
while ( $test4Row = mysql_fetch_row( $test4Result ) ) {
echo '<tr><td>' . $test4Row[1] . '</td><td>' . $test4Row[2] . '</td><td>' . $test4Row[3] .
'</td><td>' . $test4Row[4] . '</td><td>' . $test4Row[5] . '</td></tr>';
}
mysql_close ($conn);
?>
This is my table schema
phpMyAdmin MySQL-Dump
version 2.2.0rc4
#
Host: xxx.xxx.xxx.xxx:/var/lib/mysql/mysql.sock:3306
Generation Time: August 29, 2001, 12:49 pm
Server version: 3.23.36
PHP Version: 4.0.4pl1
Database : test
--------------------------------------------------------
#
Table structure for table test4
#
CREATE TABLE test4 (
id int(11) NOT NULL auto_increment,
firstname varchar(40) NOT NULL default '',
surname varchar(40) NOT NULL default '',
role varchar(40) NOT NULL default '',
department varchar(40) NOT NULL default '',
extension varchar(20) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;