note 4286 deleted from ref.odbc by sniper

From: Date: Tue, 04 Nov 2003 00:36:29 +0000
Subject: note 4286 deleted from ref.odbc by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59746@lists.php.net to get a copy of this message
Note Submitter: Pascal.Guimier@wanadoo.fr ---- This is a usefull fetch_array function, inspired from SAL.phl (http://px.sklar.com/code-pretty.html?code_id=73) Thanks to Gianugo Rabellino (mailto:gianugo@inet.it) function odbc_fetch_array($res) { $row = array(); $result = array(); if ($result = odbc_fetch_row($res)) { $nf = odbc_num_fields($res)+1; for($count=1; $count < $nf; $count++) { $field_name = odbc_field_name($res, $count); $field_value = odbc_result($res, $count); $row[$count] = $field_value; /* or $row[$field_name] = $field_value */ } return $row; } } ------------------------ use it like this : $QCateg="SELECT * FROM Table"; $ret = odbc_exec($conn, $QCateg) or die("Invalid query : $QCateg"); print "My select : <select name=myselect>"; While ($row = fetch_array($ret, 2)) print "<option value=$row[1]>$row[2]\n"; print "</select>\n<br>";

« previous php.notes (#59746) next »