/    Sign up×
Community /Pin to ProfileBookmark

updating 2 tables on one page

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:&nbsp;<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>&nbsp;&nbsp;<input name=”searchterm” type=”text”>&nbsp;
<INPUT type=image src=”search.gif” value=”Search”></div>
</form>

As you can see the [B]form action=”results.php”[/B].
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[‘TW’]); ?></td>
<td width=”53″ class=”lw”><?php echo stripslashes($row[‘LW’]); ?></td>
<td width=”28″ class=”tw”><?php echo stripslashes($row[‘Wks’]); ?></td>
<td width=”340″ class=”title”><?php echo stripslashes($row[‘Title’]); ?></td>
<td width=”307″ class=”artist”><?php echo stripslashes($row[‘Artist’]); ?></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

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @charter spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...