Static echo insertion into While Loops?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
cyan studios
Forum Newbie
Posts: 2
Joined: Wed May 21, 2008 9:39 am

Static echo insertion into While Loops?

Post by cyan studios »

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?

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);
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: Static echo insertion into While Loops?

Post by Burrito »

not sure what you mean by 'insert into one element' and 'insert into another element'

you could create two arrays and populate them inside you loop with the values you want. Or alternatively, you could create an object and use the object's property's as the values you're trying to push into 'elements'.
Post Reply