English 中文(简体)
Can t 找回朋友把它储存到数据库
原标题:Can t find the friend s id to store it to the database
  • 时间:2011-10-20 11:09:34
  •  标签:
  • php

现在,我确实在为此而努力,而且似乎不能让它发挥作用。 成员.php(我展示了所有登记用户) 我有一个名单,每个用户旁边有一个链接“ADD与FRIENDS”。

为了测试目的,我设法显示每个成员都很好(从而获得身份证),但当我点击其与朋友的联系时。 它在哪里似乎有过错。 我不知道如何让这位朋友在朋友们点击我。 php file. 请看一看!

members.php

<?php
        include  connect.php ;
        include  header.php ;

        if(isset($_SESSION[ signed_in ]) == false || isset($_SESSION[ user_level ]) != 1 )
            {
                //the user is not an admin
                echo  <br/> ;
                echo  Sorry! You have to be <a href="/signin.php"><b>logged in</b></a> to view all the <a href="signup_2.php" title="Become a registered user!"><b>registered</b></a> members. ;
                echo  <br/><br/> ;
            }
            else
            {
                echo  <h2>Registered users:</h2> ;

                $sql    = "SELECT * FROM users ORDER BY user_name ASC";
                $result = mysql_query($sql);

                $num=mysql_numrows($result);

                $i=0;
                while ($i < $num)
                {
                    //$name = mysql_result($result,$i,"user_name");
                    //$id = mysql_result($result,$i,"user_id");
                    //$picture = mysql_result($result,$i,"pic_location");

                    //?friend_id=" . $id . 
                    while($user = mysql_fetch_array($result)){
                        echo $user[ user_name ]. <br/><br/><a href="friends.php?user= .$user[ user_id ]. ">ADD TO FRIENDS</a><br/> ;
                        echo $user[ user_id ];
                        echo  <br/><br/> ;
                    }

                    $i++;
                }

                ///////////////////////////////
                /// adding users as friends ///
                ///////////////////////////////

                //while($user = mysql_fetch_array($result))
                //echo $user[ user_name ].  
                    //<a href="addfriend.php?user= .$user[ id ]. ">ADD TO FRIENDS</a><br/> ;


                //NOW I WANT TO MAKE A SPECIFIC "ADD AS FRIEND" LINK NEXT TO EACH USER


            }
            include  footer.php ;
?>

正如我说过的那样,我不敢肯定如何做到这一点,请看一看! 感谢!

J. J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.

friends.php

<?php
    include "connect.php";
    include "header.php";

    if(isset($_SESSION[ signed_in ]) == false || isset($_SESSION[ user_level ]) != 1 )
    {
        //the user is not an admin
    echo  <br/> ;
    echo  Sorry! You have to be <a href="/signin.php"><b>logged in</b></a> if you want to add the person as a friend! ;
    echo  <br/><br/> ;
    }
    else
    {
        $sql = "SELECT * FROM users";
        $result = mysql_query($sql);

                //friend_id is the ID of the friend that is clicked on...
                //HOW DO I GET THAT ID THAT IS CLICKED ON IN THE WHILE "loop" in members.php?

                $friends = ("INSERT INTO friends SET user_id= " . $_SESSION[ user_id ] . " , friend_id= ".$id." , status= 0 ");
                $result_friends = mysql_query($friends);


                if(!$friends)
                {
                    //When you can t add this person as a friend this error will show!
                    echo  You cannot add this user at this time. Please try again later! ;
                }  
                else
                {
                    //When the friend is now added to the system!
                    echo  Great! Now the user needs to approve before you can be friends! ;
                }
    }
?>
最佳回答

关于你的朋友。 网址的使用

$_GET[ user_id ]

这笔钱不是美元,而是没有界定的,以获得你称之为它用“GET”变量等美元计算的 que价,

美元

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签