Help populating a table

Hello everyone,

I am having trouble populating an HTML table from my MS SQL database. I have have done this with a two column table, but the code I used doesn’t seem to work with the 6 column table I am trying to populate now.

Here is the code that I am using

if( $totalFailures > 0 ) { $sql_messageFailures = "select a.FileName, a.FilePageCount, a.EmailIDFrom, a.EmailIDTo, a.Subject, b.ErrMessage FROM tbl_xTalk_Main a, tbl_xTalk_ErrorMsg b where a.ID=b.id and DATEPART(month, DateInserted)=DATEPART(month, getdate()) and DATEPART(day, DateInserted)=DATEPART(day, getdate()-1) and ProcessStatus = 0 order by a.ID"; $qry_messageFailures = sqlsrv_query($conn, $sql_messageFailures); /*if( sqlsrv_fetch( $qry_totalFailures ) === false) { die( print_r( sqlsrv_errors(), true)); }*/ ?> <?php while($row = sqlsrv_fetch_array($qry_messageFailures, SQLSRV_FETCH_NUMERIC)){ ?> <?php } ?>
FileName FilePageCount EmailIDFrom EmailIDTo Subject ErrMessage
<?php echo $row[0];?> <?php echo $row[1];?> <?php echo $row[2];?> <?php echo $row[3];?> <?php echo $row[4];?> <?php echo $row[5];?>

<?php }

I am getting the header names, but I am not getting anything from the while loop. The rest of the data on the page that comes after this works fine. Also, the header names are not underlined for some reason.

Any help would be great.
Thanks

Does the query succeed? Have you tried it in a database tool or checked that PHP returns the correct value from it?

I have tested the SQL statement in SQL Server Management Studio, and I am using that code in a stored procedure that create a text file that we are emailing. I am trying to generate the data that is in the text file as a webpage so we no longer have to email the text file.

If you look at the source of the page, can you see any errors?

If not, try placing

[php]<?php error_reporting(E_ALL); ?>[/php]

At the top of your page and trying again - just to check.

I think i found what the problem is. When I make changes to the php file, the IIS webserver is not updating the file. I have been updating the wrong file. Sorry for wasting your time, but this has helped me.

Thank you very much.

Sponsor our Newsletter | Privacy Policy | Terms of Service