icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Need some help here please!!!

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old October 23rd, 2004, 12:35 PM   #19 (permalink)
Surpass Fan
Comfy Contributor
 
pbflash's Avatar
 
Joined in Sep 2004
209 posts
Gave thanks: 0
Thanked 0 times
Our line numbers aren't matching up. You probably have a few blank lines that I don't. Either way, did you add the semi colon after $num = $num + 1
__________________
Pass14
www.tqwebservices.com
www.autoappraisalsunlimited.com
www.clevelandlayne.com
Pass18
www.estateagency.com.au

Some people drink deeply from the fountain of knowledge. Others just gargle.
pbflash is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 23rd, 2004, 12:38 PM   #20 (permalink)
Registered User
Comfy Contributor
 
blaze's Avatar
 
Joined in Aug 2004
Lives in Las Vegas
Hosted on pass11, pass12
187 posts
Gave thanks: 0
Thanked 0 times
Here is my current code and YES, I did add the semi colon:

PHP Code:
<?php

/**
* Hot Property's Featured Property Module with Pictures
*
* [at]package Hot Property 0.9
* [at]copyright (C) 2004 Lee Cher Yeong
* [at]url [url]http://www.Mosets.com/[/url]
* [at]author Lee Cher Yeong <cy[at]mosets.com>
**/

defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

# Include the config file
require( $mosConfig_absolute_path.'/administrator/components/com_hotproperty/config.hotproperty.php' );

# Include the language file. Default is English
if ($hp_language=='') {
    
$hp_language='english';
}
include_once(
'components/com_hotproperty/language/'.$hp_language.'.php');

# Get params 
$count intval$params->get'count') ); 
$direction $params->get'direction''vertical' ); 

# Get total number of published featured items 
$database->setQuery"SELECT COUNT(*) AS total FROM #__hp_properties AS p" 
    
"\nLEFT JOIN #__hp_prop_types AS t ON t.id=p.type" 
    
.    "\nWHERE p.published=1 AND p.approved=1 AND t.published=1" 
    
"\n AND p.featured=1" 
    
"\n    AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())" 
    
"\n    AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())"); 
$total $database->loadResult(); 
$num 1
# Get Itemid, determine if the HP component is published 
$database->setQuery("SELECT id FROM #__menu" 
    
.    "\nWHERE link='index.php?option=com_hotproperty'" 
    
.    "\nLIMIT 1"); 
$Itemid $database->loadResult(); 

# Get all featured property 
$database->setQuery"SELECT p.* FROM #__hp_properties AS p" 
        
"\nLEFT JOIN #__hp_prop_types AS t ON p.type = t.id" 
        
"\nLEFT JOIN #__hp_featured AS f ON f.property = p.id" 
        
"\nWHERE p.published='1' AND p.approved='1' AND t.published='1'" 
        
"\n    AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())" 
        
"\n    AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())" 
        
.    "\nAND p.featured='1'" 
        
"\nORDER BY f.ordering RAND" 
        
"nLIMIT 0, ".$count ); 
    
$featured $database->loadObjectList(); 
?> 
<table cellpadding="1" cellspacing="1" border="0" width="100%"> 
<?php if ($direction == 'horizontal') echo "<tr>"?> 
<?php foreach($featured AS $f) { 
    unset(
$thumb); 
    
# Get the first thumbnail of the property 
    
$database->setQuery"SELECT thumb, title FROM #__hp_photos" 
        
"\nWHERE property='".$f->id."'" 
        
"\nORDER BY ordering ASC" 
        
"\nLIMIT 0,1"); 
    
$database->loadObject($thumb); 

    if (
$thumb->thumb <> '') { 
        
$thumb_imgsize GetImageSize ($mosConfig_absolute_path.$hp_imgdir_thumb.$thumb->thumb); 
    } else { 
        
$thumb_imgsize GetImageSize ($mosConfig_absolute_path.$hp_imgdir_thumb.$hp_img_noimage_thumb); 
    } 

?> 
    <?PHP if ($num == 6){ 
        echo 
'<br />'
        
$num 1;
?>                                
    <?PHP if ($num == 6){ 
echo 
'<br />'
$num 1;
}
    
?>     
  <?php if ($direction == 'vertical') echo "<tr>"?><td align="center"> 
        <a href=" 
    <?php echo sefRelToAbs('index.php?option=com_hotproperty&task=view&id='.$f->id.'&Itemid='.$Itemid); ?>"><?php echo '<img '.$thumb_imgsize[3].' border="0" src="'.$mosConfig_live_site."/".$hp_imgdir_thumb.((!empty($thumb->thumb)) ? $thumb->thumb $hp_img_noimage_thumb).'" alt="'.$thumb->title.'">'?><br /> 
    <?php echo $f->name?></a></td><?php if ($direction == 'vertical') echo "</tr>"?> 
<?php ?> 
<?php if ($direction == 'horizontal') echo "</tr>"?> 
</table> 

<?php if ($total $count) { 
echo 
'<a href="' 
    
.    sefRelToAbs('index.php?option=com_hotproperty&task=viewfeatured&Itemid='.$Itemid
    .    
'">'._HP_MOREFEATURED.'</a>'
    
$num $num 1;
?>
__________________
-- BlaZe --
............
blaze is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 23rd, 2004, 12:44 PM   #21 (permalink)
Surpass Fan
Comfy Contributor
 
pbflash's Avatar
 
Joined in Sep 2004
209 posts
Gave thanks: 0
Thanked 0 times
Delete lines 72-75. You have the If statment in there twice and see what happens.
__________________
Pass14
www.tqwebservices.com
www.autoappraisalsunlimited.com
www.clevelandlayne.com
Pass18
www.estateagency.com.au

Some people drink deeply from the fountain of knowledge. Others just gargle.
pbflash is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 23rd, 2004, 1:04 PM   #22 (permalink)
Surpass Fan
Comfy Contributor
 
pbflash's Avatar
 
Joined in Sep 2004
209 posts
Gave thanks: 0
Thanked 0 times
Once you do that, the layout will probably not be right. Change lines 72-75 to:

<?PHP if ($num == 6){
echo '</tr>';
echo '<tr>';
$num = 1;
}
__________________
Pass14
www.tqwebservices.com
www.autoappraisalsunlimited.com
www.clevelandlayne.com
Pass18
www.estateagency.com.au

Some people drink deeply from the fountain of knowledge. Others just gargle.
pbflash is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 23rd, 2004, 1:16 PM   #23 (permalink)
Registered User
Comfy Contributor
 
blaze's Avatar
 
Joined in Aug 2004
Lives in Las Vegas
Hosted on pass11, pass12
187 posts
Gave thanks: 0
Thanked 0 times
Actually, I started over and went back to your first step. I realized something... you said to replace the order with . "\nORDER BY RAND" -- but actually it is suppose to be . "\nORDER BY RAND()" . That actually took care of the random order.

Now, as for breaking up my thumbs, this is a whole new ball of wax. Somebody told me to add the following code to break up the thumbs and start new rows. Here's what he said:

To control the breaking of images, use a simple counter like so (half of it is pseudo):

Code:
$cols=10;
$c=0; //counter

<table>
loop images {
    if($c%$cols==0) { echo '<tr>';}
    echo '<td><img></td>';
    $c++;
    if($c%$cols==0) { echo '</tr>';}
}
</table>
The only problem is, I have NO IDEA where to put this counter code in my script. He never told me. Do you have any ideas? Here is my current script as it stands now, and the random images are occurring -- so thanks for that!!

PHP Code:
<?php

/**
* Hot Property's Featured Property Module with Pictures
*
* [at]package Hot Property 0.9
* [at]copyright (C) 2004 Lee Cher Yeong
* [at]url [url]http://www.Mosets.com/[/url]
* [at]author Lee Cher Yeong <cy[at]mosets.com>
**/

defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

# Include the config file
require( $mosConfig_absolute_path.'/administrator/components/com_hotproperty/config.hotproperty.php' );

# Include the language file. Default is English
if ($hp_language=='') {
    
$hp_language='english';
}
include_once(
'components/com_hotproperty/language/'.$hp_language.'.php');

# Get params
$count intval$params->get'count') );
$direction $params->get'direction''vertical' );

