Jump to content

PHP/MYSQL create an array or string from a column and not a row


icez

Recommended Posts

** I'm french so, sorry for my bad english

*** I have no idea of how to do this so thank you to any one who can give me an hint to how!

 

I want to retrieve all numbers in the column chapter of my database and create an array or a string with it.

 

/////////////////////////////////

//CHAPTER | DATE | ... | //

// 28 | XX | ... | //

// 29 | XX | ... | //

...

 

The result I want to get from the script should be something like this...

 

$string = '28,29,30,31,32';

$query = "SELECT `chapter` FROM `table_name` ORDER BY `chapter` ASC";
$result = mysql_query($query);
while($array = mysql_fetch_assoc($result)) {
     $list[] = $array['chapter']; // to store results in an array
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.