Date: 10/30/02
- Next message: Josh Johnson: "RE: [PHP-DB] Decimal places."
- Previous message: Ford, Mike [LSS]: "RE: [PHP-DB] losing my session variables"
- In reply to: Erick Wellem: "[PHP-DB] Retruning an array from a row"
- Next in thread: Erick Wellem: "Re[2]: [PHP-DB] Retruning an array from a row"
- Reply: Erick Wellem: "Re[2]: [PHP-DB] Retruning an array from a row"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
----- Original Message -----
From: "Erick Wellem" <erick <email protected>>
To: <php-db <email protected>>
Sent: Wednesday, October 30, 2002 6:44 AM
Subject: [PHP-DB] Retruning an array from a row
> 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];
You're only returning the first column of each row. If you just want to
return the first row in the result, then do this:
$result = mysql_query(...)
$row = mysql_fetch_row($result)
return $row;
---John Holmes...
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Josh Johnson: "RE: [PHP-DB] Decimal places."
- Previous message: Ford, Mike [LSS]: "RE: [PHP-DB] losing my session variables"
- In reply to: Erick Wellem: "[PHP-DB] Retruning an array from a row"
- Next in thread: Erick Wellem: "Re[2]: [PHP-DB] Retruning an array from a row"
- Reply: Erick Wellem: "Re[2]: [PHP-DB] Retruning an array from a row"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

