In Which AHunter3, FileMaker geek, learns MySQL and PHP

Excellent. The question with the problem you’re having now is, are you sure you want to be searching the field assignedworkerslastname with the value “hunter, allan”, and not just “hunter”?

Looks like others have explained things nicely and you worked things out :slight_smile:

For completeness:
In order to generate dynamic content on your web server you can use many languages such as ASP, JSP, and of course PHP.

When the user’s browser asks for the page, the web server must actually run the program code that you wrote. In most cases, there are also static HTML pages being served alongside the PHP documents. For any request from a browser, the web server must decide whether to run PHP or to simply regurgitate the unprocessed text in a page.

For various reasons, often configuration settings or (in your case) file extensions, the web server does not run the program code; it simply sends the program code directly to the browser, as if it were a plain old HTML document.

The key on this one was seeing bits program code, with HTML table elements and such. Your browser was doing the best it could to interpret the HTML elements it found embedded in your source code.

OK nailed it at last. The query request portion of it reworded within the php like so: [noparse]

$result = mysql_query (‘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’);
[/noparse]

Apparently there are things you can do within a ‘mysql_query ()’ clause, which is not how the book told me originally to set one up. I jumped ahead because I wanted to have it return a specific found set of records to me.

It does now :slight_smile:

minor7flat5: I’m gonna do a lot of stoopid newbie things until this ceases to be foreign territory for me. I am now quite happy to have accomplished something that seemed pretty effortless 12 years ago in FileMaker of that vintage, because having gotten this far I can build on this.

Umm, the original FileMaker 2 database field names were never updated to reflect a change in how we actually used them. And when I did the MySQL from the command line, I went with a hard & fast rule: exact same field names except all lower case and without the spaces & special / illegal chars.

UPDATE! ~

See post 20 above. I got stuck and have been stuck trying to figure out how to pass on from a web form the desired search criteria to use in the MySQL criteria.

I am stuck no more. It finally occurred to me to rip the query string itself apart into substrings and glue them together using the “.” concatenator symbol in php. Then I could concentrate on just the substring that was to be (i.e, be replaced by) the value posted from the form.

This may be far klunkier than the ideal, most elegant way of going at it, but it works :slight_smile:

<html>
<head></head>
<body>

<?php

$connection = mysql_connect(‘localhost’, ‘guest’, ‘pass’);
mysql_select_db (‘ebcoa’);

caseworker = _POST[‘caseworker’];

$querystring_A = 'select client.firstname, client.lastname, reoptxfr.casetype, reoptxfr.datefield, reoptxfr.closedon from client, reoptxfr WHERE client.assignedworkerslastname = ';

$querystring_B = ’ and client.statusofcase = ‘1 Active Case’ and client.clientid = reoptxfr.clientid order by client.lastname, client.firstname, reoptxfr.sequencenumber’;

$querystring_C = ‘’’.$caseworker.’’’;
$querystring = $querystring_A.$querystring_C.$querystring_B;
$result = mysql_query ($querystring);
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>’;
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! Your querystring was '.$querystring;
}

mysql_free_result ($result);
// echo $caseworker;
mysql_close($connection);
?>

</body>
</html>

Speaking as a non-codehead who got Viswani’s book more or less thrown at me during an English Dep’t Intro to CMS class, I’m amazed you got as far as you have. The way he describes PHP only in terms of itself, without examples to make it do things, made it impenetrable.

Today’s projects: I started out with a form with a single search field on it (caseworker) which, if filled out with the full complete name of a social worker and submitted, would return (via PHP → MySQL query) all matching clients whose status is exactly “1 Active Case” and assigned to that case worker.

What it does now: has TWO fields, caseworker and status; does its search in such a way that part of a name will do, as will part of a status, thus “hunter” and “active” will work now; and either field can be left blank (does cute IF substitutions in the PhP) thus enabling search for all clients assigned to jones regardless of status or all closed cases, etc; or for that matter both can be left blank in which case it returns the entire database table, all records.
;
Still awfully primitive but it feels good :slight_smile:

Aren’t web applications cool?

FileMaker…feh. :wink:

Well, it’s more like putting aside your word processor and spending the day writing out from scratch the specific code that makes the text drop down one line and return to the left margin when it encounters the wrap barrier that you also had to define. Heck, it’s like writing the specific code that tells the system that the insertion point for each letter should be to the right of the letter just placed and then, having done that much, building on it by writing the code that makes the text drop down one line and return to the left margin upon encountering the line wrap barrier.

a) it feels damn cool but

b) no, I would not think one’s reaction would include “Word Processors…feh!”. Quite the contrary. I’m more cognizant of how much FileMaker does for me as a built-in starting point now that I’m having to write all that basic fundamentals stuff by hand, and believe me I do not appreciate it any less.

c) and (abandoning the metaphor at this point), the level of features I was able to whip out without cracking the manual or taking a single course nearly 15 years ago in FileMaker 2.1 (which wasn’t even considered relational!) looks months and months away from where I’m at in Php/SQL, if not years.

More progress.

Taking what I know and folding it back into the “home territory”. I have a FileMaker database which is acting as a front end to a MySQL database that I built from the command line, and it treats the MySQL data just like it was native FileMaker info (way cool);

and I’ve spend the last 3 days futzing with the PHP extensions for FileMaker 10 and now I have a handful of HTML and PHP files that snag data out of a FileMaker database and display them; some of the techniques are similar to what I learned for PHP + MySQL, but the encoded query language is totally different (it uses Filemaker not SQL/ ODBC approaches to PHP scripted behavior: create Find requests and then load them up and then perform the Find and get the results and array them into a table, instead of doing a structured query language SELECT command.

Mostly now I just have to play with it all and smooth it up and extend what I know until I start to feel like some kinda professional at this stuff :slight_smile: