PHP Developers Network
http://forums.devnetwork.net/

Need a simple PHP code to allow for rows and colums
http://forums.devnetwork.net/viewtopic.php?f=26&t=128894
Page 1 of 1

Author:  drumguru69 [ Wed Mar 30, 2011 11:15 am ]
Post subject:  Need a simple PHP code to allow for rows and colums

I have a Joomla based module, which shows a list of featured ads in a single column. I would like to show two rows of ads, each row consisting of four ads... I have tried to copy and paste some example php, which did not work. I was hoping someone could fill in the appropriate pieces to make the module function the way I need it to... If this is not enough information... or if more files will need to be modified to make the whole system work, then please let me know.. (I am a newbie)

[syntax="php" ]<?php
/**
* @author Sanjeev Shrestha
* Default Template for Featured
*/
defined('_JEXEC') or die('Restricted access');


$baseurl=JUri::root()."images/ads";
$basepath=JPATH_ROOT.DS."images".DS."ads";

?>

<?php if(count($lists)>0) {?>
<table border="0" cellpadding="2">
<?php foreach($lists as $l){
$linkx=JRoute::_("index.php?option=com_joomlistings&c=ad&task=view&adid=".$l->id,false);
$img_src = "";
if(file_exists($basepath.DS.$l->userid.DS.$l->image."_sthm.jpg")){
$img_src = $baseurl."/".$l->userid."/".$l->image."_sthm.jpg";
}
elseif(file_exists($basepath.DS.$l->userid.DS.$l->image."_thm.jpg")){
$img_src = $baseurl."/".$l->userid."/".$l->image."_thm.jpg";
}else{
$xurl=JUri::base()."components/com_joomlistings/images";
$img_src = $xurl."/noimage_sthm.jpg";
}
?>
<tr>
<td><a href="<?php echo $linkx; ?>"><img src="<?php echo $img_src;?>" /></a></td>
<td valign="top"><a href="<?php echo $linkx; ?>"><strong><?php echo $l->title; ?> </strong></a>
<?php if($l->price>0){?>
<div class="price">
<?php echo $l->currencysymbol; ?> <?php echo number_format($l->price,2); ?> <?php echo $l->currency; ?>
</div>
<?php }?>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
echo JText::_('NO_ADS');
}
?>



[ /syntax]

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/