# Get total number of published featured items
$database->setQuery"SELECT COUNT(*) AS total FROM #__hp_properties AS p"
    
"\nLEFT JOIN #__hp_prop_types AS t ON t.id=p.type"
    
.    "\nWHERE p.published=1 AND p.approved=1 AND t.published=1"
    
"\n AND p.featured=1"
    
"\n    AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())"
    
"\n    AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())");
$total $database->loadResult();

# Get Itemid, determine if the HP component is published
$database->setQuery("SELECT id FROM #__menu"
    
.    "\nWHERE link='index.php?option=com_hotproperty'"
    
.    "\nLIMIT 1");
$Itemid $database->loadResult();

# Get all featured property
$database->setQuery"SELECT p.* FROM #__hp_properties AS p"
        
"\nLEFT JOIN #__hp_prop_types AS t ON p.type = t.id"
        
"\nLEFT JOIN #__hp_featured AS f ON f.property = p.id"
        
"\nWHERE p.published='1' AND p.approved='1' AND t.published='1'"
        
"\n    AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())"
        
"\n    AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())"
        
.    "\nAND p.featured='1'"
        
"\nORDER BY RAND()"
        
"\nLIMIT 0, ".$count );
    
$featured $database->loadObjectList();
?>
<table cellpadding="1" cellspacing="1" border="0" width="100%">
<?php if ($direction == 'horizontal') echo "<tr>"?>
<?php 
foreach($featured AS $f) { 
    unset(
$thumb);
    
# Get the first thumbnail of the property
    
$database->setQuery"SELECT thumb, title FROM #__hp_photos"
        
"\nWHERE property='".$f->id."'"
        
"\nORDER BY ordering ASC"
        
"\nLIMIT 0,1");
    
$database->loadObject($thumb);

    if (
$thumb->thumb <> '') {
        
$thumb_imgsize GetImageSize ($mosConfig_absolute_path.$hp_imgdir_thumb.$thumb->thumb); 
    } else {
        
$thumb_imgsize GetImageSize ($mosConfig_absolute_path.$hp_imgdir_thumb.$hp_img_noimage_thumb); 
    }

?>
  <?php if ($direction == 'vertical') echo "<tr>"?><td align="center">
        <a href="
    <?php echo sefRelToAbs('index.php?option=com_hotproperty&task=view&id='.$f->id.'&Itemid='.$Itemid); ?>"><?php echo '<img '.$thumb_imgsize[3].' border="0" src="'.$mosConfig_live_site."/".$hp_imgdir_thumb.((!empty($thumb->thumb)) ? $thumb->thumb $hp_img_noimage_thumb).'" alt="'.$thumb->title.'">'?><br />
    <?php echo $f->name?></a></td><?php if ($direction == 'vertical') echo "</tr>"?>
 <?php ?>
<?php 
if ($direction == 'horizontal') echo "</tr>"?>
</table>

