Jump to content

PHP Search


Borderline

Recommended Posts

Good eveningI have a photography site, and have previously had a search tool on it - visitors can input a horse/rider's name and search for pictures linked to them. The site is located at: http://equinefocus.co.uk/index.php I used King as a test word, and while it pulls up three results (walking the course, Buckingham, looking...), I know it should be finding many more results (Mary King, Chris King, Emily King, King Eider, King Joules, and so on...) I have no doubt it's a simple procedure to correct it, but I cannot fathom it, and was hoping someone could point me in the right direction.Search box:

<form action="/categories/search.php" method="post">			<table border="0" cellspacing="0" cellpadding="0">						<tr>							<td><input type="text" name="term" /></td>							<td>  </td>							<td><input type="submit" name="submit" value="Submit" /></td>						</tr>					</table>

Results page:

<div class="content bg3"> <?php include($_SERVER['DOCUMENT_ROOT'].'/includes/*****.php');?>	<?php			// mysql			$term = $_POST['term'];			$per_page = 15;		if (!isset($_GET['page']) || !is_numeric($_GET['page'])) {		$page = 1;		}		else {		$page = (int)$_GET['page'];		}		$from = (($page * $per_page) - $per_page);				$data = mysql_query("select * FROM photos WHERE horse like '%$term%' OR rider like '%$term%' OR notes like '%$term%'");?><?php		$total_results = 		mysql_fetch_array(mysql_query("SELECT COUNT(*) AS num FROM photos 									   WHERE horse like '%$term%' OR rider like '%$term%' OR notes like '%$term%'"));		$total_pages = 		ceil($total_results['num'] / $per_page);		if ($page > 1) {		$prev = ($page - 1);		echo "<a href=\"?page=$prev\"><<  Previous</a> ";}		for($i = 1; $i <= $total_pages; $i++) {		if ($page == $i) {		echo "$i ";}				else {		echo "<a href=\"?page=$i\">$i</a> ";}}		if ($page < $total_pages) {		$next = ($page + 1);		echo "<a href=\"?page=$next\">Next >></a>";}?><?php		while($info = mysql_fetch_array($data)) {  			// images		$thumb='/photos/'.$info['date'].'/thumbs/'.$info['thumb'];		$full='/photos/'.$info['date'].'/'.$info['thumb'];		$url='/photos/'.$info['date'].'/'.$info['url'];		$ref = $info['date'].'-'.$info['ref'];?>		<p><div class='img'>							<table border="0" cellpadding="2" cellspacing="0" width="50%" align="center">		<tr>		<td width="100%">					<a href="<?php echo $full;?>" rel="lightbox[term]" title="<?php echo $ref; ?>:			<?php echo $info['horse']; ?> <?php echo $info['rider']; ?>">			<img src="<?php echo $thumb; ?>"</a>		</td></tr>		<tr><td width="100%">		<div id='refno'><?php echo $ref; ?></div></td></tr>		<tr><td width="100%"><div id='info'><?php echo $info['horse']; ?></div></td></tr></table></div></p><?php}  ?>

Data format:The data looks like this in the db:galleryissue.jpgAny assistance would be greatly appreciated.

Link to comment
Share on other sites

are those results only coming from a specific column, like the notes column?
Thanks for the response and sorry for the delay.Those results are as follows:Walking the course - notesLooking down to the paddock - notesTanya Buckingham - riderI was just having a play and noticed that if I input "King" I got the full set of results (king in lowercase only gets results where king is part of a word). On that basis, I'm guessing that I'll have to ensure all names are input in lowercase, and use CSS to display them as names should appear?
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...