Hello,
I've a problem I hope someone can solve. PHP is pretty new for me, so please be patient if I have some stupid questions.
Thanks!!
The situation :
I'm going to build a search page, where you can fill in a company (or a part of it). If I enter a word and hit the search button, it has to show me the companies I'm searching for from my table.
You can also click the companies who're shown, which goes to a detailed page then.
This is my code from companySearch.html.
This is the form where I fill in the word it has to search.
<table border="1">
<?php do { ?>
<tr>
<td bordercolor="#999966" bgcolor="#CCCC99"><a href="../k/test.php?%20Company_ID=<?php echo $row_companySearch['Company_ID']; ?>"><font color="#003366" size="2" face="Arial, Helvetica, sans-serif"><?php echo $row_companySearch['Name']; ?></font></a></td>
</tr>
<?php } while ($row_companySearch = mysql_fetch_assoc($companySearch)); ?>
</table>
This is the code from companySearch.php
This is the page where all the companies are shown and hyperlinked.
<?php require_once('../../Connections/fisherintranet.php'); ?>
<?php
$colname_companySearch = "1";
if (isset($HTTP_POST_VARS['companyName'])) {
$colname_companySearch = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['companyName'] : addslashes($HTTP_POST_VARS['companyName']);
}
mysql_select_db($database_fisherintranet, $fisherintranet);
$query_companySearch = sprintf("SELECT Companies_WorldWide_Alfabetical_def.Name, Companies_WorldWide_Alfabetical_def.Company_ID FROM Companies_WorldWide_Alfabetical_def WHERE Name like '%%%s'", $colname_companySearch);
$companySearch = mysql_query($query_companySearch, $fisherintranet) or die(mysql_error());
$row_companySearch = mysql_fetch_assoc($companySearch);
$totalRows_companySearch = mysql_num_rows($companySearch);
mysql_free_result($companySearch);
?>
<html>
<table border="1">
<?php do { ?>
<tr>
<td bordercolor="#999966" bgcolor="#CCCC99"><a href="../k/test.php?%20Company_ID=<?php echo $row_companySearch['Company_ID']; ?>"><font color="#003366" size="2" face="Arial, Helvetica, sans-serif"><?php echo $row_companySearch['Name']; ?></font></a></td>
</tr>
<?php } while ($row_companySearch = mysql_fetch_assoc($companySearch)); ?>
</table>
</html>
Then you've the page with the details, but I didn't come that far allready, because I had an error :
Warning: mysql_fetch_assoc(): 2 is not a valid MySQL result resource in /var/www/html/intranet/INTRANET/admin/zoekcompany.php on line 25
line 25 is :
<?php } while ($row_companySearch = mysql_fetch_assoc($companySearch)); ?>
Can someone solve my problem please ???
Thanks !!!!