Thanks Ragnarok but i'm a newbie to PHP/MySQL
Here's my code for the results page:
This is the full code I have on the results.php page:
<?php
// create short variable names
if(ini_get('register_globals') != "1")
{
$post = (floatval(substr(phpversion(), 0, 3)) >= 4.1) ? $_POST : $HTTP_POST_VARS;
foreach($post as $key => $value)
{
$$key = $value;
}
}
$searchtype = addslashes(trim($searchtype));
$searchterm = addslashes(trim($searchterm));
if(!$searchtype || !$searchterm)
{
exit('You have not entered search details. Please go back and try again.');
}
$link_id = @mysql_connect("localhost", "root", "password");
if($link_id === false)
{
exit("Error, Could not connect to the system database. Sorry...");
}
mysql_select_db('charts50', $link_id);
$result = mysql_query("SELECT * FROM `uk` WHERE `{$searchtype}` LIKE '%{$searchterm}%'");
?>
</head>
<body background="0000ff">
<div align="center">
<table class="table" width="760" height="266" border="0" cellpadding="5" cellspacing="0">
<tr>
<td height="29" class="years-ago">50 YEARS AGO</td>
</tr>
<tr align="left">
<td height="29" colspan="2" class="years-ago">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr class="headings">
<tr>
<th class="headings" width="28">TW</th>
<th class="headings" width="53">LW</th>
<th class="headings" width="28">Wks</th>
<th class="headings" width="340">Title</th>
<th class="headings" width="307">Artist</th>
</tr>
<?php $i = 1; while($row = mysql_fetch_array($result)){
$item = array();
$item['tw'] = stripslashes($row['tw']);
$item['lw'] = stripslashes($row['lw']);
// now we can override that
$item['lw'] = ($item['lw']=='new')
? "<img src=\"images/new2.gif\" alt=\"new!\" />"
: $item['lw'];
$item['wks'] = stripslashes($row['wks']);
$item['title'] = strtoupper(stripslashes($row['title']));
$item['artist'] = stripslashes($row['artist']);
?>
<tr>
<td width="28" class="tw"><?php echo $item['tw']; ?></td>
<td width="53" class="lw"><?php echo $item['lw']; ?></td>
<td width="28" class="wks"><?php echo $item['wks']; ?></td>
<td width="340" class="title"><?php echo $item['title']; ?></td>
<td width="307" class="artist"><?php echo $item['artist']; ?></td>
</tr>
<?php $i++; } ?>
</table> </td>
</tr>
</table>
What I want is a AND situation. I wish to enter data for 2 fields into 2 search boxes on the page (field 1 is wk no and field 2 is year) I want the result to find the record (rows) which match both wk no AND year
I also need to know how to set up the search terms on the forms.
Many Thanks