adi5402 wrote:doesent the argument in the fetch funchtion have to pass the query.
I tried changeing it but no luck.
As Frozenlight777 said, you have used the same variable name, $statusList,
twice for 2 different things: once for the results from the query, then later in your while loop for the value in one field ('status'), thus overwriting the variable and causing the next execution of the loop to have an invalid reference to the query results.
This is a good reason to use standard variable names, such as:
Code: Select all
$sql = 'SELECT *'
. ' FROM `status` ';
$result = mysql_query($sql) or die(mysql_error());
$rowTest =mysql_num_rows($result);
echo $rowTest;
$statusCount =0;
while($row =mysql_fetch_array($result)) {
$statusCount++;
$statusList = $row['status'];
echo $statusList;
}
I assume you're doing this as a learning exercise, because there would be no reason to actually count rows this way, when you already have the number of rows from the php function. I also used the more convenient notation to increment the $statusCount variable.