Lobsang has been trying to help me via PMs, examining my unsuccessful PHP code and making useful suggestions.
Despite his efforts, and mine (such as they are), I am still not successful at writing a routine whereby a find query would be POSTed from one .html file and the input received by a .php file and the input value used along with other criteria as the query string.
Here is my current code for the form.html document in which a user would type in a caseworker’s name and submit it, either to the (currently nonworking) php file that attempts to query the MySQL database or to a debugging php file that just echoes back the parsed string:
[noparse]<html>
<head></head>
<body>
<form action=“nextsqlphp.php” method=“post”>
Enter your find request: <input type=“text” name=“msg” size=“30”>
<input type=“submit” value=“Send”>
</form>
<form action=“wtfsqlphp.php” method=“post”>
Test syntax of your find request: <input type=“text” name=“msg” size=“30”>
<input type=“submit” value=“Send”>
</form>
</body>
</html>
[/noparse]
When sent from the second form (“Test syntax of your find request”), the file wtfsqlphp.php obligingly echoes back this string: select client.firstname, client.lastname, reoptxfr.casetype, reoptxfr.datefield, reoptxfr.closedon from client, reoptxfr WHERE client.assignedworkerslastname = ‘hunter, allan’ and client.statusofcase = ‘1 Active Case’ and client.clientid = reoptxfr.clientid order by client.lastname, client.firstname, reoptxfr.sequencenumber
But when sent from the first form (“Enter your find request”), the file nextsqlphp.php loads as a blank page. It’s supposed to be performing as a query the above bolded string and then return the results. This same page’s code works fine if I use a hardwired query instead of trying to snag the input from form.html, so that must be the place where I’m doing something wrong. Here’s the code for the file nextsqlphpl.php:
[noparse]
<html>
<head></head>
<body>
<?php
$connection = mysql_connect(‘localhost’, ‘guest’, ‘pass’);
input = _POST [‘msg’];
mysql_select_db (‘ebcoa’);
$result = mysql_query (‘select client.firstname, client.lastname, reoptxfr.casetype, reoptxfr.datefield, reoptxfr.closedon from client, reoptxfr WHERE client.assignedworkerslastname = ‘’.$input.’’ and client.statusofcase = ‘1 Active Case’ and client.clientid = reoptxfr.clientid order by client.lastname, client.firstname, reoptxfr.sequencenumber’);
if (mysql_num_rows ($result) >0)
{
echo ‘<table width=100% cellpadding=10 cellspacing=0 border=1>’;
echo
‘<tr><td><b>FIRSTNAME</b></td><td><b>LASTNAME</b></td><td><b>CASETYPE</b></td><td><b>OPENED</b></td><td><b>CLOSED</b></td></tr>’;wq
while($row = mysql_fetch_row($result))
{
echo ‘<tr>’;
echo ‘<td>’ . $row[0] . ‘</td>’;
echo ‘<td>’ . $row[1] . ‘</td>’;
echo ‘<td>’ . $row[2] . ‘</td>’;
echo ‘<td>’ . $row[3] . ‘</td>’;
echo ‘<td>’ . $row[4] . ‘</td>’;
echo ‘</tr>’;
}
echo ‘</table>’;
}
else
{
echo ‘No rows found!’;
}
mysql_free_result ($result);
mysql_close($connection);
?>
</body>
</html>
[/noparse]