select id from [TableName] where username = 'bobo';

解决方案 »

  1.   

    select id from 表名 where username='bobo';这个就可以了。不要告诉你这个username中的bobo有很多就可以了。
      

  2.   

    $query=mysql_query(select id from [TableName] where username = 'bobo';);
    $row=mysql_fetch_array($query);
    echo $row["id"];
      

  3.   

    $result=mysql_query(select * from [TableName] where username = 'bobo' and password='[bobo的密码]';);
    if(mysql_rows_num($result)>0){//登陆成功
      $row=mysql_fetch_array($result);
      echo $row["id"];
    }
      

  4.   

    多了个分号,改写作$query='select * from [TableName] where username = \'bobo\' and password=\'[bobo的密码]\'';
    $result=mysql_query($query);
    if(mysql_rows_num($result)>0){//登陆成功
      $row=mysql_fetch_array($result);
      echo $row["id"];
    }
      

  5.   

    $query=mysql_query(select id from 表名 where username = 'bobo');
    $row=mysql_fetch_array($query);
    echo $row["id"];
      

  6.   

    $result=mysql_query("select id from 表名 where username = 'bobo'");
    $row=mysql_fetch_object($result);
    echo $row->id;
      

  7.   

    user.php是登陆以后的页面,php代码如下:
    <?
    $a=$array[username];
    $dbh =  mysql_connect('localhost:3306','root','shilyshare520'); 
    mysql_select_db('xinlu',$dbh); 
    $sql="select username from user where username='".$logname."' and password='".$password."'";
    $res = mysql_query($sql, $dbh);
    $array=mysql_fetch_array($res);
    if($array[username])
    {Session_start();
    Session_register('a');
    $a=$array[username];
    ?>修改用户信息的页面是user_info.php,代码如下:
    <?
    if(session_is_registered(a))
    {
    $sql="select * from user where username='".$username."'";
    $dbh =  mysql_connect('localhost:3306','root','shilyshare520'); 
    mysql_select_db('xinlu',$dbh); 
    $res = mysql_query($sql, $dbh);
    $row=mysql_fetch_array($res);?>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>
    <div align="center">
      <p>修改用户信息</p>
      <form name="form1" method="post" action="updateuser.php?id=<?print($id);?>">
        <p>用户名:
          <input name="textarea" type="text" value="<?print($row[username]);?>">
        </p>
        <p>旧密码:
          <input name="textarea2" type="password" value="<?print($row[password]);?>">
        </p>
        <p>新密码:
          <input name="newpass" type="text" id="newpass" value="">
        </p>
        <p>确认密码: 
          <input name="newpass2" type="text" id="newpass2" value="">
        </p>
        <p>
          <input type="submit" name="Submit" value="修改">
        </p>
      </form>
      <p>&nbsp; </p>
    </div>
    </body>
    </html><?}
    else 
    {?><html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>你没有这个权限!!!!!!!
    </body>
    </html>
    <?}?>现在的问题是,每次取得的用户id都是1,不知道程序问题出在那里,哪位帮忙看看,而且现在对应用户的信息也不能传回user_info.php这个页面了!
    online for waiting.
      

  8.   

    $sql="select * from user where username='".$username."'";错了
    $sql="select * from user where username=".$a;
    <form name="form1" method="post" action="updateuser.php?id=<?print($id);?>">错了 <form name="form1" method="post" action="updateuser.php?id=<?print($row["id"]);?>">
    if(session_is_registered(a))错了if(session_is_registered("a"))