Re: Finding next recored in a array

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

 



Jim Lucas wrote:
Richard Kurth wrote:


$query = "    SELECT    day
        FROM    emailcampaign
        where    campaign_id = '$emailcampaign'
        AND    member_id = '$members_id'
    ";
$DB_Change_Campaign_Results = safe_query($query);

while ( $row = mysql_fetch_array($DB_Change_Campaign_Results) ) {
    $Campaign_array[$row['day']] = $row;
}

# 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 ( ($k + 1) < count($Campaign_array) ) {
    echo $Campaign_array[$k + 1];
}


This is what I get if I run the above script.
From a var_dump($Campaign_array); I get

*array*
0 => *array*
     0 => string '0' /(length=1)/
     'day' => string '0' /(length=1)/
1 => *array*
     0 => string '1' /(length=1)/
     'day' => string '1' /(length=1)/
3 => *array*
     0 => string '3' /(length=1)/
     'day' => string '3' /(length=1)/
6 => *array*
     0 => string '6' /(length=1)/
     'day' => string '6' /(length=1)/
9 => *array*
     0 => string '9' /(length=1)/
     'day' => string '9' /(length=1)/
12 => *array*
     0 => string '12' /(length=2)/
     'day' => string '12' /(length=2)/
15 => *array*
     0 => string '15' /(length=2)/
     'day' => string '15' /(length=2)/
20 => *array*
     0 => string '20' /(length=2)/
     'day' => string '20' /(length=2)/
25 => *array*
     0 => string '25' /(length=2)/
     'day' => string '25' /(length=2)/
30 =>

   *array*
     0 => string '30' /(length=2)/
     'day' => string '30' /(length=2)/

From a $val="5";
$k = array_search($val,$Campaign_array);
var_dump($k); I get

boolean false

--
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