I want make a OOP pagination for my articles - php

I want make a pagination for my articles..
Here is class:
<?php
class Mynews {
public $conn;
public function __construct() {
$this->conn = mysqli_connect("localhost", "root", "", "mynews");
}
public function readAllarticles() {
$sql = "SELECT * FROM articles WHERE status='publish'";
$query = mysqli_query($this->conn, $sql);
return mysqli_fetch_all($query, MYSQLI_ASSOC);
}
}
$obj = new Mynews;
?>
display post: <?php
include('includes/crud.php');
foreach ($obj->readAllarticles() as $art) {
extract($art);
?>
<h3><?php echo $title; ?></h3>
<p>
<?php
$post = explode(" ", $content);
$slice = array_slice($post, 0, 10);
echo implode(" ", $slice), '...';
?>
</p>
<?php
}
?>
Now i want a function my class to make a pagination... and sorry for my bad eng.. :(

You use it:
<?php
class Pagination{
function Paginate($values,$per_page){
$total_values = count($values);
if(isset($_GET['page'])){
$current_page = $_GET['page'];
}else{
$current_page = 1;
}
$counts = ceil($total_values / $per_page);
$param1 = ($current_page - 1) * $per_page;
$this->data = array_slice($values,$param1,$per_page);
for($x=1; $x<= $counts; $x++){
$numbers[] = $x;
}
return $numbers;
}
function fetchResult(){
$resultsValues = $this->data;
return $resultsValues;
}
}
// Sample Usage
$pag = new Pagination();
$data = array("Hello","Rex","Prosper","Adrivan","Hehe");
$numbers = $pag->Paginate($data,2);
$result = $pag->fetchResult();
foreach($result as $r){
echo '<div>'.$r.'</div>';
}
foreach($numbers as $num){
echo ''.$num.'';
}
?>

I use this and it works for me
PHP
function pagination_one($webpage, $total_pages,$page){
// Maximum number of links per page. If exceeded, google style pagination is generated
$max_links = 6;
$h=1;
if($page>$max_links){
$h=(($h+$page)-$max_links);
}
if($page>=1){
$max_links = $max_links+($page-1);
}
if($max_links>$total_pages){
$max_links=$total_pages+1;
}
echo '<div class="page_numbers">
<ul>';
if($page>"1"){
echo '<li class="current">First</li>
<li class="current">Prev</li> ';
}
if($total_pages!=1){
for ($i=$h;$i<$max_links;$i++){
if($i==$page){
echo '<li><a class="current">'.$i.'</a></li>';
}
else{
echo '<li>'.$i.' </li>';
}
}
}
if(($page >="1")&&($page!=$total_pages)){
echo '<li class="current">Next</li>
<li class="current">Last</li>';
}
echo '</ul> </div>';
}
function pagination_one($webpage, $total_pages,$page){
// Maximum number of links per page. If exceeded, google style pagination is generated
$max_links = 6;
$h=1;
if($page>$max_links){
$h=(($h+$page)-$max_links);
}
if($page>=1){
$max_links = $max_links+($page-1);
}
if($max_links>$total_pages){
$max_links=$total_pages+1;
}
echo '<div class="page_numbers">
<ul>';
if($page>"1"){
echo '<li class="current">First</li>
<li class="current">Prev</li> ';
}
if($total_pages!=1){
for ($i=$h;$i<$max_links;$i++){
if($i==$page){
echo '<li><a class="current">'.$i.'</a></li>';
}
else{
echo '<li>'.$i.' </li>';
}
}
}
if(($page >="1")&&($page!=$total_pages)){
echo '<li class="current">Next</li>
<li class="current">Last</li>';
}
echo '</ul> </div>';
}
// get the pagenum. If it doesn't exist, set it to 1
if(isset($_GET['pagenum']) ? $page = $_GET['pagenum']:$page = 1);
// set the number of entries to appear on the page
$entries_per_page = 6;
// total pages is rounded up to nearest integer
$total_pages = ceil($getresult/$entries_per_page);
// offset is used by SQL query in the LIMIT
$offset = (($page * $entries_per_page) - $entries_per_page);
$sql = "SELECT * FROM articles WHERE status='publish' LIMIT $offset,$entries_per_page";
// do your query results
pagination_one('articles.php', $total_pages,$page);
and CSS
.page_numbers {
width:100%;
background:#fff9f0;
overflow:hidden;
position:relative;
padding:50px 0;
}
.page_numbers ul, .pagenums ul {
clear:left;
float:left;
list-style:none;
margin:0;
padding:0;
position:relative;
left:50%;
text-align:center;
}
.page_numbers ul li,.pagenums ul li {
display:block;
float:left;
list-style:none;
margin:1px;
padding:0;
position:relative;
right:50%;
background: #a8a189;
width:25px;
}
.page_numbers ul li a, .pagenums ul li a {
display:block;
background: #fff;
border: 1px solid #a8a189;
padding:3px 6px;
text-decoration: none;
color: #7a7564;
font:bold 11px arial, verdana,sans-serif;
}
.page_numbers li.current,
.pagenums li.current{
width:50px;
}
.page_numbers a.current, .page_numbers li a:hover,
.pagenums a.current, .pagenums li a:hover {
background: #a8a189;
color: #fff;
}

Related

run php code if $players is between 5 and 9 in third span

Ok i edit my question i think i understand more now how to build a question.
The website: bit DOT ly/1MHItEH
I want to run a php code when span 3 is between 5 & 9.
The code which outputs this is $players and in the bottom there is a html output code
<td><span style='text-shadow: 0 0 10px #ffca00; color: #ffca00; font-size: 20pt;'>". $players ."</span></td>
This php code outputs a html table with different values for every added server.
For example if i add a new server to servers.php it will create a new span for that server with new values. So basicly it reads and outputs different values for every server.
So how can i just run extra php code if the span 3 is between 5 & 9?
<html>
<head>
<meta charset="utf-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
tr td, tr th { text-align: center !important; }
tr td.motd, tr th.motd { text-align: left !important; }
</style>
</head>
<body style="width: 100%; margin: 0 auto; height: 20px; ">
<table class='table table-bordered table-striped'>
</br>
<?php
error_reporting(0);
function openserveriai() {
}
function closeserveriai() {
}
function getnextstring(&$data) {
$temp="";
$counter=0;
while (ord($data[$counter++])!=0) $temp.=$data[$counter-1];
$data=substr($data,strlen($temp)+1);
return $temp;
}
function getnextbytevalue(&$data) {
$temp=ord($data[0]);
$data=substr($data,1);
return $temp;
}
function addServer($ip) {
$map = '';
$players = '';
$maxplayers = '';
$servername = '';
$output = '';
$live_server = '0';
$packet = '0';
$packet = "\xFF\xFF\xFF\xFFTSource Engine Query\x00";
$live_server = fsockopen("udp://".$ip);
if(!$live_server)
{
$output = "Off";
}
else
{
fwrite($live_server, $packet);
socket_set_timeout($live_server,1,0);
$junk = fread($live_server,5);
$status = socket_get_status($live_server);
$do = 1;
$server_info= "";
while($do)
{
$str_1 = fread($live_server,1);
$server_info .= $str_1;
$status = socket_get_status($live_server);
if($status["unread_bytes"] == 0) {$do = 0;}
}
fclose($live_server);
if (strlen($server_info) > 0)
{
$success = 1;
$junk = getnextstring($server_info);
$servername = getnextstring($server_info);
$map = getnextstring($server_info);
$junk = getnextstring($server_info);
$junk = getnextstring($server_info);
$players = getnextbytevalue($server_info);
}
if ($players != '') {
$players = $players;
} else {
$players = "0";
}
if ($maxplayers != '')
{
$maxplayers = $maxplayers;
}
else
{
$maxplayers = "0";
}
if ($output != "Full" and $players != "0" or $maxplayers != "0")
{
$output = $output;
}
else
{
$output = "<font color='#FF0000'>Offline</font>";
}
if ($map != '')
{
$map = $map;
}
else
{
$map = "--";
$maxplayers = "--";
$players = "--";
}
if ($servername != '') {
$servername = $servername;
}
else
{
$servername = "--";
}
}
if($players == $maxplayers && $players != '--')
{
$players = "" . $players . "";
}
else if($players > $maxplayers-3 && $players != '--')
{
$players = "" . $players . "";
}
else
{
$players = "" . $players . "";
}
if ( strlen($map) > 19 )
{
$map = substr($map, 0, 19) . '...';
}
echo "
<tbody>
<tr style='background: #10130d;'>
";
if ($map == '--')
{
echo "<td><span style='background-color: #b85c5c; border-radius: .25em; padding: .2em .6em .3em; font-weight: bold; color: #fff; font-size: 10pt;'>Offline</i></span></td>";
}
else
{
echo "<td><span style='background-color: #5cb85c; border-radius: .25em; padding: .2em .6em .3em; font-weight: bold; color: #fff; font-size: 10pt; '>Online</i></span></td>";
}
echo "
<td><span style='color: #fff; font-size: 10pt;'>". $ip ."</span></td>
<td><span style='text-shadow: 0 0 10px #ffca00; color: #ffca00; font-size: 20pt;'>". $players ."</span></td>
</tr>
</tbody>
";
}
openserveriai();
include ('servers.php');
closeserveriai();
?>
</table>
</body>
</html>
You can do something like this
<?php
$total = 5;
if ($total >= 5 && $total <= 9) {
//Between 5 and 9
} else {
// Not between 5 and 9
}
?>
<table class='table table-bordered table-striped'>
<tbody>
<tr>
<td><span>First</span></td>
<td><span>Second</span></td>
<td><span><?php echo $total; ?></span></td>
</tr>
</tbody>
</table>
Then you can call that php page with
require('yourpage.php');

Php multilanguage dynamic link

There are two languages on my webpage. These are en and rs. ie english and russian. I want to be listed as en.php and rs.php under the languages directory, but only if they have the form url = ln = I, for example www.google.com/en or www.google.com/rs. For this I added the .htaccess file and the function.php file. but I do not know how to change the code I wrote below. How can I do that?
i have languages folder and en.php and tr.php
<?php
# Session başlat
session_start();
$available_langs = array('en','tr');
$_SESSION['lng']='en';
# Dil seçimi yapılmışsa
if($_GET['lng']) {
# Dil seçimini session'a ata.
$_SESSION['lng'] = $_GET['lng'];
# Anasayfa'ya yönlendir.
}
if ($_SESSION['lng'] == "en") {
$lng = "en";
}
elseif ($_SESSION['lng'] == "tr") {
$lng = "tr";
}
include 'languages/'.$lng.'.php';
include("fonksiyon.php");
?>
<li>
<?php
if(isset($_GET["lng"])){
if($_GET["lng"] == "tr"){
//echo 'EN';
echo ' <li style="float:left"> <a href="?lng=en"
style="border-left: solid gray 1px; line-height: 50%; margin-top: 15px; padding-right:2px; ">EN</a></li>';
} else if($_GET["lng"] == "en"){
// echo 'TR';
echo ' <li style="float:left"> <a href="?lng=tr"
style="border-left: solid gray 1px; line-height: 50%; margin-top: 15px; padding-right:2px; ">TR</a></li>';
} else {
echo 'no lang';
}
} else {
// echo 'TR';
echo ' <li style="float:left"> <a href="?lng=tr" style="border-left: solid gray 1px;
line-height: 50%; margin-top: 15px; padding-right:2px; ">TR</a></li>';
}
?>
</li>
.htaccess
RewriteEngine On
RewriteRule ^(.*)-(.*).html$ roportajdetay.php?id=$1&$baslik=$2 [L,NC]
fonksiyon.php
<?php function cevir($s) {
$tr = array('ş','Ş','ı','İ','ğ','Ğ','ü','Ü','ö','Ö','Ç','ç');
$eng = array('s','s','i','i','g','g','u','u','o','o','c','c');
$s = str_replace($tr,$eng,$s);
$s = strtolower($s);
$s = preg_replace('/&.+?;/', '', $s);
$s = preg_replace('/[^%a-z0-9 _-]/', '', $s);
$s = preg_replace('/s+/', '-', $s);
$s = preg_replace('|-+|', '-', $s);
$s = trim($s, '-');
return $s;
} ?> ?>

How can I display two images horizontally?

I have a problem and needed an answer. How can I automatically put the 2 images horizontally.
I think I will use some if(1 ==%3)?
In the example pic I really like to horizontal the 2 images don't know how to do it ?
Here's what I've done:
for($i=0; $rows = $results->fetch(); $i++){
if($dsds=='Commissoner'){
echo $rows['prog_id'].$rows['prog_id'].' '.$rows['prog_name'].' = '.$rows['votes'];
}else {
//this is the part where I put a css
style='margin-left:44px;'><div class='box_img2' style='margin-right:10px;' >";
echo '<img src="candidates/images/'.$rows['image'].'" width="70" height="80px" />'.', '.'<br>'.$rows['lastname'].', '.$rows['firstname'].'<br>'.' = '.$rows['votes'];
echo '<br>';
}
$sdsd=$dsada
?>
<img src="candidates/images/percent.gif"width='<?php echo(100*round($rows['votes']/($sdsd),2)); ?>'height='10'>
<?php
if ($rows['votes']==0){
echo "<br>";}
else {
echo(100*round($rows['votes']/($sdsd),2)); ?>%<br>
<?php
}
echo '</div>';
}
?>
Here's my css:
.row:before, .row:after { clear:both; }
.row{
display: block;
}
.box_img2 {
float: left;
/*margin-right:85px;*/
text-align:center;
}
.box_img2 img { /* if you want it centered */
display:block;
display: inline-block;
}
Here's my entire codes:
<?php
include('../connection/connect.php');
$result = $db->prepare("SELECT * FROM candposition ORDER BY posid ASC");
$result->bindParam(':userid', $res);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
$dsds=$row['posid'];
$resulta = $db->prepare("SELECT sum(votes) FROM candidates WHERE posid= :a");
$resulta->bindParam(':a', $dsds);
$resulta->execute();
for($i=0; $rowa = $resulta->fetch(); $i++){
$dsada=$rowa['sum(votes)'];
}
echo '<div style="margin-top: 18px;">';
echo '<strong>'.$row['pos_name'].' '.'</strong><br>';
$results = $db->prepare("SELECT * FROM candidates,student WHERE candidates.idno=student.idno AND candidates.syearid = '$no'AND posid = :a ORDER BY votes DESC");
$results->bindParam(':a', $dsds);
$results->execute();
for($i=0; $rows = $results->fetch(); $i++){
if($dsds=='Commissoner'){
echo $rows['prog_id'].$rows['prog_id'].' '.$rows['prog_name'].' = '.$rows['votes'];
}else {
//this is the part
echo'<?php $src=array("candidates/images/".$rows["image"]); for($i=0;$i<3;$i++){ ?>';
echo '<img src="candidates/images<?php echo .$src[$i];?>" class="image-inner" />';}
$sdsd=$dsada
?>
<!-- <img src="candidates/images/percent.gif"width='<?php echo(100*round($rows['votes']/($sdsd),2)); ?>'height='10'>-->
<?php
if ($rows['votes']==0){
echo "<br>";}
else {
// echo(100*round($rows['votes']/($sdsd),2)); /
/*?>%<br>*/
/*<?php
}
echo '</div>';*/
}
}
?>
<?php
}
?>
This is the easiest way i can explain using php. Hopes this will help you to understand
.image-inner {
position: relative;
width: 150px;
display: inline-block;
}
<?php
$src = array(
'http://www.google.com/logos/2008/de_doodle4google08.gif',
'http://www.google.com/logos/2012/d4g_poland12-hp.jpg',
'http://www.google.com/logos/2011/colombia-independenceday11-hp.jpg'
);
for($i = 0; $i < 3; $i++)
{
echo "<img src='{$src[$i]}' class='image-inner' />";
}
?>
Display the divs as inline-block like so :
#christmas_promotion_boxes div {
display: inline-block;
}
jsFiddle

