Jump to content

looping through array subset


rndilger

Recommended Posts

Hello, I can't seem to figure out how to check a particular subset of array values obtained by using the following statement:

 

while(list($id, $member, $mem_producer, $mem_supplier, $firstname, $lastname) = mysql_fetch_array($resultType))

 

I would like to use a loop to check and see whether $mem_producer, $mem_supplier, and more categories to come are set to 'y' or 'n'. Does the while(list...) statement write the mysql values to an array? If so, what is the name of that array and can I grab a subset of it?

 

Your help is much appreciated.

 

Thanks,

 

Ryan

Link to comment
Share on other sites

list() doesn't write the values to an array. The result is already returned as an array i.e. mysql_fetch_array();

 

Thanks for the response. If the result is already returned as an array, how can I use that array to create another array?

I want to use something like:

 

$mem_type_check = array_slice(whateverthearrayiscalled,2,count(mem_type)+2);

Ryan

Link to comment
Share on other sites

Hello, I can't seem to figure out how to check a particular subset of array values obtained by using the following statement:

 

while(list($id, $member, $mem_producer, $mem_supplier, $firstname, $lastname) = mysql_fetch_array($resultType))

 

I would like to use a loop to check and see whether $mem_producer, $mem_supplier, and more categories to come are set to 'y' or 'n'. Does the while(list...) statement write the mysql values to an array? If so, what is the name of that array and can I grab a subset of it?

 

Your help is much appreciated.

 

Thanks,

 

Ryan

 

This:

 

while($field = mysql_fetch_array($resultType)
{
  $first = $field['firstname'];
}

 

the variable in the brackets [''] is replaced with whatever your database holds

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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