dynamic html tables using php
Posted: Sat Mar 11, 2006 5:53 pm
hawleyjr | Please use
Does this look correct?
TIA,
new_developer
hawleyjr | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi,
I am using php 4, an oracle 10g database, and a linux server.
I am trying to construct a loop to create a table. I am retrieving data from an oracle database. It has 3 fields (question, answer, and comments). I now want to display these three fields on a page. I assume that I can use a for loop to create the fields, but I am unclear on the syntax. Can I use html tags inside a php script or do I enclose the for statement in the <? ?> and then add html tags?
Can someone help me with the code below?Code: Select all
$sql = "select a.candidatequestion_id,
a.question,
a.answer,
a.comments
from table_name a
where a.candidate_id = 33034
order by a.displayorder";
if (!$dbcon->select_data($sql)) $dbcon->manage_error();
$result = $dbcon->get_result_set();
<table border="1" cellpadding="3">
<tr>
<? for ($z=0;$z<sizeof($result);$z++){ ?>
<td align="left"> <? $result[$z]->QUESTION ?> </td>
<td align="left"> <? $result[$z]->ANSWER ?> </td>
<td align="left"> <? $result[$z]->COMMENTS ?> </td>
<? } ?>
</tr>TIA,
new_developer
hawleyjr | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]