Re: Finding next recored in a array
| From: | Jim Lucas | Date: | Mon, 17 Sep 2007 19:51:56 +0000 |
| Subject: | Re: Finding next recored in a array | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262178@lists.php.net to get a copy of this message | ||
REVISED
Try this
<?php
$query = " SELECT day
FROM emailcampaign
WHERE campaign_id = '$emailcampaign'
AND member_id = '$members_id'
";
$DB_Change_Campaign_Results = safe_query($query);
##
## NOTICE: changed from array to assoc
##
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
## Switched to an indexed array with the day as the value instead of the key
$Campaign_array[] = $row['day'];
}
# At this point you have arrays as values for your $Campaign_array
# So, unless $k is an array that matches a sub array of $Campaign_array
# you're never going to get a match
$k = array_search($val,$Campaign_array);
# What is $k at this point? An int (1, 2, 3, etc...) , string (Sunday, Monday, etc...)
# Before I go any further I will need to know the above information.
if ( isset($Campaign_array[($k + 1)])) {
echo $Campaign_array[($k + 1)];
} else {
echo 'Not found';
}
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare