Skip to content

Instantly share code, notes, and snippets.

@micheljp
Created October 6, 2012 20:45
Show Gist options
  • Save micheljp/3846055 to your computer and use it in GitHub Desktop.
Save micheljp/3846055 to your computer and use it in GitHub Desktop.
Outputs stored Tweets from MySQL table
<?php
echo '<head>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
echo '</head>';
echo '<body>';
//connect to existing db w/ stored tweets and create variable with MySQL data
mysql_connect("path", "user", "pass") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
$tweet_archive = mysql_query("SELECT * FROM twindicators");
//print out MySQL fields in embedded html
while ($row = mysql_fetch_array($tweet_archive)) {
$decoded_text = urldecode($row["text"]);
echo '<p>' . $row[user] . ' | ' . $row[date] . '
<br /><br />
<a href="https://twitter.com/#!/' . $row[user] . '/status/' . $row[twid] . '">' . $decoded_text . ' </a></p>';
echo '<hr />';
}
echo '</body>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment