It's probably just a stupid mistake but I've built a tool to monitor tweet of a certain hash tag. However, when I try to save them to a database it only saves one tweet.
I have attached my code below.
foreach($results as $result) {
$tweetID = $result->id_str;
$userID = $result->from_user_id_str;
$tweetText = $result->text;
$tweet_time = strtotime($result->created_at);
$createdAt = date('Y-m-d H:i:s ',$tweet_time);
echo '<div>'.
'<div class="tweet" >' . displayTweet($result->text),"\r\n" .
'<div class="user">'. '<strong>Posted </strong>' . date('j/n/y H:i:s ',$tweet_time). '<strong> By </strong>' .
'<a rel="nofollow" href="http://twitter.com/' . $result->from_user. '">' . $result->from_user .
'</div>' .
'</div>';
// Execute query
mysql_select_db("dbname", $conn) or die(mysql_error());
$query = ("INSERT INTO ".$hashtag."(tweetID, userID, tweetText, createdAt) VALUES('$tweetID', '$userID', '$tweetText', '$createdAt')");
$output = mysql_query($query) or trigger_error(mysql_error()." in ".$query);
}
mysql_close($conn);
?>
How would I go about fixing this to get it to save every tweet? Thanks in advance