Reputation: 1
I want to display the countNum in the txt box but it display nothing.
i do something like this.
<input type="text" value="<?php $countNum; ?>" disabled = "disabled">
<?php
$countNum = "";
$Q = mysql_query("select * from blotterreport");
while ($row = mysql_fetch_array($Q)) {
echo "<tr onclick='trClick()'>";
echo "<td>" . $row["entrynumber"] . "</td>";
echo "<td>" . $row["natureofcase"] . "</td>";
echo "<td>" . $row["month"] . " " . $row["day"] . " " . $row["year"] . "</td>";
echo "<td>" . $row["subject"] . "</td>";
echo "</tr>";
$countNum++;
}
echo $countNum;
?>
Upvotes: 0
Views: 34
Reputation: 2713
Should use $countNum = mysql_num_rows($Q);
before input
text field.
<?php
$Q = mysql_query("select * from blotterreport");
$countNum = mysql_num_rows($Q);
?>
<input type="text" value="<?php echo $countNum; ?>" disabled = "disabled">
<?php
while ($row = mysql_fetch_array($Q)) {
echo "<tr onclick='trClick()'>";
echo "<td>" . $row["entrynumber"] . "</td>";
echo "<td>" . $row["natureofcase"] . "</td>";
echo "<td>" . $row["month"] . " " . $row["day"] . " " . $row["year"] . "</td>";
echo "<td>" . $row["subject"] . "</td>";
echo "</tr>";
}
?>
Note : Please avoid mysql_*
function because mysql_*
function has been deleted permanently from PHP 7. Please use mysqli_
or PDO
.
For PDO : http://php.net/manual/en/book.pdo.php
For Mysqli : http://php.net/manual/en/mysqli.examples-basic.php
Upvotes: 1