PHP kullanarak satırları dönen Sorunu

2 Cevap php
<?php

if (isset($_GET['flyerID']))
    $FlyerID = $_GET['flyerID'];

$DBConnect = @mysqli_connect("host", "UN", "pword")

    Or die("<p>Unable to connect to the datbase server.</p>" . "<p>Error Code ".mysqli_connect_errno().": ".mysqli_connect_error()) . "</p>";

$DBName = "agentsleuthdb";

@mysqli_select_db($DBConnect, $DBName)

    Or die("<p>Unable to select the database.</p>" . "<p>Error Code " . mysqli_errno($DBConnect) . ": " . mysqli_error($DBConnect)) ."</p>";

    $TableName = "FEEDBACK";

    $SQLstring = "SELECT * FROM $TableName order by FIRSTNAME";

    $QueryResult = @mysqli_query ($DBConnect, $SQLstring)

    Or die("<p> Unable to exequte Select query.</p>"."<p>Error Code ".mysqli_errno($DBConnect) .": ".mysqli_error

($DBConnect))."</p>";

    if (mysqli_num_rows($QueryResult) == 0){

    	exit("<p>There is no feedback</p>");
}

?>


    		<table border="1">
    			<tr>
    				<th width = "15%">First Name </th>
    				<th width = "15%">Last Name </th>
    				<th width = "15%">Email Addr </th>
    				<th width = "15%">Company </th>
    				<th width = "40%">Feedback </th>

    			</tr>


<?php
    $Row = mysqli_fetch_row($QueryResult);

do {
    echo "<tr><td>{$Row[0]}</td>";
    echo "<td>{$Row[1]}</td>";
    echo "<td>{$Row[2]}</td>";
    echo "<td>{$Row[3]}</td>";
    echo "<td>{$Row[4]}</td></tr>";
    $Row = mysqli_fetch_assoc($QueryResult);
} while ($Row);
mysqli_free_result($QueryResult);
mysqli_close($DBConnect);
?>

Sadece nasıl tüm girişleri dönebilirsiniz .. bir satır döndürür?

2 Cevap

Denedin

while ($Row = mysqli_fetch_row($QueryResult))

Açıklama here

veya

while ($Row = mysqli_fetch_array($QueryResult, MYSQL_ASSOC))

Açıklama here

Umarım bu yardımcı olur.

In your code, only the first time you call mysqli_fetch_row, which makes an $Row an indexed array. This is why you see output when you access the content of $Row with an index ($Row[0], $Row[1], etc..). Afterwards, you mysqli_fetch_assoc which turns $Row in an associative array, thus accessing $Row with an index for your output doesn't work anymore.

Önerilen aforloney ilk while döngü tarafından do ... while döngü değiştirin.