0

I have a MySQL database that has a column with a bunch of descriptions. I want those in a PHP array imitating this:

$Description[0] = "Here's a description";
$Description[1] = "Here's another description";
$Description[2] = "Wow, many descriptions";
$Description[3] = "Another one";
$Description[4] = "They just keep going";
...etc

I'm struggling with the while loop logic to make this happen though. Help!

2

3 Answers 3

0
$result = mysql_query(...);
$Description = array();
while ($row = mysql_fetch_array($result)) {
    array_push($Description, $row["columnyouwant"]);
}
Sign up to request clarification or add additional context in comments.

Comments

0
$Description = array();
$result = mysql_query(......);
while ($row = mysql_fetch_array($result))
{
    $Description[] = $row;
}
// echo print_r($Description);

Comments

-1

hi very simple...

foreach ($Description as $value) {
   echo $value;
}

1 Comment

Sorry, I guess I should've specified. I just want to pull the information from my MySQL database and store the values into the $Description array, not echo them out. I don't have the values in the array yet, that's what I need help with. A While loop to pull those from my database and plop them in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.