Multicolored divs

my site which is a search engine returns many many results with a foreach loop as such:
foreach ($xml->channel->item as $result) {
$ltitle = $result->title;
$ldesc = $result->description;
$url = $result->displayUrl;
$link = $result->link;
if (strlen($ltitle) > 60)
{
$title = substr($ltitle,0,60).'...' ;
}
else
{
$title = $ltitle;
}
if (strlen($ldesc) > 195)
{
$desc = substr($ldesc,0,195).'...' ;
}
else
{
$desc = $ldesc;
}
echo "
<br>
<div class='resultbox'>
<a class='normal' style='text-decoration:none;font-size:huge;font-weight:bold' href='$link'>$title</a><br>
<div style='padding-top:3px;padding-bottom:4px;width:580px;'>
<font style='text-decoration:none;font-size:small;font-family:Arial;'>$desc<br></font></div>
<a style='text-decoration:none;' href='$link'><font style='text-decoration:none;font-size:small;color:green;font-weight:bold;'>$url<br></font></a>
</div>
";
}
And the resultbox class above styles all of the results with this
.resultbox
{
height:auto;
width:600px;
background-color:transparent;
font-size:19px;
padding:10px;
padding-left: 30px;
padding-right: 30px;
border-left: 6px solid #333;
}
.resultbox:hover
{
border-left: 8px solid #555;
}
The border-left color is what i want changed, i would like it to generate or to style randomly off of a list of colour codes so the results, insead of being all #333 can be #333 #555 #999 and so on..... any ideas?
If u have no problems using JS , You can certainly do this :
$(document).ready(function () {
$('.resultbox').mouseenter(function() {
var randomColor = Math.floor(Math.random()*16777215).toString(16);
$('.resultbox').css("border-left", " 8px solid #"+randomColor);
});
});
change <div class='resultbox'> to <div class='resultbox random-color-".rand(1,YOUR_COLOR_LIMIT)."'> AND define colors like
.random-color-1 {
border-left: 8px solid #555;
}
.random-color-2 {
border-left: 8px solid #555;
}
.....
.random-color-YOUR_COLOR_LIMIT {
border-left: 8px solid #555;
}
change
<div class='resultbox'>
to
<div class='resultbox' style='border-left-color:$yourColorInCssFormat;'>
the style attribute overrides the css from class.
set $yourColorInCssFormat to the color you wish to have for the div. for example: $yourColorInCssFormat = '#999';
You can use inline style for that. Or alternatively you can user nth-child selector of css to repeat the border-color scheme something like this:
.resultbox:nth-child(n+1):hover {
}
.resultbox:nth-child(2n+1):hover {
}
.resultbox:nth-child(3n+1):hover {
}
First off, try this out for your foreachloop:
<?php foreach ($xml->channel->item as $result): ?>
<?php
$ltitle = $result->title;
$ldesc = $result->description;
$url = $result->displayUrl;
$link = $result->link;
if (strlen($ltitle) > 60){
$title = substr($ltitle,0,60).'...' ;
}else{$title = $ltitle;}
if (strlen($ldesc) > 195){
$desc = substr($ldesc,0,195).'...' ;
}else{$desc = $ldesc;}
?>
<div class='resultbox'>
<a class='normal' style='text-decoration:none;font-size:huge;font-weight:bold' href='<?php echo $link ?>'><?php echo $title; ?></a>
<br>
<div style='padding-top:3px;padding-bottom:4px;width:580px;'>
<font style='text-decoration:none;font-size:small;font-family:Arial;'>
<?php echo $desc; ?><br>
</font>
</div>
<a style='text-decoration:none;' href='<?php echo $link; ?>'><font style='text- decoration:none;font-size:small;color:green;font-weight:bold;'><?php echo $url; ?><br></font> </a>
<?php endforeach; ?>
That way you're not playing with big echos.
Now for generating random colors your could use php rand();
For example:
//Generate a random number between the two parameters
$randomNumber = rand(1, 3);
//Use this number to dictate what the variable color should be
if($randomNumber == 1){$color = "#333"}
elseif($randomNumber == 2){$color = "#555"}
elseif($randomNumber == 3){$color = "#999"}
You can then use the variable $color in your code to randomly assign one of the colors to elements.
Hope this helps!
-Gui