<?php if ($total $count) { 
echo 
'<a href="'
    
.    sefRelToAbs('index.php?option=com_hotproperty&task=viewfeatured&Itemid='.$Itemid)
    .    
'">'._HP_MOREFEATURED.'</a>';
?>
__________________
-- BlaZe --
............

Last edited by blaze; October 23rd, 2004 at 1:18 PM..
blaze is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 23rd, 2004, 1:22 PM   #24 (permalink)
Surpass Fan
Comfy Contributor
 
pbflash's Avatar
 
Joined in Sep 2004
209 posts
Gave thanks: 0
Thanked 0 times
The couter you have would work but it would just display the images, not the link. Give this a try:

PHP Code:
<?php 

/** 
* Hot Property's Featured Property Module with Pictures 

* [at]package Hot Property 0.9 
* [at]copyright (C) 2004 Lee Cher Yeong 
* [at]url [url]http://www.Mosets.com/[/url] 
* [at]author Lee Cher Yeong <cy[at]mosets.com> 
**/ 

defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 

# Include the config file 
require( $mosConfig_absolute_path.'/administrator/components/com_hotproperty/config.hotproperty.php' ); 

# Include the language file. Default is English 
if ($hp_language=='') { 
    
$hp_language='english'

include_once(
'components/com_hotproperty/language/'.$hp_language.'.php'); 

# Get params 
$count intval$params->get'count') ); 
$direction $params->get'direction''vertical' ); 

# Get total number of published featured items 
$database->setQuery"SELECT COUNT(*) AS total FROM #__hp_properties AS p" 
    
"\nLEFT JOIN #__hp_prop_types AS t ON t.id=p.type" 
    
.    "\nWHERE p.published=1 AND p.approved=1 AND t.published=1" 
    
"\n AND p.featured=1" 
    
"\n    AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())" 
    
"\n    AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())"); 
$total $database->loadResult(); 
$num 1;

# Get Itemid, determine if the HP component is published 
$database->setQuery("SELECT id FROM #__menu" 
    
.    "\nWHERE link='index.php?option=com_hotproperty'" 
    
.    "\nLIMIT 1"); 
$Itemid $database->loadResult(); 

# Get all featured property 
$database->setQuery"SELECT p.* FROM #__hp_properties AS p" 
        
"\nLEFT JOIN #__hp_prop_types AS t ON p.type = t.id" 
        
"\nLEFT JOIN #__hp_featured AS f ON f.property = p.id" 
        
"\nWHERE p.published='1' AND p.approved='1' AND t.published='1'" 
        
"\n    AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())" 
        
"\n    AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())" 
        
.    "\nAND p.featured='1'" 
        
"\nORDER BY RAND()" 
        
"\nLIMIT 0, ".$count ); 
    
$featured $database->loadObjectList(); 
?> 
<table cellpadding="1" cellspacing="1" border="0" width="100%"> 
<?php if ($direction == 'horizontal') echo "<tr>"?> 
<?php foreach($featured AS $f) { 
    unset(
$thumb); 
    
# Get the first thumbnail of the property 
    
$database->setQuery"SELECT thumb, title FROM #__hp_photos" 
        
"\nWHERE property='".$f->id."'" 
        
"\nORDER BY ordering ASC" 
        
"\nLIMIT 0,1"); 
    
$database->loadObject($thumb); 

    if (
$thumb->thumb <> '') { 
        
$thumb_imgsize GetImageSize ($mosConfig_absolute_path.$hp_imgdir_thumb.$thumb->thumb); 
    } else { 
        
$thumb_imgsize GetImageSize ($mosConfig_absolute_path.$hp_imgdir_thumb.$hp_img_noimage_thumb); 
    } 

