Re: [PHP] Database abstraction?




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



.



Relevant Pages

  • Re: [PHP] New years resolution: To get serious with my programming! Anyone wanna help? :)
    ... a nice userfriendly message log the cryptic mysql error message, ... echo "SOMETHING BAD HAPPENED!"; ... 3251 132nd ave ... Holland, MI, 49424 ...
    (php.general)
  • Re: [PHP] SEARCHING for an answer...
    ... ONLY reference to edit.php in the entire code of that page. ... echo $qstring; ... 3251 132nd ave ... Holland, MI, 49424 ...
    (php.general)
  • Live FreeBSD CD
    ... To customise liveFreeBSD create a new directory then have ... Customize will only copy files 1 level deep, ... echo x - Makefile ... X# Run installworld and install into our object directory ...
    (freebsd-current)
  • Re: Office 07 Where is the Print Button
    ... Right-click, choose Customize, and then add Print from the list of commands. ... Echo [MS PPT MVP] http://www.echosvoice.com ...
    (microsoft.public.office.misc)
  • Re: [PHP] Database abstraction?
    ... echo <<<HTML ... <?PHP ... 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. ... Thanks Jim! ...
    (php.general)