03-21-2008, 09:17 AM
|
#1 (permalink)
|
|
The Contributor
Join Date: Sep 2007
Location: Finland
Posts: 45
Thanks: 3
|
Table generator?
Hi all and happy eastern! =)
I have on my new project quite many tables where I collect infos and such. I'm totally pissed of to write all over those tables and thought that if I need to changes something (class name etc) I have to go throught those all.. no way!
So, I know that it is possible to make function which generate table but would need some example of that.
Preferences as query and field names.. below is something what I came in my mind but I just can't get it work.. eh..
PHP Code:
function maketable($field, $query) {
$fields[] = array($field);
print("<table cellspacing=\"0\" cellpaddign=\"5\" width=\"100%\">\n");
$arr = mysql_query($query) or die(mysql_error());
while($fetch = mysql_fetch_array($arr)) {
foreach($fields as $f) {
print("<tr><td>".$fetch[$f[0]]."</td><td>".$fetch[$f[2]]."</td></tr>\n");
}
}
print("</table>\n\n");
}
Thanks for all help! =)
|
|
|