Hi everyone,
I want to display the results of a query, preferably as a HTML table, on a form. The form's first tab shows the parent record and the subsequent tabs show the child records from different tables. I thought I could do this with PHP in a HTML object however PHP is only executed in reports. I want to display a non-editable overview of the records in the child tables, so all the information is available on one screen without having to browse through many tabs (e.g. to show a table showing addresses, phone numbers and email addresses). This will probably be based on a view comprised of many unioned queries.
I have tried to do this with a subform, but this takes up much more onscreen space and cannot easily include icons/images.
Thanks,
James
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
How to display query results on a form?
Re: How to display query results on a form?
bluemoon,
try this..
//-- Create a nuBuilder html object that contains this..
this goes in 'Before Open' of the form
It builds the table with php into a string and then inserts it into a div as the page is loaded.
Steven
try this..
//-- Create a nuBuilder html object that contains this..
Code: Select all
<div id='HTMLobject' style='top:10px;left:10px;width:400px;height:400px'></div>
Code: Select all
$HTMLstring = '';
//-- add table name
$table = '';
$result = nuRunQuery("SELECT * FROM $table");
$fields_num = db_num_fields($result);
$HTMLstring .= "<table border='1'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++){
$field = db_fetch_field($result);
$HTMLstring .= "<td>{$field->name}</td>";
}
$HTMLstring .= "</tr>\n";
// printing table rows
while($row = db_fetch_row($result)){
$HTMLstring .= "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell){
$HTMLstring .= "<td>$cell</td>";
}
$HTMLstring .= "</tr>\n";
}
$HTMLstring .= "</table>\n";
$HTMLstring = base64_encode($HTMLstring);
$jsString = "function nuLoadThis(){\n";
$jsString .= " var nuHTMLtable = '$HTMLstring';\n";
$jsString .= " document.getElementById('HTMLobject').innerHTML = decode64(nuHTMLtable);\n";
$jsString .= "}";
addJSFunction($jsString);
Steven