canabatz Posted November 5, 2012 Share Posted November 5, 2012 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); } } Quote Link to comment https://forums.phpfreaks.com/topic/270314-problem-in-foreach-loop-with-unserialized-content/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.