So im building a fast food website i have built most of it apart from displaying the menu this will be different for each take away which is signed up. I have worked out that im gonna have categories and items so the take away can have a categories called "trays" then 5 items inside that categories with all the different trays they do then they can make another categorie for another block of food and so on. Problem i have is i will need to print out the categories and the items. I have 1 table called categories then another called topics the items will be stored in the topic table and categories in categories so would need to display it like so
categorie
topic
topic
topic
over and over.
Here is my html
<div class="menu-widget" id="2">
<div class="widget-heading">
<h3 class="widget-title text-dark">
POPULAR ORDERS Delicious hot food!
<a class="btn btn-link pull-right" data-toggle="collapse" href="#popular2" aria-expanded="true">
<i class="fa fa-angle-right pull-right"></i>
<i class="fa fa-angle-down pull-right"></i>
</a>
</h3>
<div class="clearfix"></div>
</div>
<div class="collapse in" id="popular2">
<div class="food-item">
<div class="row">
<div class="col-xs-12 col-sm-12 col-lg-8">
<div class="rest-logo pull-left">
<a class="restaurant-logo pull-left" href="#"><img src="http://placehold.it/100x80" alt="Food logo"></a>
</div>
<!-- end:Logo -->
<?php echo "food inside";?>
<div class="rest-descr">
<h6>Veg Extravaganza</h6>
<p> Burgers, American, Sandwiches, Fast Food, BBQ</p>
</div>
<!-- end:Description -->
</div>
<!-- end:col -->
<div class="col-xs-12 col-sm-12 col-lg-4 pull-right item-cart-info"> <span class="price pull-left">$ 19.99</span> + </div>
</div>
<!-- end:row -->
</div>
<!-- end:Food item --><!-- end:Food item --><!-- end:Food item -->
<div class="food-item white"><!-- end:row -->
</div>
<!-- end:Food item -->
</div>
<!-- end:Collapse -->
</div>
<!-- end:Widget menu -->
and here is my code
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-6"><!-- end:Widget menu -->
<?php
///first select the category based on $_GET['cat_id']
$sql = "SELECT * FROM categories WHERE takeawayid =' ".$id1."'";
$result = mysql_query($sql);
if(!$result)
{
echo 'The category could not be displayed, please try again later.' . mysql_error();
}
else
{
if(mysql_num_rows($result) == 0)
{
echo 'This category does not exist.';
}
else
{
//display category data
while($row = mysql_fetch_assoc($result))
{
?>
<div class="menu-widget" id="2">
<div class="widget-heading">
<h3 class="widget-title text-dark">
<?php echo $row['cat_name'] ; ?> <a class="btn btn-link pull-right" data-toggle="collapse" href="#popular2" aria-expanded="true">
<i class="fa fa-angle-right pull-right"></i>
<i class="fa fa-angle-down pull-right"></i>
</a>
</h3>
<div class="clearfix"></div>
<?php
//do a query for the topics
$sql2 = "SELECT * FROM topics WHERE topic_cat =' ".$row['cat_id']."'";
$result2 = mysql_query($sql2);
}
echo $row2['topic_subject'] ;
if(!$result2)
{
echo 'The topics could not be displayed, please try again later.';
}
else
{
if(mysql_num_rows($result2) == 0)
{
echo 'There are no topics in this category yet.';
}
else
{
//prepare the table
while($row2 = mysql_fetch_assoc($result2))
{
?>
<div class="collapse in" id="popular2">
<div class="food-item">
<div class="row">
<div class="col-xs-12 col-sm-12 col-lg-8">
<div class="rest-logo pull-left">
<a class="restaurant-logo pull-left" href="#"><img src="http://sdfsdf.com/beta/restaurants/<?php echo $id33 ;?>.png" alt="Food logo"></a>
</div>
<!-- end:Logo -->
<div class="rest-descr">
<h6><?php echo $row2['topic_subject'] ;?></h6>
<p> Burgers, American, Sandwiches, Fast Food, BBQ</p>
</div>
<!-- end:Description -->
</div>
<!-- end:col -->
<div class="col-xs-12 col-sm-12 col-lg-4 pull-right item-cart-info"> <span class="price pull-left">$ 19.99</span> + </div>
</div>
<!-- end:row -->
</div>
<!-- end:Food item --><!-- end:Food item --><!-- end:Food item -->
<div class="food-item white"><!-- end:row -->
</div>
<!-- end:Food item -->
</div>
<!-- end:Collapse -->
</div>
</div>
<?php
}
}
}
}
}
?>
<!-- end:Widget menu -->
Code works but when i add more than 1 result im getting this
http://prntscr.com/fu3qll
Here is 1 cat and 2 topics in side it
https://prnt.sc/fu3g2j
works great but when i add 2 cats and 4 topics 2 inside each one i get above the fu3kbk link
so i fixed it by moving the bracket down on
$result2 = mysql_query($sql2);
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-6"><!-- end:Widget menu -->
<?php
///first select the category based on $_GET['cat_id']
$sql = "SELECT * FROM categories WHERE takeawayid =' ".$id1."'";
$result = mysql_query($sql);
if(!$result)
{
echo 'The category could not be displayed, please try again later.' . mysql_error();
}
else
{
if(mysql_num_rows($result) == 0)
{
echo 'This category does not exist.';
}
else
{
//display category data
while($row = mysql_fetch_assoc($result))
{
?>
<div class="menu-widget" id="2">
<div class="widget-heading">
<h3 class="widget-title text-dark">
<?php echo $row['cat_name'] ; ?> <a class="btn btn-link pull-right" data-toggle="collapse" href="#popular2" aria-expanded="true">
<i class="fa fa-angle-right pull-right"></i>
<i class="fa fa-angle-down pull-right"></i>
</a>
</h3>
<div class="clearfix"></div>
</div>
<?php
//do a query for the topics
$sql2 = "SELECT * FROM topics WHERE topic_cat =' ".$row['cat_id']."'";
$result2 = mysql_query($sql2);
if(!$result2)
{
echo 'The topics could not be displayed, please try again later.';
}
else
{
if(mysql_num_rows($result2) == 0)
{
echo 'There are no topics in this category yet.';
}
else
{
//prepare the table
while($row2 = mysql_fetch_assoc($result2))
{
?>
<div class="collapse in" id="popular2">
<div class="food-item">
<div class="row">
<div class="col-xs-12 col-sm-12 col-lg-8">
<div class="rest-logo pull-left">
<a class="restaurant-logo pull-left" href="#"><img src="http://geatzo.com/beta/restaurants/<?php echo $id33 ;?>.png" alt="Food logo"></a>
</div>
<!-- end:Logo -->
<div class="rest-descr">
<h6><?php echo $row2['topic_subject'] ;?></h6>
<p> Burgers, American, Sandwiches, Fast Food, BBQ</p>
</div>
<!-- end:Description -->
</div>
<!-- end:col -->
<div class="col-xs-12 col-sm-12 col-lg-4 pull-right item-cart-info"> <span class="price pull-left">$ 0</span> + </div>
</div>
<!-- end:row -->
</div>
<!-- end:Food item --><!-- end:Food item --><!-- end:Food item -->
<!-- end:Food item -->
</div>
<!-- end:Collapse -->
<?php
}
}
}
}
}
}
?>
</div>
</div>
<!-- end:Widget menu -->
Related
Hi everyone I'm niubbie in php.I have a problem with tab. I would like the tabs on their click to show a different topic. All this using php and calling the db.
My DB:
giorno
pranzo
cena
lunedi
12:00
20:00
martedi
12:00
20:00
mercoledi
12:00
20:00
giovedi
12:00
20:00
venerdi
12:00
20:00
Days are represented by tabs and when I click on a different day I want it to show lunch and dinner of that particular day.
My code:
<section class="big-section bg-light-gray border-top border-color-medium-gray wow animate__fadeIn">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12 text-center margin-six-bottom">
<h6 class="alt-font text-extra-dark-gray font-weight-500">Orari</h6>
</div>
</div>
<div class="row justify-content-center">
<div class="col-12 col-lg-10 tab-style-05">
<div class="tab-box">
<!-- start tab navigation -->
<ul class="nav nav-tabs margin-7-rem-bottom md-margin-5-rem-bottom xs-margin-15px-lr align-items-center justify-content-center font-weight-500 text-uppercase">
<?php
$sql = "SELECT * FROM orari_ristorante ";
$risultato = mysql_query($sql) or die(mysql_error()."<br>Impossibile eseguire l'interrogazione");
$i=0;
while ($riga = mysql_fetch_assoc($risultato)){
?>
<?php if($i == 0){?>
<li class="nav-item alt-font"><a class="nav-link active" href="#tab-nine1" data-toggle="tab"><?php echo $riga['giorno'];?></a></li>
<?php }else{?>
<li class="nav-item alt-font"><a class="nav-link" href="#tab-nine1" data-toggle="tab"><?php echo $riga['giorno'];?></a></li>
<?php }
$i++;
}?>
</ul>
<!-- end tab navigation -->
</div>
<div class="tab-content">
<!-- start tab content -->
<div class="tab-pane med-text fade in active show" id="tab-nine1">
<div class="panel-group accordion-event accordion-style-04" id="accordion1" data-active-icon="icon-feather-minus" data-inactive-icon="icon-feather-plus">
<!-- start accordion item -->
<div class="panel border-color-black-transparent">
<div class="panel-heading">
<?php
$sql = "SELECT pranzo,cena FROM orari_ristorante LIMIT 1";
$risultato = mysql_query($sql) or die(mysql_error()."<br>Impossibile eseguire l'interrogazione");
while ($riga = mysql_fetch_assoc($risultato)){
?>
<span class="panel-time">Pranzo</span>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1">
<div class="panel-title">
<span class="text-extra-dark-gray d-inline-block font-weight-500"><?php echo $riga['pranzo'] ;?></span>
</div>
</a>
<span class='prenota'>PRENOTA</span>
<span class="panel-time">Cena</span>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1">
<div class="panel-title">
<span class="text-extra-dark-gray d-inline-block font-weight-500"><?php echo $riga['cena'] ;?></span>
</div>
</a>
<span class='prenota'>PRENOTA</span>
<?php
}
?>
</div>
</div>
</div>
</div>
<!-- end tab content -->
</div>
</div>
</div>
</div>
</section>
My problem is that each tab shows all the rows and not the specific one for that day
My Problem
You need to ensure you are using unique ID's for your contents and using them in your href of the tab.
Reading your code it looks like each tab is created with the same ID
<li class="nav-item alt-font"><a class="nav-link active" href="#tab-nine1" data-toggle="tab"><?php echo $riga['giorno'];?></a></li>
I would echo out the unique id from the database eg.
href="#tab-<?echo $riga['id'];?>" (or whatever your unique column header is)
Ensure you also echo this out further down when the tab content is being created.
Based on what you are trying to accomplish, if you limit your results to one, you will always only show the first day in the db. Here's how I would change your second while loop.
<?php
$sql = "SELECT * FROM orari_ristorante";
$risultato = mysqli_query($conn, $sql);
$i = 0;
while ($riga = mysqli_fetch_assoc($risultato)){
if($i == 0){
$css = ""
}else{
$css = "display:none"
}
?>
<div class="giorno_tab <?php echo $riga['giorno'] ;?>" style="<?php echo $css ;?>">;
<span class="panel-time">Pranzo</span>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1">
<div class="panel-title">
<span class="text-extra-dark-gray d-inline-block font-weight-500"><?php echo $riga['pranzo'] ;?></span>
</div>
</a>
<span class='prenota'>PRENOTA</span>
<span class="panel-time">Cena</span>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1">
<div class="panel-title">
<span class="text-extra-dark-gray d-inline-block font-weight-500"><?php echo $riga['cena'] ;?></span>
</div>
</a>
<span class='prenota'>PRENOTA</span>
</div>
<?php
$i++;}
?>
</div>
It is not the solution, however you can build on top of that to accomplish what you are trying to do. Hopefully that somewhat helps.
Just to explain, I was adding $riga["giorno"] as an kind of ID in the class, however Revbo's answer would give a clearer code when it comes to an ID
enter image description here
I'm trying to make a dashboard
When placing small boxes in the board
The boxes that are in the new row go outside the bounds of the page
The boxes in the first row appear correctly, but the problem starts when they go down to the second and third row, and so on.....
How can I solve this problem please?`
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<?php
$stmt = $conn->prepare("SELECT * FROM ticket_prices ");
$stmt->execute();
$total = 0;
foreach ($stmt as $srow) {
$subtotal = $srow['TicketPrice'];
$total += $subtotal;
}
echo "<h3>" . $total, 2 . " AED</h3>";
?>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<?php
$stmt = $conn->prepare("SELECT * FROM ticket_prices ");
$stmt->execute();
$total = 0;
foreach ($stmt as $srow) {
$subtotal = $srow['TicketPrice'];
$total += $subtotal;
}
echo "<h3>" . $total, 2 . " AED</h3>";
?>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<?php
$stmt = $conn->prepare("SELECT * FROM ticket_prices ");
$stmt->execute();
$total = 0;
foreach ($stmt as $srow) {
$subtotal = $srow['TicketPrice'];
$total += $subtotal;
}
echo "<h3>" . $total, 2 . " AED</h3>";
?>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<?php
$stmt = $conn->prepare("SELECT * FROM ticket_prices ");
$stmt->execute();
$total = 0;
foreach ($stmt as $srow) {
$subtotal = $srow['TicketPrice'];
$total += $subtotal;
}
echo "<h3>" . $total, 2 . " AED</h3>";
?>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<?php
$stmt = $conn->prepare("SELECT * FROM ticket_prices ");
$stmt->execute();
$total = 0;
foreach ($stmt as $srow) {
$subtotal = $srow['TicketPrice'];
$total += $subtotal;
}
echo "<h3>" . $total, 2 . " AED</h3>";
?>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
</section>`
Your HTML structure is wrong. You can see it clearly in sublime or vs code or any of the html editor.
Assuming that you are going to Loop either the 'Box' or the 'Row of 4 Boxes', I have re-structured the HTML without the "PHP" code.
Looping Option 1 :
Look for <!-- Looping Option 1 -->, You can loop the boxes from here.
Looping Option 2 :
Look for <!-- Looping Option 2 -->, You can loop the row of 4 boxes from here.
<section>
<div class="container">
<!-- Lopping option 2 -->
<div class="row">
<!-- Lopping option 1 -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<h3></h3>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<!-- Lopping option 1 -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<h3></h3>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<h3></h3>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-hc">
<div class="inner text-hc">
<h3></h3>
<p>Total Sales from products</p>
</div>
<div class="icon">
<i class="fa fa-shopping-cart"></i>
</div>
<a href="../booking/index.php" class="small-box-footer">More info <i
class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
</div>
<!-- Lopping option 2 -->
</div>
</section>
I need to display a "count" of records (rows) in my SQLtable "doctors". This count must appear on my dashboard page in the below element for total number of doctors
This is index.php for my dashboard page
<?php
$con = mysqli_connect("localhost","root","","hospital_db");
$result = mysqli_query($con,"SELECT * FROM doctors");
$rows = mysqli_num_rows($result);
$content = '<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-aqua">
<div class="inner">
<h3><?php echo '.$rows.';?></h3>
<p>Doctors</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
View Doctors <i class="fa fa-arrow-circle-right"></i>
</div>
</div>
<!-- ./col -->
</div>';
include('../master.php');
?>
You should use mysqli object in new php version try the following code
Make connection first like
<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");
$result = mysqli_query($con,"SELECT * FROM doctors");
$rows = mysqli_num_rows($result);
echo "There are " . $rows . " rows in my table.";
$content = '<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-aqua">
<div class="inner">
*<h3><?php echo "$rows"; } ?></h3>*
<p>Doctors</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
View Doctors <i class="fa fa-arrow-circle-right"></i>
</div>
</div>
<!-- ./col -->
</div>';
include('../master.php');
?>
if you just need the count then why don't you use the aggregate function count(*) in your query. this much better helps you. and in your code in h3 tag you can concat the string directly rather than using again php code. this might looks better and in structured form.
try this:
<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");
$result = mysqli_query($con,"SELECT count(*) as total_rows FROM doctors");
$rows = $result->total_rows;
echo "There are " . $rows . " rows in my table.";
$content = '<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-aqua">
<div class="inner">
*<h3>'.$rows.'</h3>*
<p>Doctors</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
View Doctors <i class="fa fa-arrow-circle-right"></i>
</div>
</div>
<!-- ./col -->
</div>';
include('../master.php');
?>
How can i add another user to its right, when i limit it to 5 it goes down not to the right im pretty stuck here how can i align it, i dont know the term or what you call that thing thanks in advance
<h2>Recently Added</h2>
<?php
include_once('connection.php');
$sql = "SELECT * FROM tblstdpro
ORDER BY StdID DESC LIMIT 0, 5";
$result = mysqli_query($conn,$sql);
$count = 0;
while($row = mysqli_fetch_array($result)){
$StudentID="<a href='ProfileRecords.php?id=".$row['StdID']."'>".$row['StdID']."</a>";
$StdName="<a href='ProfileRecords.php?id=".$row['StdID']."'>" . $row['Fname'] . ' ' . $row['Lname'] . "</a>";
?>
<div class="col-md-6">
<!-- USERS LIST -->
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title">Latest Members</h3>
<div class="box-tools pull-right">
<span class="label label-danger"> New Members</span>
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
<button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div><!-- /.box-header -->
<div class="box-body no-padding">
<ul class="users-list clearfix">
<li>
<img src="<?php echo $row['StdImage'];?>" alt="User Image">
<a class="users-list-name" href="#"><?php echo "$StdName" ?></a>
<span class="users-list-date"><?php echo "$StudentID" ?></span>
<?php } ?>
<div class="box-footer text-center">
View All Users
</div><!-- /.box-footer -->
</div><!--/.box -->
</div><!-- /.col -->
</div><!-- /.row -->
I want to print half of the table record in left accordion and remaining half record in right div. I am using the following code. I ahve two column in the table. In which i have record. Example if there are 4 records in the table than first two record should go on left accordion and next two records should go on right side accordion. I am using the following code.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "data";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, price FROM demo";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
print_r($row);
}
} else {
echo "0 results";
}
$conn->close();
?>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
<div class="ordinary">
<div class="container">
<div class="row main-row">
<!--left-->
<div class="col-md-6">
<div class="col-inner left-col">
<div class="accordion-group" id="accordion">
<div class="accordion-panel" >
<div class="heading glyphicon-custom">
<h4 class="title left-title">
<a class="accordion-toggle title-font" data-toggle="collapse" data-parent="#accordion" href="#panel1"><i class="glyphicon glyphicon-plus gly-font "></i><span class="title-panel">Antipasti</span></a>
</h4>
</div>
<div id="panel1" class="panel-collapse collapse">
<div class="contain-body">
<div class="su-spoiler-content su-clearfix inner-content">
1
</div>
</div>
</div>
</div>
</div>
</div>
<!--make it 50% -->
<div class="col-inner left-col">
<div class="accordion-group" id="accordion">
<div class="accordion-panel" >
<div class="heading glyphicon-custom">
<h4 class="title left-title">
<a class="accordion-toggle title-font" data-toggle="collapse" data-parent="#accordion" href="#panel2"><i class="glyphicon glyphicon-plus gly-font "></i><span class="title-panel">Antipasti</span></a>
</h4>
</div>
<div id="panel2" class="panel-collapse collapse">
<div class="contain-body">
<div class="su-spoiler-content su-clearfix inner-content">
2
</div>
</div>
</div>
</div>
</div>
</div>
</div> <!-- left-col-md-6 ends here -->
<div class="col-md-6 ">
<div class="col-inner right-all">
<div class="accordion-group" id="accordion">
<div class="accordion-panel" >
<div class="heading glyphicon-custom">
<h4 class="title">
<a class="accordion-toggle title-font" data-toggle="collapse" data-parent="#accordion" href="#panel3"><i class="glyphicon glyphicon-plus gly-font "></i><span class="title-panel">Antipasti</span></a>
</h4>
</div>
<div id="panel3" class="panel-collapse collapse">
<div class="contain-body">
<div class="su-spoiler-content su-clearfix inner-right">
3
</div>
</div>
</div>
</div>
</div>
</div>
<!-- accordian -->
<div class="col-inner right-all">
<div class="accordion-group" id="accordion">
<div class="accordion-panel" >
<div class="heading glyphicon-custom">
<h4 class="title">
<a class="accordion-toggle title-font" data-toggle="collapse" data-parent="#accordion" href="#panel4"><i class="glyphicon glyphicon-plus gly-font "></i><span class="title-panel">Antipasti</span></a>
</h4>
</div>
<div id="panel4" class="panel-collapse collapse">
<div class="contain-body">
<div class="su-spoiler-content su-clearfix inner-right">
4
</div>
</div>
</div>
</div>
</div>
</div>
<br/>
</div> <!-- right-col-md-6 ends here -->
</div>
</div>
</div>
<script type="text/javascript">
var selectIds =$('#panel1,#panel2,#panel3,#panel4');
$(function ($) {
selectIds.on('hidden.bs.collapse show.bs.collapse', function () {
$(this).prev().find('.glyphicon').toggleClass('glyphicon-plus glyphicon-minus');
})
});
</script>
</body>
Try this:
<?php
while($row = fetch_row($result)){
$rows[]=$row;
}
?>
Inside left accordion
<?php
for($i=0;$i < count($rows)/2;$i++){
echo $row[$i]['id']; //or whatever you want
}
?>
Inside right accordion
<?php
for($i=count($rows)/2;$i < count($rows); $i++){
echo $row[$i]['id']; //or whatever you want
}
?>