Click here to Skip to main content
15,742,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<?php
include 'openCon.php' ;

$sql = "SELECT id,price,table,unitTable,chair,unitChair,lightingFan,unitLightingFan,Decoration, unitDecoration FROM packagea";
$result = mysqli_query($conn,$sql) ;
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result))
{
$id = $row['id'];
$price = $row['price'];
$table = $row['table'];
$unitTable = $row['unitTable'];
$chair = $row['chair'];
$unitChair = $row['unitChair'];
$lightingFan = $row['lightingFan'];
$unitLightingFan = $row['unitLightingFan'];
$Decoration = $row['Decoration'];
$unitDecoration = $row['unitDecoration'];


echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";



}


}
?>
Bil Price Table Unit Chair Unit Lighting & Fan Unit Decoration Unit
$id$price$table$unitTable$Chair$unitChair$lightingFan$unitLightingFan$Decoration$unitDecoration


->I HAVE PROBLEM AT THIS LINE = if(mysqli_num_rows($result) > 0) {

What I have tried:

I HAVE TRY GOOGLE FOR THE SOLUTION BUT EVERYTHING I TRY IT DOESNT FIX MY ERROR
Posted
Updated 19-Jun-18 23:47pm
Comments
Richard MacCutchan 20-Jun-18 6:15am    
The first thing you should try (which you obviously didn't) is to read the documentation, where it clearly explains what type of result you get from each command.

1 solution

This a FAQ (Frequentyl Asked Question) which has been asked and answered multiple times and can be also solved by reading the documentation:

Return Values

Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.
You have to check the return value of mysqli_query() as shown in the examples at the above link before passing it to other functions like mysqli_num_rows().

Upon failures report the error message to know what went wrong. Usual errors sources are invalid SQL commands and the message provided by mysqli_error($conn) will tell you what was wrong. Because I don't know about your database, I can only guess. Here it might be a typo in one of the column names or the table name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900