I have an index.php. page which is a search on my MySQL database to update HTML tables in my results.php page.
I have a form on the index page as the search which is like this:
<form action="results.php." method="post">
Search: <select name="searchtype">
<option value="Date">Date</option>
<option value="Wk No.">Wk #</option>
<option value="Artist">Artist</option>
<option value="Title">Title</option>
</select> <input name="searchterm" type="text">
<INPUT type=image src="search.gif" value="Search"></div>
</form>
As you can see the form action="results.php".
This is OK for updating one table on the results page but I wish to update 2 seperate tables on the same page.
Does anyone know how to code so that the correct table is updated on the page.
The PHP code in the results page is:
<?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="images/ground.jpg">
<div align="center">
<table class="table" width="760" height="266" border="0" cellpadding="5" cellspacing="0">
<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)){ ?>
<tr>
<td width="28" class="tw"><?php echo stripslashes($row); ?></td>
<td width="53" class="lw"><?php echo stripslashes($row); ?></td>
<td width="28" class="tw"><?php echo stripslashes($row); ?></td>
<td width="340" class="title"><?php echo stripslashes($row); ?></td>
<td width="307" class="artist"><?php echo stripslashes($row); ?></td>
</tr>
<?php $i++; } ?>
</table> </td>
</tr>
</table>
This is the code that for updating one of the tables, dows anyone know how to code to update the other or can I only update one table on each webpage.
I want to update the second one from a second search.
All help will be much appreciated