float left every other item echo php

im trying to float left every other UL tag, and i know i should flaot left every item and every other item clear:left, from what i've read, but the thing is i dont know how many UL or LI would appear because im echoing from a data base.
this is the CSS:
.clientes_provincia li{
font-family:Verdana, Geneva, Tahoma, sans-serif;
font-size:10px;
font-weight:bold;
text-decoration:none;
list-style-type:none;
text-align:left;
margin-top:0px;
margin-left:10px;
}
.clientes_comuna li{
font-family:Verdana, Geneva, Tahoma, sans-serif;
font-weight:bold;
font-size:10px;
font-weight:bold;
text-decoration:none;
list-style-type:none;
list-style-position:inside;
}
.clientes_giro li{
font-family:Verdana, Geneva, Tahoma, sans-serif;
font-size:10px;
font-weight:normal;
text-decoration:none;
list-style-type:disc;
}
.clientes_nombre li{
font-family:Verdana, Geneva, Tahoma, sans-serif;
font-size:10px;
font-weight:normal;
text-decoration:none;
list-style-type:circle;
margin-left:20px;
}
and this is the php code, where i echo the list:
<?php
$nombreProvincia = "";
$nombreComuna = "";
$nombreGiro = "";
$nombreNombre = array();
while ($row = mysql_fetch_assoc($resultAraucania)) {
if ($nombreProvincia == $row['nombreProvincia']) {
if ($nombreComuna == $row['nombreComuna']) {
if ($nombreGiro == $row['nombreGiro']) {
$nombreNombre[] = $row['nombreNombre'];
}
else { //nombreGiro
echo '<li>' . implode('</li><li> ', $nombreNombre).'</li></ul></li></ul>';
$nombreGiro = $row['nombreGiro'];
echo '<ul class="clientes_giro"><li>'.$nombreGiro.'<ul class="clientes_nombre">';
$nombreNombre = array($row['nombreNombre']);
}
}
else { // nombreComuna
echo '<li>' . implode('</li><li> ', $nombreNombre).'</li></ul></li></ul></li></ul>';
$nombreComuna = $row['nombreComuna'];
echo '<ul class="clientes_comuna"><li>'.$nombreComuna;
$nombreGiro = $row['nombreGiro'];
echo '<ul class="clientes_giro"><li>'.$nombreGiro.'<ul class="clientes_nombre">';
$nombreNombre = array($row['nombreNombre']);
}
}
else { // nombreProvincia
if (!empty($nombreNombre)) {
echo '<li>' . implode('</li><li> ', $nombreNombre).'</li></ul></li></ul></li></ul></li></ul>';
}
$nombreProvincia = $row['nombreProvincia'];
// this is the UL i'd like float for every other one.
echo '<ul class="clientes_provincia"><li>'.$nombreProvincia;
$nombreComuna = $row['nombreComuna'];
echo '<ul class="clientes_comuna"><li>'.$nombreComuna;
$nombreGiro = $row['nombreGiro'];
echo '<ul class="clientes_giro"><li>'.$nombreGiro.'<ul class="clientes_nombre">';
$nombreNombre = array($row['nombreNombre']);
}
}
echo '<li>' . implode('</li><li> ', $nombreNombre).'</li></ul></li></ul></li></ul></li></ul>';
?>
So what I'd like to do is float every other UL tag of the 'Provincia' echo.
Thanks for the help!
at this moment with what i have i get a list like this:
Provincia1
Comuna1
Giro1
Nombre1
Nombre2
Provincia2
Comuna2
Giro2
Nombre3
Nombre4
I want the provincia 2 be on the right side of provincia 1, and if I have another list
provincia 3 i want it to be under pronvincia 1, and a prinvia 4 beside provincia 3 and so on.., thats what i mean with floating every other UL provincia, hope that helps as an example.
$i = 0;
while ($row = mysql_fetch_assoc($resultAraucania)) {
$class = $i++ % 2 ? 'odd' : 'even';
...
echo '<li class="' . $class . '">';
...
}
This allows you to easily distinguish between even and odd columns and float "every other" column left.
If you don't care about IE too much, you can use
.clientes_provincia:nth-of-type(odd) { float: left }
I think that your markup and looping is making this problem harder than it should be. I actually think it could just be 1 loop.
The trick here is to use a width on a container <div> and each <ul> which automatically forces the browser to float two <ul>s and then drop to the next row for the following <ul>. If you can't use this static width idea then you have 2 very good other solutions already.
Here is a small example which I have tested at http://writecodeonline.com/php/
$dataRow = array();
$dataRow[0] = array('nombreProvincia' => 'A123', 'nombreComuna' => 'A456', 'nombreGiro' => 'A789', 'nombreNombre' => array(101, 102));
$dataRow[1] = array('nombreProvincia' => 'B123', 'nombreComuna' => 'B456', 'nombreGiro' => 'B789', 'nombreNombre' => array(201, 202));
$dataRow[2] = array('nombreProvincia' => 'C123', 'nombreComuna' => 'C456', 'nombreGiro' => 'C789', 'nombreNombre' => array(301, 302));
echo '<div style="width:600px">';
foreach ($dataRow as $key => $row) {
$nombreProvincia = $row['nombreProvincia'];
$nombreComuna = $row['nombreComuna'];
$nombreGiro = $row['nombreGiro'];
$nombreNombre = '<li>'.implode('</li><li>', $row['nombreNombre']).'</li>';
echo $provincia = <<<HTML
<ul class="clientes_provincia" style="width:200px;float:left;">
<li>$nombreProvincia
<ul class="clientes_giro">
<li>$nombreGiro
<ul class="clientes_nombre">
$nombreNombre
</ul>
</li>
</ul>
</li>
</ul>
HTML;
}
echo '<br style="clear:both"></div>';
Also, heredoc is awesome if you use PHP >= 4.

Categories