javascript table in php block

I am in need of help displaying a table using javascript in a php block. Below is the code I have:

?>

<script type="text/javascript">
$(document).ready(function() {
    $('#pain').dataTable( {
            "bPaginate": false,
        "bLengthChange": false,
        "bFilter": false,
        "bSort": false,
        "bInfo": false,
        "bAutoWidth": true
        }
        );
} );
</script>
<?php
$client = $_COOKIE['memberID'];

echo '<br><table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="pain">
                <thead>
                  <tr>
                    <th>PainWhere</th>
                    <th><strong>PainDescribe</strong></th>
                    <th><strong>Severity</strong></th>
                    <th><strong>Current</strong></th>
                  </tr>
                </thead>
                <tbody><tr>
    <td>
    $PainWhere</td>
    <td>
    $PainDescribe</td>
    <td>
    $Severity</td>
    <td>
    $Current</td>
    </tr>';
   

echo '</table>';


but it is not displaying properly. Pics attached. I want to use the installed jquery for my datatables, but the way I have it working on my custom page is not working in a php block.

First pic is of the page that is not working with code above. 2nd page is page that is working, but I added the javascript call to a custom page. Any help would be greatly appreciated. Thanks in advance.

javascript table.png · 521.7K · 173 views
javascript table1.png · 602.3K · 181 views
caredesign.net
Quote · 27 Sep 2013

ok, scratch this one - i got it figured out. code below, but if not correct, I welcome any suggestions:

?>
<link type="text/css" rel="stylesheet" href="http://mydomain.com/mtsdemo/templates/base/demo_page.css"></link>
<link type="text/css" rel="stylesheet" href="http://mydomain.com/mtsdemo/templates/base/demo_table.css"></link>
<link type="text/css" rel="stylesheet" href="http://mydomain.com/mtsdemo/templates/base/jquery.dataTables_themeroller.css"></link>
<link type="text/css" rel="stylesheet" href="http://mydomain.com/mtsdemo/plugins/jquery/themes/jquery-ui-1.8.4.custom.css"></link>

<script src="http://mydomain.com/mtsdemo/inc/js/jquery.dataTables.js" language="JavaScript" type="text/javascript"></script>

<script type="text/javascript">

$(document).ready(function() {
    $('#pain').dataTable( {
            "bJQueryUI": true,
            "bPaginate": false,
        "bLengthChange": false,
        "bFilter": false,
        "bSort": false,
        "bInfo": false,
        "bAutoWidth": true
        }
        );
} );
</script>
<?php
$client = $_COOKIE['memberID'];

echo "<br><table width='100%' cellpadding='0' cellspacing='0' border='0' class='display' id='pain'>
                <thead>
                  <tr>
                    <th>PainWhere</th>
                    <th><strong>PainDescribe</strong></th>
                    <th><strong>Severity</strong></th>
                    <th><strong>Current</strong></th>
                  </tr>
                </thead>
                <tbody>";

$pain = mysql_query("SELECT * FROM pain WHERE client_id = '$client'") or die (mysql_error());
// We are going to use the "$row" method for this query. This is just my preference.
while ($row_pain = mysql_fetch_array($pain)) {
    $PainWhere = $row_pain["PainWhere"];
    $PainDescribe = $row_pain["PainDescribe"];
    $Severity = $row_pain["Severity"];
    $Current = $row_pain["PainCurrent"];

    // Echo your table row and table data that you want to be looped over and over here.
    echo "<tr>
    <td>
    $PainWhere</td>
    <td>
    $PainDescribe</td>
    <td>
    $Severity</td>
    <td>
    $Current</td>
    </tr>";    
}
// Close out your table.
echo "</table>";

caredesign.net
Quote · 27 Sep 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.