如何写mysqli_result

时间:2013-12-19 10:12:59

标签: php html mysql

如何在最后一行设置mysqli_result?

if(isset($_POST['thename']) === true && empty($_POST['thename']) === false) {
    $getVal = mysqli_real_escape_string($cutConn_db, trim($_POST['thename']));

    require '../db/cb_bz.php';
    $query = mysql_query("
    SELECT 'photos'.'theurl' FROM 'names' WHERE 'names'.'thename'".$getVal."'");
    $resultA = mysqli_query($cutConn_db, $query);
    $rowz = mysqli_fetch_row($resultA);
    $tota_rowz = $rowz[0];

    echo($tota_rowz !== 0) ? mysqli_result($query, 0, 'theurl') : 'Not found.';
}

1 个答案:

答案 0 :(得分:-1)

$query = "SELECT 'photos'.'theurl' FROM 'names' WHERE 'names'.'thename'".$getVal."'";
$resultA = mysqli_query($cutConn_db, $query);

就够了。

我认为你需要mysqli_num_rows 如果收到结果,可以通过$rowCount = mysqli_num_rows($resultA);查看。 不仅仅是:

while ($row = mysqli_fetch_row($resultA)) {
    printf ("%s \n", $row[0]);
}