Jump to content

Recommended Posts

This seems like a stupid question but I cant seem to figure it out. What I am trying to do is generate an array that looks like the below sample but have all the Member ID's group so I know the card each member grabbed.

 

Array
(
    [889557275612] => Array
	(
	    [0] => Array
	        (
	            [Cards_ID] => 51
	            [Cards_MemberID] => 889557275612
	            [Cards_Card] => 308292114653
	            [Cards_DateTime] => 1969-12-31 18:00:00
	        )

	    [1] => Array
	        (
	            [Cards_ID] => 51
	            [Cards_MemberID] => 889557275612
	            [Cards_Card] => 308292114653
	            [Cards_DateTime] => 1969-12-31 18:00:00
	        )
	)
    [971131027757] => Array
	(
	    [0] => Array
	        (
	            [Cards_ID] => 51
	            [Cards_MemberID] => 971131027757
	            [Cards_Card] => 308292114653
	            [Cards_DateTime] => 1969-12-31 18:00:00
	        )
	)
)

 

 

  $query = "SELECT
               *
            FROM
               Cards";
  $res =& $db['tickets']->query($query);
  if (PEAR::isError($res))
  	throw new TixException($_SERVER['SCRIPT_NAME'] . ":", TixExceptionCodes::UNKNOWN_ERROR);
  
  $cardsGrouped = array();
  while ($res->fetchInto($row)) {
  	array_push($cardsGrouped[$row['Card_MemberID']], $row);
  }

Not really sure what you are talking about a little bit. But this is where I would start. Hopefuly this might help you some way.

 

 

<?PHP






$query = "SELECT * FROM  Cards";

$result = mysql_query($query)
or die("Query failed: " . mysql_error());


while ($row = mysql_fetch_assoc($result))
{


$Cards_ID[1] = $row['Cards_ID'];
$Cards_MemberID[1] = $row['Cards_MemberID'];
$Cards_Card[1] = $row['Cards_Card'];
$Cards_DateTime[1] = $row['Cards_DateTime'];
}





Array
(
    [889557275612] => Array
	(
	    [0] => Array
	        (
	            [Cards_ID] => 51
	            [Cards_MemberID] => 889557275612
	            [Cards_Card] => 308292114653
	            [Cards_DateTime] => 1969-12-31 18:00:00
	        )

	    [1] => Array
	        (
	            [Cards_ID] => 51
	            [Cards_MemberID] => 889557275612
	            [Cards_Card] => 308292114653
	            [Cards_DateTime] => 1969-12-31 18:00:00
	        )


?>

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.