hi all,
i want a different views to display my products for users like in this site http://www.naaptol.com in this site user can see different views like grid view,consise view and list view and also the page displays very quickely in this site,how can i acheive this if i use like hide/show div tags the page gets too long to display becoz i must use 3 while loops for different views
any way i can acheive using only one while loop
thank u
This isnt really php necessary. It should be done using CSS's unorder list ().
There are many tutorials if you search stuff like "drop down menu css" on google. Take a look
Hope this helps
i think this can be done with show/hide divs or ul
but the products are dynamic and we need to loop for list view style and another loop for grid view like this
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?
$cond2="";
$protypename=array();
if(!empty($_GET['scat'])){ $cond2.=" and `subcat_code`='".$_GET['scat']."' ";}
if(!empty($_GET['sscat'])){ $cond2.=" and `sscat_code`='".$_GET['sscat']."' ";}
$rseall="select type_code from master_products where status=1 ".$cond2." order by pname desc";
$rresall=mysql_query($rseall);
$total=mysql_num_rows($rresall);
$protype=mysql_query("select * from product_type where type_status=1");
while($protyperow=mysql_fetch_array($protype))
{
$protypename[$protyperow['type_code']]=$protyperow['type_name'];
$protypelink[$protyperow['type_code']]=$protyperow['type_link'];
}
$rsel="select type_code,prod_code,sale_price,pname,short_desc from master_products where status=1 ".$cond2." order by pname desc limit $start,$len";
$rres=mysql_query($rsel);
$i=1;
//if($num>0){
while($rrow=mysql_fetch_array($rres))
{
?>
<tr>
<td align="center" ><div id="list"><table border="0" cellpadding="0" cellspacing="0" <? if(!empty($_GET['pid']) && $_GET['pid']==$rrow['prod_code']){ ?> background="images/top_talling.gif" bgcolor="#FBFDFC" <? } ?>>
<tr>
<td><a href="<? echo $protypelink[$rrow['type_code']]?>?pid=<?=$rrow['prod_code']?>"><img src="facile_product_uploads/<?=$_GET['cat']?>/thumbnail/<?=$rrow['prod_code']?>.jpg"alt="<?=$rrow['pname']?>" hspace="5" vspace="5" border="0"></a> </td>
<td><img src="images/spacer.gif" border="0" alt="" width="13" height="1"> </td>
<td style="width:100%;"><table cellpadding="4" cellspacing="0" border="0">
<tr>
<td><a href="<? echo $protypelink[$rrow['type_code']]?>?pid=<?=$rrow['prod_code']?>" class="procatname"><?=$rrow['pname']?></a></td>
<td align="right"><span class="alert">Product code :</span>#<?=$rrow['prod_code']?></td>
</tr>
<tr>
<td colspan="2"> <div align="justify">
<?=$rrow['short_desc']?>
</div></td>
</tr>
<tr>
<td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"><table width="100%" border="0" align="left" cellpadding="2" cellspacing="0" style="width:auto;">
<tr>
<td ><a href="<? echo $protypelink[$rrow['type_code']]?>?pid=<?=$rrow['prod_code']?>"><img src="images/button_details.gif" border="0" alt="" width="48" height="12"></a></td>
<td ><strong><img src="images/spacer.gif" border="0" alt="" width="11" height="1"><a href="<? echo $protypelink[$rrow['type_code']]?>?pid=<?=$rrow['prod_code']?>"><? echo $protypename[$rrow['type_code']];?></a></strong></td>
<td align="right" valign="middle"> </td>
<td align="right" valign="middle"><span class="style64"> Rs.
<?=$rrow['sale_price']?>
</span></td>
<td align="right" valign="middle"><a href="<? echo $protypelink[$rrow['type_code']]?>?pid=<?=$rrow['prod_code']?>"></a></td>
</tr>
</table></td>
<td align="right"><a href="<? echo $protypelink[$rrow['type_code']]?>?pid=<?=$rrow['prod_code']?>"><img src="protypeimages/<?=$rrow['type_code'];?>.gif" alt="" border="0"></a></td>
</tr>
</table></td>
</tr>
</table></td>
<? } ?></tr>
</table></div>
<div id="grid" ><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" >
<?php
$c=-3;
while($row=mysql_fetch_array($rres))
{
if(($c%3)==0){ echo '<tr valign="middle">';}
$c++;
?>
<td align="center" bgcolor="#FFFFFF"><table width="92%" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #EFEFEF">
<tr>
<td height="100" align="center" bgcolor="#FFFFFF"><a href="<? echo $protypelink[$row['type_code']]?>?pid=<?=$row['prod_code']?>"><img src="facile_product_uploads/<?=$_GET['cat']?>/thumbnail/<?=$row['prod_code']?>.jpg"alt="<?=$rrow['pname']?>" hspace="5" vspace="5" border="0"></a> </td>
</tr>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF"><a href="<? echo $protypelink[$row['type_code']]?>?pid=<?=$row['prod_code']?>" class="procatname"><?=$row['pname']?></a></td>
</tr>
<tr align="center" valign="top">
<td height="5" align="left" valign="middle" bgcolor="#FFFFFF"><p><img src="images/spacer.gif" height="1" width="1" /></p></td>
</tr>
<tr>
<td align="justify" bgcolor="#FFFFFF" class="prise"><?=$row['short_desc']?></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF" class="prise"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"><table width="100%" border="0" align="left" cellpadding="2" cellspacing="0" style="width:auto;">
<tr>
<td ><a href="<? echo $protypelink[$row['type_code']]?>?pid=<?=$row['prod_code']?>"><img src="images/button_details.gif" border="0" alt="" width="48" height="12"></a></td>
<td ><strong><img src="images/spacer.gif" border="0" alt="" width="11" height="1"><a href="<? echo $protypelink[$row['type_code']]?>?pid=<?=$row['prod_code']?>"><? echo $protypename[$row['type_code']];?></a></strong></td>
<td align="right" valign="middle"> </td>
<td align="right" valign="middle"><span class="style64"> Rs.
<?=$row['sale_price']?>
</span></td>
<td align="right" valign="middle"><a href="<? echo $protypelink[$row['type_code']]?>?pid=<?=$row['prod_code']?>"></a></td>
</tr>
</table></td>
<td align="right"><a href="<? echo $protypelink[$row['type_code']]?>?pid=<?=$row['prod_code']?>"><img src="protypeimages/<?=$row['type_code'];?>.gif" alt="" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr align="center" valign="top">
<td height="5" align="left" valign="middle" bgcolor="#FFFFFF"><p><img src="images/spacer.gif" height="1" width="1" /></p></td>
</tr>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF"><a href="viewproduct.php?ProdID=<?php echo $prow['ProdID'];?>"><img src="images/info.gif" width="41" height="17" border="0" /></a> <a href="addtocart.php?ProdID=<?php echo $prow['ProdID'];?>&home=yes"><img src="images/addcort-m.gif" width="71" height="17" border="0" /></a></td>
</tr>
</table></td>
<?php if(($c%3)==0){ echo "</tr><tr><td height='1' valign='top'> </td></tr>";} } ?>
</table></td>
</tr>
</table></div>
</td>
</tr>
<? if($i!=$pagecount && $i!=$total){?>
<tr>
<td height="1"><img src="images/spacer.gif" width="1" height="3"></td>
</tr>
<tr>
<td height="1" background="images/line_x.gif"><span style="width:100%;"><img src="images/spacer.gif" border="0" alt="" width="1" height="1"></span></td>
</tr>
<tr>
<td height="1"><img src="images/spacer.gif" width="1" height="3"></td>
</tr>
<?
$i++;
}
?>
</table>
since it has two while loops it takes much time and i used show/hide to display divs i want only one while
any ideas using arrays or ajax concept
with a jQuery toggle() event you can switch the css display properties easily, to hide/unhide divs, or use an accordion type, with nice effects.
So, you can make the three views on PHP, each of them enclosed on a single div, then use of unobtrusive javascript to generate an accordion view:
http://docs.jquery.com/UI/Accordion
Naaptol uses tabs for views, easy achievable with jQuery too:
hi thanks for a replies,iam not concered with views or how to do that my problem is dynamically we write loops in php like while($x=mysql_fetch_assoc($y)) and we loop it through to display,like wise i have to write loops for grid view,another one for consice view etc.. but i dont want to do this since it takes much time
thank you