this is the controller method
public function ajaxLoad()
{
$data['query'] = $this->db->query("SELECT * FROM items ORDER BY id DESC");
$data['content'] = $this->load->view('item', $data, true);
$data = json_encode($data);
echo $data;
}
and this is the js that invokes ajax
var tempScrollTop, currentScrollTop = 0;
$(document).scroll(function(){
currentScrollTop = $(document).scrollTop();
if (tempScrollTop < currentScrollTop )
{
var result = currentScrollTop % 100;
if(result == 0)
{
$.ajax({
url: "ajax/load",
type: "POST",
success: function(res){
$("#content").html(res);
}
});
}
}
else if (tempScrollTop > currentScrollTop )
{
var result = currentScrollTop % 100;
if(result == 0)
{
$("#content").text("Вверх запрос " + result);
}
}
tempScrollTop = currentScrollTop;
})
the problem i that i can't get the part of a page with the query that goes in the content and then json_encode to transfer to javascript, if i remove the
$data['query'] = $this->db->query("SELECT * FROM items ORDER BY id DESC");
and change this to
$data['content'] = $this->load->view('item', null, true);
thus without the $data object its ok.
then its comes empty, but i need the database rows to display in the content
how can i solve this problem??
and the echo $data; - its the only way to transfer the data to js??, i tried return $data;, but that doesn't work :(
and also the main problem is that the PHP generates the page with the foreach function that generates records by loop, but if i put one of those records with ajax will the variables inside that partial become values of the database query??, or i need to set the values with js??
i am confused about that, sorry if i am wrong, can you help me???
so this is how looks the page generated by php by when the pages loads:
<? $i = 1 ?>
<? foreach($query->result() as $q): ?>
<?
$milliseconds = $q->end;
//echo $dd;
//echo time();
/*
$year = date('y', $t);
$month = date('m', $t);
$day = date('d', $t);
$hour = date('h', $t);
$minute = date('i', $t);
$second = date('s', $t);
*/
$d = new Datecalc;
$begin = date("Y-m-d H:i:s");
$end = date($q->end);
#$date = $d->dateDiff($begin , $end);
//$begin = strtotime($begin);
//$end = strtotime($q->end);
$d->dateDiff($begin, $end);
//echo $d->day;
$desc = substr($q->desc, 0, 225);
if(strlen($desc) > 180)
{
$desc = $desc."...";
}
?>
<input type="hidden" value="<?= $milliseconds ?>" id="milliseconds_<?= $q->id ?>" />
<div class="item" id="item_<?= $q->id ?>">
<? if(!empty($_SESSION['role']) && $_SESSION['role'] == 'admin'): ?>
<div class="admin_delete">
<?= img('css/img/admin_delete.png'); ?>
</div>
<? endif; ?>
<div class="desc">
<span class="discount">Скидка <?= $q->discount ?>%</span>
<span class="desc"><?= $desc ?></span>
</div>
<div class="item_pic">
<? $attr = array('src' => $q->image,
'id' => 'item_pic',
'class' => 'item_pic') ?>
<?= img($attr) ?>
</div>
<div class="menu_3">
<ul class="menu_3">
<li class="timer">
<? $attr = array('src' => 'css/img/time.png',
'class' => 'time') ?>
<?= img($attr) ?>
<span id="days_<?= $q->id?>"><?= $d->day ?></span>д.
<span id="hours_<?= $q->id?>"><?= $d->hour ?></span> :
<span id="minutes_<?= $q->id?>"><?= $d->min ?></span> :
<span id="seconds_<?= $q->id?>"><?= $d->sec ?></span>
</li>
<li class="price">
<?= $q->price ?>с.
</li>
<li class="buy">
<div class="small">
99
</div>
<a href="<?= base_url() ?>buy/<?= $q->id ?>">
<?= img('css/img/kupit.png') ?>
</li>
<li class="item_arrow">
<?= img('css/img/item_arrow.png') ?>
<? if($i % 2 == 0): ?>
<ul class="submenu2">
<? else: ?>
<ul class="submenu2">
<? endif; ?>
<li>
<a href="<?= base_url() ?>show/<?= $q->id ?>">
Подробнее
</a>
</li>
<li>
Как это работает
</li>
<li style="border-bottom: none;">
Рассказать друзьям
</li>
<li style="border-bottom: none;">
<?= img('css/img/namba.png') ?>
<?= img('css/img/mail_ru.png') ?>
<?= img('css/img/odnoklassniki.png') ?>
<?= img('css/img/vkontakte.png') ?>
<?= img('css/img/facebook.png') ?>
</li>
</ul>
</li>
</ul>
</div>
</div>
<? $i++; ?>
<? endforeach; ?>
<div class="clear"></div>
i dont know how to put the records by ajax separately gradualy when the user scrolls down
Try rewriting these two lines
$data['query'] = $this->db->query("SELECT * FROM items ORDER BY id DESC");
$data['content'] = $this->load->view('item', $data, true);
as
$db_data['query'] = $this->db->query("SELECT * FROM items ORDER BY id DESC");
$data['content'] = $this->load->view('item', $db_data, true);
As it is, you are sending, as part of the JSON output, the query response from the DB (in the $data array). Then replace the last two lines with
echo json_encode($data);
Related
I have a foreach loop, and in that I have a more information button. I want it so that when x == 0 then the display to that more information button is 'none'
This is the variable that is different in each foreach item.
$issuesFixedCount
This is the class that needs to be display none if the variable == 0.
<a href="<?='version/?version=' . $item->name; ?>" class="moreInfo">Meer
My code:
<div class="pb-2 mb-3">
<h1 class="h2">Recente Jira releases</h1>
<div class="release-items" id="release-items">
<?php
foreach ($items as $item):
$proj = new ProjectService();
$versionService = new VersionService();
$version = $proj->getVersion('', $item->name);
$res = $versionService->getRelatedIssues($version);
$uns = $versionService->getUnresolvedIssues($version);
$issuesFixedCount = $res->issuesFixedCount;
$issuesUnresolvedCount = $uns->issuesUnresolvedCount;
$roundedIssue = $issuesFixedCount - $issuesUnresolvedCount;
if ($res->issueFixedCount == 0){
echo "
<script>
const moreInfoVar = document.querySelector('.moreInfo');
const.style.display = 'none';
</script>";
}
?>
<div class="item" id="item">
<h4>Versie: <?= $item->name; ?></h4>
<div class="details">
<p>Issues in versie: <?= $res->issuesFixedCount; ?> </p>
<p>Afgeronde issues: <?= $roundedIssue;?> </p>
<p>Nog te verwerken issues: <?= $uns->issuesUnresolvedCount;?> </p>
Meer info<br>
</div>
<small><?= $item->releaseDate; ?></small>
<a class="toggle">Toon meer</a>
</div>
<?php
endforeach;?>
<?php
$startAtValueNext = $_GET['startAt'];
$startAtNext = $startAtValueNext += 5;
$startAtValuePrevious = $_GET['startAt'];
$startAtPrevious = $startAtValuePrevious -= 5;
if ($startAtPrevious <= 0){
$startAtPrevious = 0;
}
?>
</div>
<div class="Next-Previous">
<- Vorige
Volgende ->
</div>
</div>
There's no need to inject JavaScript in this way. Instead, simply modify what is sent to the browser in the first place:
<p>Nog te verwerken issues: <?= $uns->issuesUnresolvedCount;?> </p>
<a href="<?='version/?version=' . $item->name; ?>" class="moreInfo" <?= ($res->issueFixedCount == 0 ? 'style="display:none;"' : ''); ?>>Meer info</a><br>
</div>
P.S. document.querySelector('.moreInfo') will only ever select the first element it finds which has that class. It doesn't target the specific element you're outputting on the current row, so that's one reason why that approach doesn't work.
I have a page which allows you to filter results using an AJAX call which works fine, I have added pagination which work fine initially but as soon as you move to another page, the checkbox becomes unchecked and it just shows all results again. I assume this is because the page is reloading when it moves to page 2, is there a way of keep the filter setting set and continue to show the results from the filter AJAX. The pagination obvisouly works fine when no filter is selected but my brain just doesn't seem to be working and can't work this out.
Any help would be appreciated!
My code is below, I am also aware that currently my code is open to sql injection but just trying to get everything to work and then will go back through it:
<body>
<?php include("PHP/header.php"); ?>
<div class="container-fluid">
<div class="container" style="margin-top: 2%; text-align: center;">
<h1> Reviews</h1>
On This page you will find our reviews on music tech and software
<br/>
<br/>
<br/>
Filter Reviews:
<ul class="list-group">
<?php
$search = $conn->prepare("SELECT DISTINCT reviewcat FROM review_db ORDER BY reviewcat");
$search->execute();
while ($row = $search->fetch(PDO::FETCH_ASSOC)) {
?>
<li class="list-group-item">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input product_check" value="<?=$row['reviewcat'];?>" id="reviewcat"> <?=$row['reviewcat']; ?>
</label>
</div>
</li>
<?php } ?>
</ul>
</div>
<br/><br/>
<div class="row-fluid ">
<h5 class="text-center" id="textChange"> All Reviews </h5>
<hr>
<div class="text-center">
<img src="Images/loader.gif" id="loader" width="100" style="display: none">
</div>
<?php
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 8;
$offset = ($pageno-1) * $no_of_records_per_page;
// Prev + Next
$prev = $pageno - 1;
$next = $pageno + 1;
?>
<div id="result" class="card-deck card_group_style pt-4" >
<?php
$stmt = $conn->prepare("SELECT COUNT(*) FROM review_db");
$stmt->execute();
$total_rows = $stmt->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);
$result = $conn->prepare("SELECT * FROM review_db ORDER BY reviewsub DESC LIMIT $offset, $no_of_records_per_page ");
$result->execute();
?>
<?php while ($row = $result->fetch(PDO::FETCH_ASSOC)) {// Important line !!! Check summary get row on array .. ?>
<?php
$my_date = $row['reviewsub'];
$date = DATE("d/m/Y",strtotime($my_date));
?>
<div class="col-sm-6 col-lg-3 py-2">
<div class="card mb-4">
<img class="card-img-top card-images " src="Images/Reviews/<?php echo $row['reviewimage1'];?>" alt="<?php echo $row['reviewtitle'];?>" >
<div class="card-body">
<h5 class="card-title"><?php echo $row['reviewtitle'];?></h5>
<p class="card-text"><?php echo $row['reviewsynop'];?></p>
<a href="Reviews/review-content.php?id=<?php echo $row['id'];?>&reviewtitle=<?php echo $row['reviewtitle'];?>" class="btn btn-primary my-4" >Read More</a>
<div class="card-footer" style="padding: 1%;">
<small class="text-muted">Submitted: <?php echo $date; ?></small>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="container">
<!-- Pagination Controller -->
<?php
if($total_pages <= 1){
$hidepage = 'none';
}else{
$hidepage = 'flex';
}
?>
<ul class="pagination justify-content-center pagination-mb" style="display: <?php echo $hidepage; ?>">
<li><a class="page-link" href="?pageno=1">First</a></li>
<li class="page-item <?php if($pageno <= 1){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>">Prev</a>
</li>
<?php for($i = 1; $i <= $total_pages; $i++ ): ?>
<li class="page-item <?php if($pageno == $i) {echo 'active'; } ?>">
<a class="page-link" href="?pageno=<?= $i; ?>"> <?= $i; ?> </a>
</li>
<?php endfor; ?>
<li class="page-item <?php if($pageno >= $total_pages){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>">Next</a>
</li>
<li><a class="page-link" href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
</ul>
<!-- Pagination end -->
</div>
</div>
</div>
</div>
<?php include("PHP/footer.php"); ?>
</div>
</body>
<?php include("PHP/js.php"); ?>
<script>
$(document).ready(function(){
$('#link-review,#link-footer-review').addClass('active');
});
</script>
<script type="text/javascript">
$(document).ready(function(){
function get_filter_text(text_id){
var filterData = [];
$('#'+text_id+':checked').each(function(){
filterData.push($(this).val());
});
return filterData;
}
$(".product_check").click(function(){
if ($(this).prop('checked')) {
$("#loader").show();
var action = 'data';
var reviewcat = get_filter_text('reviewcat');
$.ajax({
method:'POST',
url:'reviewaction.php',
data:{action:action,reviewcat:reviewcat},
success:function(response){
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("Filtered Reviews");
}
});
} else {
$("#loader").show();
var action = 'data';
var reviewcat = get_filter_text('reviewcat');
$.ajax({
method:'POST',
url:'reviewaction.php',
data:{action:action,reviewcat:reviewcat},
success:function(response){
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("All Reviews");
}
});
}
});
});
</script>
reviewaction.php:
<?php
if(isset($_POST['action'])){
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 8;
$offset = ($pageno-1) * $no_of_records_per_page;
// Prev + Next
$prev = $pageno - 1;
$next = $pageno + 1;
$checksql = "SELECT COUNT(*) FROM review_db WHERE reviewcat !=''";
$sql = "SELECT * FROM review_db WHERE reviewcat !=''";
if(isset($_POST['reviewcat'])){
$reviewcat = implode("','", $_POST['reviewcat']);
$checksql .="AND reviewcat IN('".$reviewcat."')";
$sql .="AND reviewcat IN('".$reviewcat."')";
}
$resultpag = $conn->prepare($checksql);
$resultpag->execute();
$total_rows = $resultpag->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);
$sql .="ORDER BY reviewsub DESC LIMIT $offset, $no_of_records_per_page ";
$result = $conn->prepare($sql);
$result->execute();
$output='';
if (count($result) > 0) {
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$my_date = $row['reviewsub'];
$date = DATE("d/m/Y",strtotime($my_date));
$output .= '
<div class="col-sm-6 col-lg-3 py-2">
<div class="card mb-4">
<img class="card-img-top card-images" src="Images/Reviews/'.$row['reviewimage1'].'" alt="'.$row['reviewtitle'].'" >
<div class="card-body">
<h5 class="card-title">'.$row['reviewtitle'].'</h5>
<p class="card-text">'.$row['reviewsynop'].'</p>
<a href="Reviews/review-content.php?id='.$row['id'].'&reviewtitle='.$row['reviewtitle'].'" class="btn btn-primary my-4" >Read More</a>
<div class="card-footer" style="padding: 1%;">
<small class="text-muted">Submitted: '.$date.'</small>
</div>
</div>
</div>
</div>
';
} //While Loop End
}else{
$output = "<h3>No Reviews Found!</h3>";
}
echo $output;
}
?>
You can do it a couple of ways. One is to add the filter to the GET URI parameters of each page link at the end of your filter function, and add code that marks the filters as selected/checked if the parameters exist in the URI before running the POST request. The other is to change the code so that pagination is done with the same POST request instead of actually navigating to a new URL.
I need to list half portion of the for loop is to left side and other is in the next is right side.how to solve it?
foreach ( $events as $post ) {
$start_date = tribe_get_start_date( $post, false, 'F d, Y');
$end_date = tribe_get_end_date( $post, false, 'F d, Y');
if($i<=$number){
?>
<div class="col-md-61 leftDiv">
<div class="row1 outerDiv">
<li class="ecs-event">
<span class="duration time">
<span class="tribe-event-date-start"><?php if(!empty($start_date)) { ?> <?php echo $start_date; ?> <?php } ?> <?php if(!empty($end_date) && $start_date != $end_date ) { ?> - <?php echo $end_date; ?> <?php } ?> </span>
</span><span class="duration venue"><em>
at </em><?php echo tribe_get_venue( $post ); ?></span>
<h4 class="entry-title summary"><?php echo $post->post_title; ?>
</h4>
</li>
</div>
</div>
<?php } else {
?>
<div class="col-md-61 rightDiv">
<div class="row1 outerDiv">
<li class="ecs-event">
<span class="duration time">
<span class="tribe-event-date-start"><?php if(!empty($start_date)) { ?> <?php echo $start_date; ?> <?php } ?> <?php if(!empty($end_date) && $start_date != $end_date ) { ?> - <?php echo $end_date; ?> <?php } ?> </span>
</span><span class="duration venue"><em>
at </em><?php echo tribe_get_venue( $post ); ?></span>
<h4 class="entry-title summary"><?php echo $post->post_title; ?>
</h4>
</li>
</div>
</div>
<?php }?>
<?php
} ?>
please help to do that.I mean top to bottom listing as side by side
To point you to the idea you can check for even or odd item numbers to distribute your items.
Here is a generic code:
$even = [];
$odd = [];
foreach(range(1,10) as $value) {
if($value % 2 === 0) {
// even divisable by 2 without rest
$even[] = $value;
continue;
}
$odd[] = $value;
}
How to do pagination in Yii without any grid view and listview
I was stack in their for two days
these is my controller
public function actionIndex()
{
$criteria = new CDbCriteria;
// $criteria ->order = 'date';
$pages = new CPagination(OfferEvents::model()->count());
$pages ->pageSize = 2;
$pages -> applyLimit($criteria);
$post= OfferEvents::model()->findAll($criteria);
$this -> render('index', array('post' => $post, 'pages' => $pages));
}
and my view
<?php foreach($models as $model): ?>
<?php for($x = 0; $x < $arrlength; $x++) { ?>
<?php if($catiddet == 1){?>
<div class="col-sm-4">
<div class="list-box fadeInDown ">
<div class="img-box-1">
<img src="<?php echo $offerListArray[$x]['offerimg']; ?>" style="width:360px;height:202px;" />
<a href="#" class="view-btn" d='modal-launcher' data-toggle="modal"
data-target="#detailsOffeEve" onClick="showdetails(<?php echo $offerListArray[$x]['id']; ?>)">View Event</a>
</div>
<div class="text-box">
<?php
$date2=$offerListArray[$x]['enddate'] ;
$diff = (strtotime($date2)- strtotime($now))/24/3600;
?>
<div class="round-box clear"><span><h1><?php echo $diff ?><small>Days</small></h1></span></div>
<p style="height:19px;overflow: hidden;"> <b ><?php echo $offerListArray[$x]['offertitle']; ?> </b></p>
<p style="height: 80px;overflow: hidden;"><?php echo $offerListArray[$x]['description']; ?> </p>
</div>
</div>
</div>
<?php } else{?>
<div class="col-sm-4" >
<div class="list-box">
<div class="img-box-1">
<?php $filepathnw=$offerListArray[$x]['offerimg'];
//if (file_exists($filepathnw)) { $filepathSrc=Yii::app()->baseUrl.'/'.$filepathnw; } else
//{ $filepathSrc='http://www.childnet.com/pimages/1351720/thumbnail4.jpg'; }
?>
<img src="<?php echo $filepathnw; ?>" />
<a href="#" class="view-btn" d='modal-launcher' data-toggle="modal"
data-target="#detailsOffeEve" onClick="showdetails(<?php echo $offerListArray[$x]['id']; ?>)">View Offer</a>
</div>
<div class="text-box" style="padding:2px !important;">
<?php
$date2=$offerListArray[$x]['enddate'] ;
$diff = (strtotime($date2)- strtotime($now))/24/3600;
?>
<span><h1><?php echo $diff ?><small>Days</small></h1></span>
<span><h1><?php echo $offerListArray[$x]['discountper']; ?>%<small>DISCOUNT</small></h1></span>
<span><h1>$<?php echo $offerListArray[$x]['discountperamt']; ?><small>You Save</small></h1></span>
<div class="text-box" style="padding:15px;">
<p style="height:19px;overflow: hidden;">
<b ><?php echo $offerListArray[$x]['offertitle']; ?> </b></p>
<p style="height: 80px;overflow: hidden;"><?php echo $offerListArray[$x]['description']; ?> </p>
</div> </div>
</div>
</div>
<?php } ?>
<?php } ?>
<?php endforeach; ?>
// display pagination
<?php $this->widget('CLinkPager', array(
'pages' => $pages,
)) ?>
out put comes fine..but the data repeats...
select * FROM offer_events WHERE enddate >= '$now' AND (title like '%$locationdet%' OR description like '%$locationdet%') AND type = '$catiddet' ORDER BY id DESC LIMIT 6 ");
$datalat = $dbCommand->queryAll(); $numlatData=count($datalat);
// echo "<pre>"; print_r($datalat); echo "</pre>";
$latlongdats='';
if($numlatData!=0){
foreach($datalat as $expertn)
{
$ids=$expertn['id'];
$offertitle=$expertn['title'];
if($expertn['image']!=""){ $imgUrl=$expertn['image']; } else { $imgUrl='image-not-available.png'; }
$infowinimgpath='theme/images/OfferEvents/thumb/'.$imgUrl;
if (file_exists($infowinimgpath)) { $infowinimgpathSrc=Yii::app()->baseUrl.'/'.$infowinimgpath; } else
{ $infowinimgpathSrc=Yii::app()->baseUrl.'/theme/images/OfferEvents/thumb/image-not-available.png'; }
$offerimg=$infowinimgpathSrc;
$latinow=$expertn['latitude'];
$longinow=$expertn['longitude'];
$latlongdats.="['".$ids."', ".$latinow.",".$longinow.",'".$offertitle."','".$offerimg."','".$expertn['startdate']."'],";
$offertList = array(
"id" => $ids,
"offertitle"=> $offertitle,
"offerimg" => $offerimg,
"description" => $expertn['description'],
"startdate" => $expertn['startdate'],
"enddate" => $expertn['enddate'],
"discountper" => $expertn['discountper'],
"discountperamt" => $expertn['discountperamt']
);
array_push($offerListArray,$offertList);
}
$zoomlevel=3;
$latlongdatsfinal=rtrim($latlongdats, ",");
} else { $latlongdatsfinal="['','',''],"; $ErrorMsgmap="No Result Found."; }
}
and could you please explain me how this happend???
You can use CActiveDataProvider to perform your pagination needs
public function actionIndex()
{
$criteria = new CDbCriteria;
// $criteria ->order = 'date';
$post= new CActiveDataProvider('OfferEvents', array(
'criteria' => $criteria,
'pagination'=>array('pageSize' => 2),
));
$this -> render('index', array('post' => $post));
}
In your view, instead of using foreach loop, use ListView / GridView and pass the CActiveDataProvider instance ($post) in your case
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$post,
'itemView'=>'_post', // refers to the partial view named '_post'
));
the "_post.php" subview file would contain
$data->property // whatever properties you have set for 'OfferEvents'
I'm coding a staff panel but I'm stuck I've added a menu (navigation) but I'm stuck on how to go about opening it when clicked and closing it when clicked if open.
Here is the code i have so far;
<ul id="menu" class="nav">
<?php
$url = $_GET['url'] ? $core->clean($_GET['url']) : 'core.home';
$query3 = $db->query("SELECT * FROM menu WHERE url = '{$url}'");
$array3 = $db->assoc($query3);
if (!$array3['usergroup']) {
$array3['usergroup'] = "invalid";
}
$query = $db->query("SELECT * FROM usergroups ORDER BY weight ASC");
while ($array = $db->assoc($query)) {
if (in_array($array['id'], $user->data['uGroupArray'])) {
?>
<div class="menustyle" onclick="Radi.menuToggle('<?php echo $array['id']; ?>');">
<div class="menutext"><?php echo $array['name']; ?></div>
</div>
<ul>
<li class="menuitems"<?php if ($array['id'] != $array3['usergroup']) { ?> onclick="Radi.menuToggle('<?php echo $array['id']; ?>');" style="display: none;"<?php } ?> id="mitems_<?php echo $array['id']; ?>">
<?php
$query2 = $db->query("SELECT * FROM menu WHERE usergroup = '{$array['id']}' AND visible = '1' ORDER BY weight ASC");
$i = "a";
while ($array2 = $db->assoc($query2)) {
?>
<li>
<?php echo $array2['text']; ?>
</li>
<?php
$i++;
if ($i == "c") {
$i = "a";
}
}
?>
</ul>
</li>
<?php
}
}
?>
</li>
</ul>
</div>
And this is the defualt code when you download radipanel;
<div style="float: left; width: 200px;">
<?php
$url = $_GET['url'] ? $core->clean($_GET['url']) : 'core.home';
$query3 = $db->query("SELECT * FROM menu WHERE url = '{$url}'");
$array3 = $db->assoc($query3);
if (!$array3['usergroup']) {
$array3['usergroup'] = "invalid";
}
$query = $db->query("SELECT * FROM usergroups ORDER BY weight ASC");
while ($array = $db->assoc($query)) {
if (in_array($array['id'], $user->data['uGroupArray'])) {
?>
<div class="box">
<div class="square menu" style="background: #<?php echo $array['colour']; ?>;" onclick="Radi.menuToggle('<?php echo $array['id']; ?>');">
<img id="menutoggle_<?php echo $array['id']; ?>" class="menutoggle" src="_img/<?php echo ( $array['id'] != $array3['usergroup'] ) ? 'plus' : 'minus'; ?>_white.png" alt="Toggle" align="right" />
<strong><?php echo $array['name']; ?></strong>
</div>
<div class="menuitems"<?php if ($array['id'] != $array3['usergroup']) { ?> style="display: none;"<?php } ?> id="mitems_<?php echo $array['id']; ?>">
<?php
$query2 = $db->query("SELECT * FROM menu WHERE usergroup = '{$array['id']}' ORDER BY weight ASC");
$i = "a";
while ($array2 = $db->assoc($query2)) {
?>
<a href="<?php echo $array2['url']; ?>" class="<?php echo $i; ?>">
<?php echo $array2['text']; ?>
</a>
<?php
$i++;
if ($i == "c") {
$i = "a";
}
}
?>
</div>
</div>
<?php
}
}
?>
</div>
So any ideas on why my code is not doing it?