Mini Twitter System streaming + notes, PHP

Source: Internet
Author: User
Small Twitter System source + notes, PHP

?

Let's do it today. The source code of the small Twitter system is a familiar piece of PHP.

For the next month's graduation plan.

?

Download the

Http://dl.vmall.com/c0nkwafdqz

?

Index

?

 
  
 
  Microblogging application

See List of users

" . $_session [' message ']. ""; unset ($_session [' message ']);}? >


Headers

?

?

 
  Sorry, could not connect to database.
Please contact your system's admin for more help\n ";" Exit ();} mysql_select_db ($DATABASE);? >

Users

 
  
 
  Microblogging application-users

List of Users

$value) {//=> refers to getting the contents of an element within a cell within an array, echo " \ n "; echo" \ n ";//Show Idecho" \ n "; echo" \ n ";}?" >
" . $key. "unfollow follow";} echo "

There is no users in the system!



?

?

  0) {$extra = "limit $limit";} else {$extra = ";} $sql = "Select User_id,body, stamp from posts where user_id on ($user _string) Order BY stamp desc $extra"; echo $sql; $resul t = mysql_query ($sql), while ($data = Mysql_fetch_object ($result)) {$posts [] = array (' stamp ' = + $data->stam P, ' userid ' = $data->user_id, ' body ' and ' $data->body ');} return $posts;} /** * Show User * If user_id = 0, show all users directly * If User ID >0, display username changed user follow * @param unknown_type $user _id * @return multitype:| Multitype:null */function show_users ($user _id = 0) {if ($user _id > 0) {$follow = array (); $fsql = "Select user_id from Followingwhere follower_id= ' $user _id ' ";//select Follower$fresult = mysql_query ($fsql) from follow, while ($f = Mysql_fetch _object ($fresult)) {//Turn the result into a Array_push ($follow, $f->user_id);//Place the user_id field in F in Follow}if (count ($follow) {$id _string = implode (', ', $follow);//with "," as the delimiter to process this string, the stitching behind the Sql$extra = "and ID in ($id _string)";} else {return array ();}} $users= Array (); $sql = "SELECT ID, username from users where status= ' active ' $extra order by username";//select Follower ID from user table and Name$result = mysql_query ($sql), while ($data = Mysql_fetch_object ($result)) {$users [$data->id] = $data->u sername;//want to fill in user name}return $users;} /** * Search out user follow User ID * @param unknown_type $userid * @return Multitype: */function following ($userid) {$users = array ( $sql = "SELECT distinct user_id from followingwhere follower_id = ' $userid '", $result = mysql_query ($sql); while ($dat A = Mysql_fetch_object ($result)) {Array_push ($users, $data->user_id);} return $users;} function Check_count ($first, $second) {$sql = "SELECT count (*) from Followingwhere user_id= ' $second ' and follower_id= ' $fi Rst ' "; $result = mysql_query ($sql); $row = Mysql_fetch_row ($result); return $row [0];} function Follow_user ($me, $them) {$count = Check_count ($me, $them), if ($count = = 0) {$sql = "INSERT into following (use r_id, follower_id) VALUES ($them, $me) "; $result =mysql_query ($sql);}} function Unfollow_user ($me, $them) {$count = Check_count ($me, $them), if ($count! = 0) {$sql = "Delete from followingwhe Re user_id= ' $them ' and follower_id= ' $me ' limit 1 '; $result = mysql_query ($sql);}}? >


Add

?

?

 
  


 
  



  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.