Display SQL query results

ukalaboy

New Member
I am having trouble displaying results from a SQL query. I am trying to display all images and prices from a products table. I am able to display the echo statement "Query works" in the browser. But, the results are not displaying in the browser.\[code\] if ($count > 0) { echo "Query works"; } else { echo "Query doesn't work" ."<br/>"; }\[/code\]PHP Code:\[code\]$con = getConnection(); $sqlQuery = "SELECT * from Products"; // Execute Query ----------------------------- $result = mysqli_query($con, $sqlQuery); if(!$result) { echo "Cannot do query" . "<br/>"; exit; } $row = mysqli_fetch_row($result); $count = $row[0]; if ($count > 0) { echo "Query works"; } else { echo "Query doesn't work" ."<br/>"; } // Display Results ----------------------------- $num_results = $result->numRows(); for ($i=0; $i<$num_results; $i++) { $row = $result->fetchRow(MDB2_FETCH_ASSOC); echo '<img src="'.$row['Image'].'>'; echo "<br/>" . "Price: " . stripslashes($row['Price']);\[/code\]}Screenshot 1
3qbi6.png
Screenshot 2: removed the images from the database, and used a filepath instead
gyoYf.png
Screenshot 3: print_r($row)
JvFrx.png
 
Back
Top