?> 
<?PHP if ($num == 6){ 
echo 
'</tr';
echo 
'<tr>'
$num 1

  <?
php if ($direction == 'vertical') echo "<tr>"?><td align="center"> 
        <a href=" 
    <?php echo sefRelToAbs('index.php?option=com_hotproperty&task=view&id='.$f->id.'&Itemid='.$Itemid); ?>"><?php echo '<img '.$thumb_imgsize[3].' border="0" src="'.$mosConfig_live_site."/".$hp_imgdir_thumb.((!empty($thumb->thumb)) ? $thumb->thumb $hp_img_noimage_thumb).'" alt="'.$thumb->title.'">'?><br /> 
    <?php echo $f->name?></a></td><?php if ($direction == 'vertical') echo "</tr>"?> 
<?php ?> 
<?php if ($direction == 'horizontal') echo "</tr>"?> 
</table> 

<?php if ($total $count) { 
echo 
'<a href="' 
    
.    sefRelToAbs('index.php?option=com_hotproperty&task=viewfeatured&Itemid='.$Itemid
    .    
'">'._HP_MOREFEATURED.'</a>'
    
$num $num 1
?>
__________________
Pass14
www.tqwebservices.com
www.autoappraisalsunlimited.com
www.clevelandlayne.com
Pass18
www.estateagency.com.au

Some people drink deeply from the fountain of knowledge. Others just gargle.
pbflash is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 23rd, 2004, 1:36 PM   #25 (permalink)
Registered User
Comfy Contributor
 
blaze's Avatar
 
Joined in Aug 2004
Lives in Las Vegas
Hosted on pass11, pass12
187 posts
Gave thanks: 0
Thanked 0 times
I tried it, but get this error:

Parse error: parse error, unexpected '<' in /home/******/public_html/modules/mod_hp_featuredprop_wpic.php on line 78

Line error: <?php if ($direction == 'vertical') echo "<tr>"; ?><td align="center">

So I added a new line above it: ?> to get rid of the parse error. The script now works, but it still doesn't break up the thumbs nor start a new row in the table. It spans across and expands the table, hence breaking up the layout badly. The links still work too.
__________________
-- BlaZe --
............
blaze is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 23rd, 2004, 1:58 PM   #26 (permalink)
Surpass Fan
Comfy Contributor
 
pbflash's Avatar
 
Joined in Sep 2004
209 posts
Gave thanks: 0
Thanked 0 times
Try this. If it doesn't work I'll take another look at it later as I'm on my way out with the kids.

PHP Code:
<?php 

/** 
* Hot Property's Featured Property Module with Pictures 

* [at]package Hot Property 0.9 
* [at]copyright (C) 2004 Lee Cher Yeong 
* [at]url [url]http://www.Mosets.com/[/url] 
* [at]author Lee Cher Yeong <cy[at]mosets.com> 
**/ 

defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 

# Include the config file 
require( $mosConfig_absolute_path.'/administrator/components/com_hotproperty/config.hotproperty.php' ); 

# Include the language file. Default is English 
if ($hp_language=='') { 
    
$hp_language='english'

include_once(
'components/com_hotproperty/language/'.$hp_language.'.php'); 

# Get params 
$count intval$params->get'count') ); 
$direction $params->get'direction''vertical' ); 

# Get total number of published featured items 
$database->setQuery"SELECT COUNT(*) AS total FROM #__hp_properties AS p" 
    
"\nLEFT JOIN #__hp_prop_types AS t ON t.id=p.type" 
    
.    "\nWHERE p.published=1 AND p.approved=1 AND t.published=1" 
    
"\n AND p.featured=1" 
    
"\n    AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())" 
    
"\n    AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())"); 
$total $database->loadResult(); 

# Get Itemid, determine if the HP component is published 
$database->setQuery("SELECT id FROM #__menu" 
    
.    "\nWHERE link='index.php?option=com_hotproperty'" 
    
.    "\nLIMIT 1"); 
$Itemid $database->loadResult(); 

# Get all featured property 
$database->setQuery"SELECT p.* FROM #__hp_properties AS p" 
        
"\nLEFT JOIN #__hp_prop_types AS t ON p.type = t.id" 
        
"\nLEFT JOIN #__hp_featured AS f ON f.property = p.id" 
        
"\nWHERE p.published='1' AND p.approved='1' AND t.published='1'" 
        
"\n    AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())" 
        
"\n    AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())" 
        
.    "\nAND p.featured='1'" 
        
"\nORDER BY RAND()" 
        
"\nLIMIT 0, ".$count ); 
    
$featured $database->loadObjectList(); 
?> 
$cols=6;
$c=0; //counter
<table cellpadding="1" cellspacing="1" border="0" width="100%"> 
<?php foreach($featured AS $f) { 
    unset(
$thumb); 
    
# Get the first thumbnail of the property 
    
$database->setQuery