Mailinglisten-Archive |
Hi PCS,
>Ich suche Beispiele für die verwendung einer ODBC (Access) Datenbank mit
>PHP3.
<?
$connection_id= odbc_connect("testodbc", "",""); /* Verbindung zur
ODBC-Datenquelle */
$query="select * from artikel where name like '%maus%'";
$result=odbc_exec($connection_id, $query);
/* zuerst automatisch alles als HTML-Tabelle ausgeben */
odbc_result_all($result, "bgcolor=#006666 border=1 cellspacing=0");
/* und jetzt das ganze manuell */
echo("<br><br><table bgcolor=#660066 border=1 cellspacing=0
cellpadding=5>");
$query="select * from artikel where name like '%maus%'";
$result=odbc_exec($connection_id, $query);
/* feldnamen ausgeben */
echo("<tr>");
for($i=0;$i<odbc_num_fields($result);$i++)
{
$feldname=odbc_field_name($result,$i+1);
echo("<td><font face=\"Verdana, Arial, Helevtica, sans-serif\" size=3
color=#FFFFFF><b>$feldname</b></font></td>");
}
echo("</tr>");
/* daten ausgeben */
while(odbc_fetch_row($result))
{
echo("<tr>");
for($i=0;$i<odbc_num_fields($result);$i++)
{
$feld=odbc_result($result,$i+1);
echo("<td><font face=\"Verdana, Arial, Helevtica, sans-serif\" size=2
color=#FFFFFF>$feld</font></td>");
}
echo("</tr>");
}
echo("</table>");
?>
Grüße
Stephan
work: http://analogon.com
phpforum: http://analogon.com/php/
php::bar PHP Wiki - Listenarchive