Jump to content

why mysql_fetch_array into multidimensional array?


levivel
 Share

Recommended Posts

I'm trying to pull out a list of id's into a simple array, but I seem to be getting is a multidimensional array. All I need is a simple array with the list of id's. What am I doing wrong?

//Get list of all sentence id's selected for test in database
$allSentenceQuery = mysql_query("SELECT id FROM associations WHERE validate='checked'") or die("First Query: ".mysql_error());
while ($allSentenceResult = mysql_fetch_array($allSentenceQuery)){
$allSentences[] = $allSentenceResult['id'];
//echo "allSentences: ".$allSentenceResult['id'];
}

And what I get:

"Array ( [0] => Array ( [1] => 2 [2] => 3 etc...."

 

Thanks for your help!

Link to comment
Share on other sites

What is that output the result of?

 

sorry, I didn't mention the other important part of the story:

 

I ran that array through array_diff to compare it with another array, and the output is actually the result of the arraydiff function. What I wanted to do was remove the elements from the first array that also appeared in the second array.

 

$rateSentences[] = array_diff($allSentences,$subjectSentences);

 

$subjectSentences is pulled the same way as allSentences in my first post. The output in my first post is a print_r of $rateSentences.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.