Hi guys,
I am investigating converting two of our older software programs into web-based applications with a MySQL back-end. I would prefer to do it on PHP than Delphi as it will gives us a neat little Intranet. I've been playing around with PHP a bit and have found it really good.
My main concern is with MySQL query results.
e.g.
Lets say I execute this query:
Select * from customers where cust_code LIKE A%
My code looks something like this:
<?php
// Connect, selecting database
$link = mysql_connect('localhost', 'root', '')
or die('Could not connect: ' . mysql_error());
mysql_select_db('quicken') or die('Could not open quicken database');
// Perform SQL query
$query = 'SELECT * FROM customers WHERE cust_code LIKE ' . '"A%"';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
if (mysql_num_rows($result) == 0)
{
echo 'Results found: 0';
exit();
}else{
// Print results in HTML
echo 'Results found: ' .mysql_num_rows($result);
echo "<p></p>";
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Close connection
mysql_close($link);
?>
Now, with these results, these are displayed in a table. This is where my problem is. Lets say I have 3 rows in the table. They might look something like this:
cust_code Address
AB11 Address for AB11
AB12 Address for AB12
AB13 Address for AB13
I would like to be able to click on any of these rows above and execute another query, e.g. each of these rows would contain a link to another query called find_invoice.php. If I click on say, line 3 it will then pass 'AB13' to find_invoice.php. find_invoice.php will then execute the query :
SELECT * FROM INVOICES WHERE CUST_CODE = 'AB13'.
How can I get the customer code for the row I click on? Is this possible?
Any suggestions welcome
Thanks in advance.