Re: Finding next recored in a array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux