?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?How to put whole colume in an array?
Author:??(---.dsl.snfc21.pacbell.net)
Date:???10-14-03 16:51

If i have a country list want to list out, like this:

table "country"

cou_list
---------
USA
England
China
Japan
Korea
...etc

How can I list them out?
I can list them out by "while" function
but I want to put them all in an array.

I have tried this:

function get_country_array()
// extract old info from database
{
$conn = db_connect();

$query = "select cou_list from countries";
$result = mysql_query($query);

$col = mysql_num_rows($result);
$country_ar = array();

for ($i = 0; $i <=$col; $i++) {
$result[$i] = $country_ar;
}

for ($i=0; $i <=$col; $i++)
{
if ($country_ar[$i] == $old_country)
{
$country_select[$i] = 'selected'; } echo '';
}

return $result;
}
?>

Can anyone teach me?
thanks

?Topics Author? Date
?How to put whole colume in an array???new
Vincent 10-14-03 16:51?
?how to retrieve address in variable using array???new
jan 10-14-03 20:25?
?Re: How to put whole colume in an array???new
bastien 10-15-03 06:48?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > If i have a country list want to list out, like this: > > table "country" > > cou_list > --------- > USA > England > China > Japan > Korea > ...etc > > How can I list them out? > I can list them out by "while" function > but I want to put them all in an array. > > I have tried this: > > function get_country_array() > // extract old info from database > { > $conn = db_connect(); > > $query = "select cou_list from countries"; > $result = mysql_query($query); > > $col = mysql_num_rows($result); > $country_ar = array(); > > for ($i = 0; $i <=$col; $i++) { > $result[$i] = $country_ar; > } > > for ($i=0; $i <=$col; > $i++) > { > if ($country_ar[$i] == $old_country) > { > $country_select[$i] = > 'selected'; } echo ''; > } > > return $result; > } > ?> > > Can anyone teach me? > thanks ">??

Provided By
Phorum