Zend - The PHP Company




Informix

Add Code


PHP / Informix connection  

Type: code fragment
Added by: soffinagli
Entered: 05/10/2000
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 9313
This allows you to start database programming in PHP using an Informix server. This fragment pulls out two fields from a table.


<?
$db_user 
=         "user";       // username for db
$db_password =     "password";        // password for db
$db =              "database@server";    // db to use

$db_query =    "select id, product from catalog";

$conn_id ifx_connect("$db""$db_user""$db_password");
$result ifx_query($db_query$conn_id); 

    if (
$result) {
    echo 
"These were in the catalog table:<ul>";
    while (
$r ifx_fetch_row($result)) {

    
// reformat output

    
$id $r["id"];
    
$product $r["product"];

    echo 
"<li>$id$product";

    }
    echo 
"</ul>";

        } else {
        echo 
"No data.";
        
ifx_errormsg();
        }
ifx_free_result($result);
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories