Static echo insertion into While Loops?
Posted: Mon Jan 19, 2009 3:12 pm
I have a while loop that takes some values from our SQL database and it will be echoed into an XFA form to merge to a PDF.
The basic problem is, I need to take some of the results of the row fetch and insert them into one element, then take the rest and insert it into a second element.
I don't want the element tags to repeat like the row results do. I've considered finding ways to turn while results into variables and all kinds of things, and web searches lead me to believe the search itself is erroneous.
Can anyone help me with this?
The basic problem is, I need to take some of the results of the row fetch and insert them into one element, then take the rest and insert it into a second element.
I don't want the element tags to repeat like the row results do. I've considered finding ways to turn while results into variables and all kinds of things, and web searches lead me to believe the search itself is erroneous.
Can anyone help me with this?
Code: Select all
if (!$conn)
{exit('Connection Failed: ' . $conn);}
$sql="SELECT fname, lname, empl FROM PREmployees";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit('Error in SQL');}
$lname=odbc_result($rs,'lname');
$fname=odbc_result($rs,'fname');
$empl=odbc_result($rs,'empl');
$xdpStr = '<valid>';
echo $xdpStr;
while (odbc_fetch_row($rs))
{
echo $empl . ',';
}
$xdpStr2 = '</valid>
<valcatch>';
echo $xdpStr2;
while (odbc_fetch_row($rs))
{
echo $fname . ' ' . $lname . ',';
}
$xdpStr3 = '</valcatch>';
echo $xdpStr3;
odbc_close($conn);