Herzlich willkommen im Archiv vom ABAKUS Online Marketing Forum
Du befindest Dich im Archiv vom ABAKUS Online Marketing Forum. Hier kannst Du Dich für das Forum mit den aktuellen Beiträgen registrieren.
Code: Alles auswählen
function hyperlink($text) {
$text = ereg_replace("[a-zA-Z]+://([-]*[.]?[a-zA-Z0-9_/-?&%])*", "<a href=\"\\0\">\\0</a>", $text);
$text = ereg_replace("(^| )(www([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://\\2\">\\2</a>", $text);
return $text;
}
function sql2table($sql) {
global $db;
$out = "";
$th = "";
$th = "";
$thset=0;
$erg = $db->query($sql);
while ($res = $db->getdata($erg)) {
$td .= "<tr>"."\n";
foreach($res as $key => $value) {
if($thset==0) {
$th .= '<td class="productListing-heading">'.$key.'</td>'."\n";
}
$td .='<td class="productListing-data">'.$value.'</td>'."\n";
}
$td .= "</tr>"."\n";
$thset=1;
}
$th = "<tr>".$th."</tr>"."\n";
$out = '<table class="productListing" width="100%">'.$th.$td.'</table>'."\n";
$out = hyperlink($out);
return $out;
}
//beispiel:
$db = new database();
$sql = "SELECT artikel_name AS Name, artikel_preis as Einzelpreis FROM tbl_artikel ";
echo sql2table($sql);