Foreach for ordering columns and placement in div tags

They have: 3 posts

Joined: Dec 2010

Hi all, i was looking for a way to include my div-table ORDER DESC ASC links so finally i found the following code with standard table which I believe it is secured and simple, and working fine.
But, my question is i have a div-table like..

<div class="tablo"> 
  <div class="head">
    <div class="sub1">id</div>
    <div class="sub2">baslik</div>
    <div class="sub3">makale</div>
    <div class="sub4"> tarih</div>
  </div>

Unfortunately, because of foreach function, i am lost and no idea how to convert below raw table into my div table where each div has different style because of width portion.

Here is the raw table code:

<?php
$sortColumns
= array('id', 'baslik', 'makale', 'tarih');
$sortOrder = array('ASC', 'DESC');

if(!isset(
$_GET['op']) || !isset($sortColumns[$_GET['op']]))
{
$_GET['op'] = 0;
}
if(!isset(
$_GET['ord']) || !isset($sortOrder[$_GET['ord']]))
{
$_GET['ord'] = 0;
}

$query = 'SELECT '.implode(', ', $sortColumns).' FROM icerikdb ORDER BY '.$sortColumns[$_GET['op']].' '.$sortOrder[$_GET['ord']];
$fileName = getenv('SCRIPT_NAME');
include
'conn.php';
$result = mysql_query($query);

echo
'<table>';
echo
'<tr>';
foreach(
$sortColumns as $key => $column)
{
echo
'<td><a href="',$fileName,'?op=',$key,'&ord=',($_GET['op'] == $key && 0 == $_GET['ord']) ? '1' : '0','">',$column,'</a></td>';
}
echo
'</tr>';

while (
$row = mysql_fetch_array($result))
{
echo
'<tr>';
foreach(
$sortColumns as $column)
{
echo
'<td>',$row[$column],'</td>';
}
echo
'</tr>';
}
echo
'</table>';
?>
 

Thanks for any help.