One variable row inside another variable row

前端 未结 3 1847
庸人自扰
庸人自扰 2021-01-28 16:09

I have following script:

$sql = \"SELECT * FROM `users`\"
$q = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($q);
$sql1 = \"SELECT * FROM `ot         


        
3条回答
  •  终归单人心
    2021-01-28 16:58

    $sql = "SELECT * FROM users;";
    $q = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($q);
    
    $sql1 = sprintf("SELECT * FROM other_table where username='%s';", $row['username']);
    $q1 = mysql_query($sql1) or die(mysql_error());
    $row1 = mysql_fetch_array($q1);
    

    // now $row1 contains the tuple of this user and could access the variables are you would // normally do e.g. $row1['ID']

提交回复
热议问题