Re: Database abstraction?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Apr 17, 2008, at 2:12 PM, Jim Lucas wrote:
Jason Pruim wrote:
On Apr 17, 2008, at 11:14 AM, Jim Lucas wrote:
Stut wrote:

[/snip]


Both ideas worked great... Thank you!
Now I do still have one question, I decided that what Jim put up worked a little bit better for me so I'm going off of his code, what I want to do now though, is take this code:
       foreach ( $dataSet AS $row ) {
echo <<<ROW
           <tr>
           <td>{$row['FName']}</td>
           <td>{$row['LName']}</td>
           <td>{$row['Add1']}</td>
           <td>{$row['Add2']}</td>
           <td>{$row['City']}</td>
           <td>{$row['State']}</td>
           <td>{$row['Zip']}</td>
           <td>{$row['XCode']}</td>
           <td>{$row['Record']}</td>
           </tr>
ROW;
       }
And turn it into some kind of a loop that would pull the info dynamically so I can have something more like this:
<?PHP
while($dataSet <= $num_rows) {
   //print dynamic fields based off of field names
echo <<<ROW
   <tr>
<td>$dataSet['$field']</td>
</tr>
ROW;
}
?>
And what would print on the page would be something along the lines of:
<?PHP
echo <<<TEST
<tr>
<td>Jason</td>
<td>Pruim</td>
<td>My Address</td>
<td>My Other Address</td>
</tr>
TEST;
?>
Etc. Etc. Etc. I'm trying to avoid hardcoding things like field names so that I can use this software for multiple customers without having to completely customize it for everyone since so many parts will be the same. Maybe though I'm trying to abstract the wrong part of the program... I could do it to a few other parts and just customize this one...
Need to think about that.
Any ideas are greatly appreciated :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@xxxxxxxxxx

This would do it.

foreach ( $dataSet AS $row ) {
	echo '<tr><td>.join('</td><td>', $row).'</td></tr>';
}

Okay so that worked perfectly... NOW... Care to tell me why? :) Or point me to the right area?



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@xxxxxxxxxx




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux