Date: 10/30/02
- Next message: Ford, Mike [LSS]: "RE: [PHP-DB] losing my session variables"
- Previous message: David Robley: "[PHP-DB] Re: Decimal places."
- Next in thread: 1LT John W. Holmes: "Re: [PHP-DB] Retruning an array from a row"
- Reply: 1LT John W. Holmes: "Re: [PHP-DB] Retruning an array from a row"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello All,
How can I return and print an array from a user defined function from
a database from a row like this, *just one row*, but it contains more
than 1 columns:
+--------+--------+
| Field1 | Field2 |
+--------+--------+
| Data1 | Data2 |
+--------+--------+
I want the output will be: Data1
Data2
I have tried this:
funtion get_dbfield_data(){
$conn=dbconn(); // mysql connection function
$result=mysql_query("SELECT Field1,Field2 FROM table_name WHERE Condition);
$fields_data=array();
while($row=mysql_fetch_row($result)){
$fields_data[]=$row[0];
}
return $fields_data;
}
// End function
//... Now the main program
$data=get_dbfield_data();
$i=0;
foreach($data as $k){
echo "$k<br>";
$i++;
}
The output : Data1
:( and if I count(get_dbfield_data()) it returns 1. Can anybody help
me? Thank you for your generous help...
-- Best regards, Erick Wellem-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Ford, Mike [LSS]: "RE: [PHP-DB] losing my session variables"
- Previous message: David Robley: "[PHP-DB] Re: Decimal places."
- Next in thread: 1LT John W. Holmes: "Re: [PHP-DB] Retruning an array from a row"
- Reply: 1LT John W. Holmes: "Re: [PHP-DB] Retruning an array from a row"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

