Code: Select all
while ($row = mysqli_fetch_assoc($result))
{
extract($row);
}
Moderator: General Moderators
Code: Select all
while ($row = mysqli_fetch_assoc($result))
{
extract($row);
}
Code: Select all
while ($row = mysqli_fetch_assoc($result)){
$yourArrayData[] = $row; // Read row into new array
}Code: Select all
foreach($yourArrayData as $row){
print $row['tableFieldName']; // Print field from the table row.
}Code: Select all
while ($row = mysqli_fetch_assoc($result)){
$yourArrayData[] = $row; // Read row into new array
}
Code: Select all
foreach($yourArrayData as $row){
print $row['tableFieldName']; // Print field from the table row.
}
Code: Select all
`id` `name`
1 Jim
2 Joe
3 JohnCode: Select all
$yourArrayData = array(
array("id" => 1, "name" => "Jim"),
array("id" => 2, "name" => "Joe"),
array("id" => 3, "name" => "John")
);Code: Select all
foreach($yourArrayData as $row){ // $row in this case, refer's to the current row of data inside the $yourArrayData array.
print "ID: ".$row['id']." - Name: ".$row['name']; // Print field from the table row.
}Code: Select all
// Grab each row
while ($row = mysqli_fetch_assoc($result))
{
extract($row);
}
?>
<!-- Menu -->
<div id="menu-container">
<div id="menu">
<ul>
<!--
replace # with link based on $categories_id and Main with $categories_name
-->
<li><a href="#" class="top_parent">Main</a>
<ul>
<li><a href="#" class="parent">Sub</a>
<ul>
<li><a href="#">Sub 2</a></li>
<li><a href="#">Sub 2</a></li>
<li><a href="#">Sub 2</a></li>
<li><a href="#">Sub 2</a></li>
</ul>
</li>
</div> <!-- end the menuh-container div -->
</div> <!-- end the menuh div -->
Code: Select all
<?php
while ($categoryData = mysqli_fetch_assoc($result)){
$categoryArray [] = $categoryData; // Read row into new array
}
?>
// blah with the rest of the code up till you print the data out.
<li><a href="#" class="parent">Sub</a>
<ul>
<?php foreach($categoryArray as $category){ // for each category entered in the category array
print "<li><a href='#{$category['id']}'>{$category['name']}</a></li>"; // print out a new line per category.
} ?>
</ul>
</li>