I am running the following script to draw a table from results in my database:
$user =& JFactory::getUser();
$currentUser = $user->id;
$query = "SELECT * FROM jos_modelform_submissions WHERE user_id='".$currentUser."' AND model_type='model1'";
$db->setQuery($query);
$tableResults = $db->query();
$formLayout .= $tableResults;
echo "<div style='overflow:auto;'><table border='1' cellspacing='0' cellpadding='14'>
<tr bgcolor='#0D7CCD'>";
echo "<TD style='text-align:center;color:#FFFFFF;' width='25px'><b>ID</b></TD>
<TD style='text-align:center;color:#FFFFFF;' width='40px'><b>User ID</b></TD>
<TD style='text-align:center;color:#FFFFFF;' width='200px'><b>Input</b></TD>
<TD style='text-align:center;color:#FFFFFF;' width='600px'><b>Output</b></TD>
<TD style='text-align:center;color:#FFFFFF;' width='110px'><b>Model Type</b></TD>
<TD style='text-align:center;color:#FFFFFF;' width='100px'><b>Date/Time</b></TD>
</tr>";
echo "<tr><td colspan ='6'><div style='width:1075px;height:300px;overflow:auto;'><table border='1' cellspacing='0' cellpadding='14'>";
while ($row = mysql_fetch_array($tableResults))
{
$mix = array("<", "/>", ">", "/");
$output1 = str_replace($mix, "#", $row['output']);
$output2 = str_replace("#", "<BR/>", $output1);
echo "<tr onclick=\"alert('Test');\" onmouseover=\"document.body.style.cursor='pointer'\" onmouseout=\"document.body.style.cursor='default'\">";
echo "<TD style='text-align:center;' width='25px'>" . $row['id'] . "</td>";
echo "<TD style='text-align:center;' width='40px'>" . $row['user_id'] . "</td>";
echo "<TD width='200px'>" . $row['input'] . "</td>";
echo "<TD width='600px'>" .stripslashes($output2). "</td>";
echo "<TD style='text-align:center;' width='110px'>" . $row['model_type'] . "</td>";
echo "<TD style='text-align:center;' width='100px'>" . $row['date_time'] . "</td>";
echo "</tr>";
}
echo "</table> </div></td></tr></table></div></br></br>";
The table presents fine but at the bottom of my page I am getting the output of the Resource ID#. How can I get rid of this? Is there an error in my syntax or logic somewhere? You can see the code running here:
Do you echo
$formLayout ?From your code :
echoing the return from a query() will result in the output of “Resource ###”
echoing a file handle (returned from fopen()) will produce the same result