'SQL Smarty template not to list category
Category in the database as in the picture
<?php
$sql = "SELECT * FROM pm_categories ORDER BY name ASC";
$result_t = mysql_query($sql) OR die(mysql_error());
while($row = mysql_fetch_assoc($result_t))
{
$data[] = $row;
}
$smarty->assign('data', $data);
?>
The above code list all the categories by name in the database. What I want is to list one by one by Id, how can I do that?
Solution 1:[1]
$sql = "SELECT * FROM pm_categories ORDER BY name ASC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
//output data of each row
while($row = $result->fetch_assoc()) {
echo $row["table_field"]; // Name is the field of pm_categories table
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RAKHIL P |

