Jim Lucas wrote:
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';
}
include ("includes/location.php");
$query = " SELECT day
FROM emailcampaign
where campaign_id = '1'
AND member_id = '8'
";
$DB_Change_Campaign_Results = safe_query($query);
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
$Campaign_array[] = $row['day'];
}
if ( isset($Campaign_array[($k + 1)])) {
echo $Campaign_array[($k + 1)];
} else {
echo 'Not found';
}
var_dump($Campaign_array);
This is what I get now when I run this
1
*array*
0 => string '0' /(length=1)/
1 => string '1' /(length=1)/
2 => string '3' /(length=1)/
3 => string '6' /(length=1)/
4 => string '9' /(length=1)/
5 => string '12' /(length=2)/
6 => string '15' /(length=2)/
7 => string '20' /(length=2)/
8 => string '25' /(length=2)/
9 => string '30' /(length=2)/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php