Forum Moderators: not2easy

Message Too Old, No Replies

generating a list rather than columns

php css list bullet

         

hanyaz

12:12 pm on Dec 21, 2007 (gmt 0)

10+ Year Member



Hello,
I have a marketplace and for the featured catalogs i have in the front, the companies prods displayed with a table.
Columns are generated when a new product has to be displayed .
However, i want them appear in a div container and be listed with <li>....reproducing the table effect with css.
The code is below
Thanks for your help
yaz


<div align="center">
<?
////////------getting gold members
mt_srand((double)microtime()*1000000);
$sbq1_mem="select * from b2b_members where sb_memtype=1";
$sbrs1_mem=mysql_query($sbq1_mem);
$sbgold_list="0";
while($sbrow1_mem=mysql_fetch_array($sbrs1_mem))
{
$sbgold_list.=",".$sbrow1_mem["sb_id"];
}

$sbq_off="select *,UNIX_TIMESTAMP(sb_postedon) as sbposted from b2b_products where sb_approved='yes' and sb_uid in ($sbgold_list) order by sb_id desc";
//echo($sbq_off);
$sbrs_off=mysql_query($sbq_off);
$sbrow_count=mysql_num_rows($sbrs_off);
if( ($sbrow_count > 0) && ($sb_feature_count > 0) )
{
if( ($sbrow_count <= $sb_feature_count) )
{///////------no need of random coz records are not enough
?>
<table width="90%" border="0" cellspacing="1" cellpadding="0" class="seperatorstyle">
<tr>
<td colspan="<?php echo $sb_no_of_columns;?>" class="titlestyle"><strong>&nbsp;Featured
Product Catalogs</strong></td>
</tr>
<?php
$sb_td_count=0;
while( $sbrow_off=mysql_fetch_array($sbrs_off) )
{
if($sb_td_count%$sb_no_of_columns == 0)
{?>
<tr>
<?php }
?>
<td width="<?php echo round(100/$sb_no_of_columns);?>%" height="100%">
<table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0" class="innertablestyle">
<tr valign="top" >
<td width="60">
<?php
$sbq_img_off="select * from b2b_product_images where sb_offer_id=".$sbrow_off["sb_id"];
$sbrow_img_off=mysql_fetch_array(mysql_query($sbq_img_off));
if($sbrow_img_off)
{?>
<div align="center"><a href="view_product.php?id=<?php echo $sbrow_off["sb_id"];?>"><img src="<? echo $img_path;?><?php echo $sbrow_img_off["sb_img_url"];?>" <? echo $img_pmt;?> border="0" title="<?php echo $sbrow_off["sb_title"];?>"></a>
<?php }//end if
else
{
?>
<a href="view_product.php?id=<?php echo $sbrow_off["sb_id"];?>"><img src="images/nopic.gif" <? echo $img_pmt;?> border="0" title="<?php echo $sbrow_off["sb_title"];?>"></a>
<?php }//end else
?>
</div></td>
<td width="100%"><font class="red"><strong>[
<?php
$mem=mysql_fetch_array(mysql_query("select * from b2b_members where sb_id=".$sbrow_off["sb_uid"]));
$profile=mysql_fetch_array(mysql_query("select * from b2b_companyprofiles where sb_uid=".$sbrow_off["sb_uid"]));
if ($profile)
echo $profile["sb_companyname"];
else
echo $mem["sb_username"];?>
]</strong></font><br> <font class="smalltext">
<?php
if (strlen (strip_tags($sbrow_off["sb_description"]))>50)
{
echo substr(strip_tags($sbrow_off["sb_description"]), 0, strrpos( substr(strip_tags($sbrow_off["sb_description"]), 0, 50),' ' )) . "...";
}
else
{
echo strip_tags($sbrow_off["sb_description"]);
}

?></font></td>
</tr>
<tr valign="top">
<td colspan="2"><a href="view_product.php?id=<?php echo $sbrow_off["sb_id"];?>">
<?php if (strlen ($sbrow_off["sb_title"])>25)
{
echo substr($sbrow_off["sb_title"], 0, strrpos( substr($sbrow_off["sb_title"], 0, 25),' ' ));
}
else
{
echo $sbrow_off["sb_title"];
}
//echo $sbrow_off['sb_title'];?>
</a></td>
</tr>
</table></td>
<?php
$sb_td_count++;
if($sb_td_count%$sb_no_of_columns == 0)
{?>
</tr>
<?php }
?>
<?php
}//end while
//////-------padding empty tds
$sb_remainder=$sb_td_count%$sb_no_of_columns;
if($sb_remainder==0)
{
$sb_no_of_pads=0;
}
else
{
$sb_no_of_pads=$sb_no_of_columns-$sb_remainder;
}

for($sb_new_counter=1;$sb_new_counter<=$sb_no_of_pads;$sb_new_counter++)
{
?>
<td width="<?php echo round(100/$sb_no_of_columns);?>%" height="100%">
<table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td class="innertablestyle"> <font class="red"><strong>YOUR FREE ADD </strong></font></td>
</tr>
<tr>
<td class="innertablestyle"> <font class="smalltext"> Register for FREE and your offer will appear here! </font></td>
</tr>
</table></td>
<?php
}//end for padding?>
</table>
<?php
}//end if no need of random
else
{// generate random
/////////////////////////////-------------------------------
unset($number);
$number[0]=-1;
for($i=0;$i<$sb_feature_count;$i++)
{
$unique=0;
while($unique==0)
{
$j=mt_rand(1,$sbrow_count);
for($k=0;$k<count($number);$k++)
{
//echo $j;
if($number[$k]==$j)
break;
}
if($k>(count($number)-1))
{
$unique=1;
}
}
$number[$i]=$j;
}

//echo "$sbtotal_in_rs hi";
/*for($k=0;$k<count($number);$k++)
{
echo $number[$k]." ";
}
//die();
*/
//////////////////////////---------------------------------
?>
<table width="90%" border="0" cellspacing="1" cellpadding="0" class="seperatorstyle">
<tr>
<td colspan="<?php echo $sb_no_of_columns;?>" class="titlestyle"><strong>&nbsp;Featured
Product Catalogs</strong></td>
</tr>
<?php

$sbcounter=0;
$i=0;
$sb_td_count=0;
while( ($i<$sb_feature_count) ) //&& ($sbcounter >= 0) )
{
//echo "I is $i, ";
if( $sbrow_off=mysql_fetch_array($sbrs_off) )
$sbcounter++;
//else
//$sbcounter=-1;
for($j=0;$j<count($number);$j++)
{
if( ($sbcounter == $number[$j]) )
{
if($sb_td_count%$sb_no_of_columns == 0)
{?>
<tr >
<?php }
?>
<td width="<?php echo round(100/$sb_no_of_columns);?>%" height="100%" valign="top">
<table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0" class="innertablestyle">
<tr valign="top" >
<td width="60">
<?php
$sbq_img_off="select * from b2b_product_images where sb_offer_id=".$sbrow_off["sb_id"];
$sbrow_img_off=mysql_fetch_array(mysql_query($sbq_img_off));
if($sbrow_img_off)
{?>
<div align="center"><a href="view_product.php?id=<?php echo $sbrow_off["sb_id"];?>"><img src="<? echo $img_path;?><?php echo $sbrow_img_off["sb_img_url"];?>" <? echo $img_pmt;?> border="0" title="<?php echo $sbrow_off["sb_title"];?>"></a>
<?php }//end if
else
{
?>
<a href="view_product.php?id=<?php echo $sbrow_off["sb_id"];?>"><img src="images/nopic.gif" <? echo $img_pmt;?> border="0" title="<?php echo $sbrow_off["sb_title"];?>"></a>
<?php }//end else
?>
</div></td>
<td width="100%"><font class="red"><strong>[
<?php
$mem=mysql_fetch_array(mysql_query("select * from b2b_members where sb_id=".$sbrow_off["sb_uid"]));
$profile=mysql_fetch_array(mysql_query("select * from b2b_companyprofiles where sb_uid=".$sbrow_off["sb_uid"]));
if ($profile)
echo $profile["sb_companyname"];
else
echo $mem["sb_username"];?>
]</strong></font><br> <font class="smalltext">
<?php
if (strlen (strip_tags($sbrow_off["sb_description"]))>50)
{
echo substr(strip_tags($sbrow_off["sb_description"]), 0, strrpos( substr(strip_tags($sbrow_off["sb_description"]), 0, 50),' ' )) . "...";
}
else
{
echo strip_tags($sbrow_off["sb_description"]);
}
?>
</font></td>
</tr>
<tr valign="top">
<td colspan="2"><a href="view_product.php?id=<?php echo $sbrow_off["sb_id"];?>">
<?php if (strlen ($sbrow_off["sb_title"])>25)
{
echo substr($sbrow_off["sb_title"], 0, strrpos( substr($sbrow_off["sb_title"], 0, 25),' ' ));
}
else
{
echo $sbrow_off["sb_title"];
}
//echo $sbrow_off['sb_title'];?>
</a></td>
</tr>
</table></td>
<?php
$sb_td_count++;
if($sb_td_count%$sb_no_of_columns == 0)
{?>
</tr>
<?php }
?>
<?php
$i++;//one add displayed
break;//after showing the add
}//end if sbcounter == number[j]
}//for loop j
}//end while
//////-------padding empty tds
//echo "td count $sb_td_count, sb_no_of_columns $sb_no_of_columns ";
$sb_remainder=$sb_td_count%$sb_no_of_columns;
$sb_no_of_pads=($sb_remainder!=0)?$sb_no_of_columns-$sb_remainder:0;
for($sb_new_counter=1;$sb_new_counter<=$sb_no_of_pads;$sb_new_counter++)
{
?>
<td width="<?php echo round(100/$sb_no_of_columns);?>%" height="100%">
<table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td class="innertablestyle"> <font class="red"><strong>YOUR FREE ADD </strong></font></td>
</tr>
<tr>
<td class="innertablestyle"> <font class="smalltext"> Register for FREE and your offer will appear here! </font></td>
</tr>
</table></td>
<?php
}//end for padding?>
</table>
<?php
}//end else generate random
}//end if ($sbrow_count > 0) && ($sb_feature_count > 0)
?>
</div>

tedster

3:39 pm on Dec 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My first impression is that this actually IS tabular information and deserves to be presented in a table.

But if you are set on doing it a different way - what is the CSS issue you are up against? There is a lot of PHP and HTML involved here (and they both have their own forums) but I can quite get what CSS is giving you troubles.

Also, you probably should trim down the code to the CSS problem - that's a lot of code to hope others will wade through. See our Guide to Posting HTML and CSS [webmasterworld.com].

If you ask the community here to do all the work for you, then it's not very likely you will get help for the specific question you need answered ;)

hanyaz

5:23 pm on Dec 21, 2007 (gmt 0)

10+ Year Member



Ok it is fine,
i have found a solution, was not that easy for me but after many trials it is wroking.
Yes i know that there is a lot of php involved here but as my problem was related with css i posted here, i did not need to solve any php error or sthg else...just needed to display in the way i opted.
My problem here was that for every new entry a table was generated, i wanted first to display the entries through a listing and float them left, but as you said it deserves to be diplayed through a table.
thanks for your answer
hanyaz