...

View Full Version : Ordering Columns HELP



balkan
02-22-2007, 10:43 PM
i have code for order columns like:

1 2
3 4

but i cannot order this whit include template, so how can order whit my template ?

index.php

<?php
include("konekcija.php");

$query = mysql_query("select * from news WHERE catid=cat_id AND status = '1'");

$total = mysql_num_rows($query);

$numRows = ceil($total / 2);


echo ('<table border=1>');

for ($y = 0; $y < $numRows; $y++) {

echo ('<tr>');

for ($x = 0; $x < 2; $x++) {

if (($offset = ($y + ($x * $numRows))) < $total) {

mysql_data_seek($query, $offset);

$row = mysql_fetch_array($query);
// i wanna put here include file: templates/index.php //
echo ('<td>'.$row['name'].'</td>');
echo ('<td>'.$row['desc'].'</td>');
}
}

echo ('</tr>');
}

echo ('</table>');
?>

templates/index.php


<style type="text/css">
.style1 {
border-width: 0;
background-color: #FFFFFF;
color: #000000;
font-size: 12px;
font-weight: bold;
}
.style2 {
border-collapse: collapse;
border: 1px solid #000000;
background-color: #C0C0C0;
}
.style5 {
border: 1px solid #5589BF;
}
.style7 {
border: 1px solid #008080;
}
.style11 {
border-width: 1px;
}
.style12 {
border-width: 0;
background-color: #5589BF;
color: #FFFFFF;
font-size: 11px;
font-weight: bold;
}
.style13 {
border-width: 0;
background-color: #5589BF;
background-image: url('images/blok.gif');
text-align: center;
}
.style15 {
color: #5589BF;
}

</style>
</head>

<body>

<table style="width: 35%" class="style2" cellspacing="0" cellpadding="2" align="center">
<tr>
<td>
<table style="width: 100%" cellpadding="0" class="style7">
<tr>
<td class="style13" style="width: 400px; color: #FF0000; font-size: 12px; text-align: center; font-weight: bold;"><?=$a1[Name]?>
</td>
</tr>
</table>
<img src="images/spacer.gif" width="1px" height="3px"></img><table style="width: 100% height: 69px;" cellpadding="0" class="style7">
<tr>
<td class="style1" valign="top">
<?=$ItemImage?>
</td>
<td class="style11">
<table style="width: 100%" class="style5">
<tr>
<td class="style12"><font color="#C0C0C0">Category:</font>&nbsp;<a href="search.php?CategoryID=<?=$a1[catid]?>"><?=$a1[CategoryName]?></a></td>
</tr>
<tr>
<td class="style12"><font color="#C0C0C0">Date:</font>&nbsp;<?=$a1[Date1]?></td>
</tr>
</table>
</td>
</tr>
</table>
<img src="images/spacer.gif" width="1px" height="3px"></img><table style="width: 100%" cellpadding="0" class="style7">
<tr>
<td class="style12"><font color="#C0C0C0">Description:</font>&nbsp;<?=nl2br($a1[Desc]);?></td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<hr style="width: 50%; height: 1px" noshade="noshade" class="style15">
<br />
</body>

</html>

balkan
02-23-2007, 12:14 AM
i have try to get this like picture, can someone help me ?
http://i12.tinypic.com/2lm1nww.jpg

meth
02-23-2007, 04:58 AM
$query = mysql_query("select * from news WHERE catid=cat_id AND status = '1'");


The query has no 'ORDER BY'. Choose a column from `news` and place it after the 'ORDER BY'. MySql ordering is DESC by default. If you want to order by asc, place 'ASC' after the column name e.g:



$query = mysql_query("select * from news WHERE catid=cat_id AND status = '1' ORDER BY columnName DESC");


Trouble is, I doubt these products are held in the `news` table. The php code and the template html you've posted look unrelated. Please post the php code that applies to your template.

balkan
02-23-2007, 12:04 PM
yes code from templates/index.php look unrelated, but need code for looping to get table like picture ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum