I am creating a table to display on a web page and that table is populated from data in a MySQL database. I am trying to do a couple of things that are making it difficult for me.

First I am trying to have call the PHP code that exists in a separate file in HTML via JavaScript. I think I have that working right but I am not 100% sure (because the table will not display). I think it is working right because some of the code for the table (which is in the PHP file) displays in FireBug.

Second I am trying to make it so the rows alternate colors for easy viewing too. My PHP code so far is below. The table does not display at all in any browser.

@controlfreak123, I am not sure what you mean by "include ('filename_with_php_in_it')". As far as the page not being called to be parsed, I think it is being called and contact is being made. I pointed out in my original question that I believe this is true because FireBug shows the code for the table, and that code is in separate PHP file, thus communication between the HTML file and the PHP file must be taking place. Here is how I am calling the PHP file from the HTML file you if you care to know:

@Matt S, I am not getting much in the way of output, in fact I didn't know I was getting anything at all until I looked at FireBug and saw that the PHP code (or some of it) was indeed being passed to the HTML file. The specific question is how do I get the data I want from my MySQL database and populate it into an HTML table via PHP. I can also confirm that employees does have data in it, two entries I put in for testing. I can try to put the code into its own file without the JavaScript as you suggested, but that would defeat my purpose since I want my HTML and PHP files to be separate, but I may try it just to see if the PHP code is good and to make sure the JavaScript isn't breaking it.

@Aaron, I am not sure what you are asking (sorry). The code is meant to populate create and populate a table on an HTML page.

I'd suggest you take a step back and start from the beginning. Add code incrementally, when what you have so far works. This will make it easier for others to help, too.
–
Lauri LehtinenJun 16 '10 at 3:45

hint: use include('filename_with_php_in_it'); to just pull that code into the page you are on. Also if it is in an html file chances are your php runtime isn't being called to parse the page when it is accessed
–
Matt PhillipsJun 16 '10 at 3:47

It'd be helpful to know what you're receiving the way of output. There also doesn't seem to be a specific question. Can you confirm that employees has data? Can you execute this page directly (without the JS call) by requesting it in your browser and do you get the table output?
–
Matt SJun 16 '10 at 3:48

another hint. use <?=$php_variable?> to get the values from php into your code. Its alot cleaner than creating strings with php values in them. But note you need to have short tags enabled for that to work.
–
Matt PhillipsJun 16 '10 at 3:49

I still cannot get what I want (I guess I just am not explaining it well) so I just went with what I had (which worked if I moved my PHP code into the HTML file and changed the extension) and configured the server to process HTML as PHP. I was just being anal wanting all HTML with separate PHP code in another file. Thanks for your help.
–
ubiquibaconJun 16 '10 at 6:45

Maybe I am not being clear, as far as this question is concerned I only have one HTML file and one PHP file. I am calling the code in the PHP file from the HTML file via JavaScript. I could just combine all the HTML and PHP code of both files into one big PHP file, but I don't want to do that, I want all of my web pages to be HTML. I can see now (in FireBug) that all of the data I want to display in my table is being sent retrieved and sent from the PHP file to the HTML file, but it just isn't displaying for some reason. I can get it to work, but not as two separate files like I want.
–
ubiquibaconJun 16 '10 at 4:37

You're being quite clear, but it's not something that is possible. That's what we're all trying to say. There's no reason to separate it like that, though there are other methods of separation. Template engines, including the HTML instead of vice-versa, etc.
–
FoscoJun 16 '10 at 21:49

The first time "mysql_fetch_array" function is used on a Resource Handler, after that it does not work properly. This answer may seem a bit vague, but I have seen it many times, so I always use a "while" or "do-while" loop for fetching multiple rows from DB.