Note that there are some explanatory texts on larger screens.

plurals
  1. POfind friends who also tweet this
    primarykey
    data
    text
    <p>I'm working out a social tool like twitter, but I got stuck on "who also tweet this twitter."</p> <p>There's a list of twitters on my page, and I wanna display who also tweeted this for each tweet.</p> <p>I'm using MySQL + php + Smarty.</p> <p>Here's the code: /* ---- php ---- */</p> <pre><code>// Get twitters that tweeted over 200 times. $sql = mysql_query("SELECT id, content, user, tweets FROM twitter_list WHERE tweets &gt; '200'"); $twitter_array = array(); while($tweet_row = mysql_fetch_array($sql)){ array_push($twitter_array, $tweet_row); // Get the users who tweeted these twitters. $twitter_id = $tweet_row['id']; // Find out 5 friends who also tweeted this twitter. twitter_relation stores who tweets what. $friends_who_also_tweet = mysql_query("SELECT tid, twitter_id, user_id FROM tweet_relation WHERE twitter_id = '$twitter_id' ORDER BY tid DESC LIMIT 5"); $friends_who_also_tweet_array = array(); while($friends_who_also_tweet_row = mysql_fetch_array($friends_also_tweet_array)){ array_push($friends_who_also_tweet_array, $friends_who_also_tweet_row); } if($friends_who_also_tweet_array){ $sm-&gt;assign("fwat", $friends_who_also_tweet_array); } } if($twitter_array){ $sm-&gt;assign("twitter", $twitter_array); } $smarty-&gt;display('twt.html'); </code></pre> <p>/* ---- HTML: twt.html ---- */</p> <pre><code>... {section name=twitter loop=$twitter} &lt;div class="content"&gt;{$twitter[twitter].content}&lt;/div&gt; &lt;div class="who_also_tweet"&gt; {section name=who loop=$fwat} &lt;div class="i_also_tweet"&gt;{$fwat[who].user_id}&lt;/div&gt; {/section} &lt;/div&gt; {/section} </code></pre> <p>I wish to get the array of twitter, and for each twitter, retrieve the 5 users who tweets it. But it only display the first twitter's users, I suspect while() might be wrong but cannot find it out. Anyone could lend me a hand? Many thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload