0

This should be a quick one.

I'm pulling a list of id's and I need to place them in an array.

Here is my php code to get the list of id's

$get_archives = mysql_query("SELECT * FROM archive WHERE user = '$email'  ");
while ($row = mysql_fetch_assoc($get_archives)) {
$insta_id = $row['insta_id'];

    $insta_id = "'" . $insta_id."',";

echo $insta_id;

    };

This echo's a list of id's that looks like this: '146176036','136514942',

Now I want to put that list into an array. So i tried something like this:

    $y = array($insta_id);

However that isn't working. Any suggestions?

4 Answers 4

1
$y = array();
while ($row = mysql_fetch_assoc($get_archives)) {
  $y[] = $row['insta_id'];
}
Sign up to request clarification or add additional context in comments.

Comments

0
$myArray = array();

    $get_archives = mysql_query("SELECT * FROM archive WHERE user = '$email'  ");
    while ($row = mysql_fetch_assoc($get_archives)) {
    $insta_id = $row['insta_id'];

        $insta_id = "'" . $insta_id."',";


        $myArray[] =$insta_id;

        };

Comments

0

did you mean like this: ?

$insta_id=array();
while ($row = mysql_fetch_assoc($get_archives)) {
$insta_id[] = $row['insta_id'];
}

Comments

0

Create an array, and push the values into it:

$values = array();

while ( $row = mysql_fetch_assoc( $get_archives ) ) {
  array_push( $values, $row['insta_id'] );
}

Comments

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.