Jump to content

Problem In Foreach Loop With Unserialized Content


canabatz

Recommended Posts

Hi,

 

i got problem in foreach loop, the code is stuck on first loop.

 

 

any one see any problem in the code?

im stuck on it for a day now.

 

thanks !



function get_rss()
{
global $catArray, $yesterday, $date;

$rss = mysql_query("SELECT id, cat, tcat, title, pic FROM portal_coverages WHERE v = 1 AND date BETWEEN ('" . $yesterday . "') AND ('" . $date . "')ORDER BY id DESC");
$resultp = array();


while($row = mysql_fetch_object($rss))
{
$resultp[$row -> cat][$row -> tcat] = $resultp[$row -> cat][$row -> tcat] . "
<tr>
<td><p style='color:#F91010;'>" . $catArray[$row -> cat . "," . $row -> tcat] . "</p></td>
<td><img src='http://dossinet.me/" . $row -> pic . "' width='50' height='50' /></td>
<td>" . $row -> title . "</td>
<td><a href='http://dossinet.me/view," . $row -> id . ".html'>קישור </a></td>
</tr>
";
}

return $resultp;
}



include("rss/mail_class.php");


$kk=1;
$query = mysql_query("SELECT rss_id, user_id FROM `portal_rss`")or die(mysql_error());
$get_rss = get_rss();


while($row = mysql_fetch_object($query))
{
$rss_id = unserialize($row -> rss_id);


foreach($rss_id as $key)
{
$x = explode(',', $key);

if(!empty($get_rss[$x[0]][$x[1]]))
{
$title .= $catArray[$key] . ', ';
$result .= $get_rss[$x[0]][$x[1]];
}
}

if(!empty($result))
{
$query = mysql_query("SELECT * FROM `user` WHERE `userid` ='" . $row -> user_id . "'")or die(mysql_error());
$rowz = mysql_fetch_array($query);

$user['name'] = $rowz['username'];
$user['email'] = $rowz['email'];

$params = array(
'file' => 'rss',
'subject' => "עדכוני קטגוריה - " . $title,
'from_name' => "עדכוני קטגוריה ",
'vars' => array('cat' => $title, 'post' => $result, 'name' => $user['name']),
);

Mail::To($user['email']);
Mail::set_mail($params, true);
Mail::send_mail($params);
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.