echo on query result buggin

时间:2017-05-07 11:54:20

标签: php mysql echo

我试图用:

提取$ row elemts
$sql = "SELECT date, email, journal, section FROM selection_loggedin WHERE email = '$email' and date in (SELECT max(date) FROM (SELECT date, email FROM selection_loggedin WHERE email = '$email') as x)";
$result = $dbc->query($sql);

if ($result->num_rows > 0) { 

while($row = $result->fetch_assoc()) {
    $journal = row['journal'];
    $section = row['section'];
    print_r($row);
    //echo "'$journal'"."'$section'";
    echo "<br>".row['email']."<br>";
    echo row['date']."<br>";

我明白了:

Array ( 
      [date] => 2017-05-07 12:45:45 
      [email] => benoitkoen@gmail.com 
      [journal] => Wall Street Journal 
      [section] => Economy 
) 

为什么不打印正确的东西(&#39;华尔街日报&#39;经济&#39;)

1 个答案:

答案 0 :(得分:0)

$sql = "SELECT date, email, journal, section FROM selection_loggedin WHERE email = '$email' and date in (SELECT max(date) FROM (SELECT date, email FROM selection_loggedin WHERE email = '$email') as x)";
$result = $dbc->query($sql);

if ($result->num_rows > 0) { 

while($row = $result->fetch_assoc()) {
    $journal = $row['journal'];
    $section = $row['section'];
    print_r($row);
    //echo "'$journal'"."'$section'";
    echo "<br>".$row['email']."<br>";
    echo $row['date']."<br>";