Jump to content

help with this php mysql script


simun

Recommended Posts

this script shows some news from mysql, i try to put limit 5 in query but it still show onley one news,

please can someone help me?

 

<?php

	$posebna_ponuda = $db->query("SELECT id FROM objects WHERE posebna_ponuda = 1 ORDER BY RAND() LIMIT 5");

	if (is_array($posebna_ponuda)) {
		$posebna_ponuda_object = new S_Object($posebna_ponuda[0]['id']);
		$posebna_ponuda_object->gallery->getPhotos();


		if (is_array($posebna_ponuda_object->gallery->photos)) {
			$main_photo_key = 1;
			foreach($posebna_ponuda_object->gallery->photos as $photoKey => $photo) {
				if ($photo['fields']['main']) {
					$main_photo_key = $photoKey;
					break;
				}
			}
			$photo = $posebna_ponuda_object->gallery->photos[$main_photo_key];
		}

		foreach($__constants as $c => $constant) {
			if ($constant['database']['value'] == $posebna_ponuda_object->type) {
				$posebna_ponuda_object->link = $constant['link'][$__language];
				break;
			}
		}

	?>

		<div id="izdvojeno">

            
            
<?php
	if (is_array($photo)) {
?>
            <div style="border: none; border-width:0px;padding-top: 10px;">
			<a href="/<?=$__language?>/<?=$posebna_ponuda_object->link?>/<?=$posebna_ponuda_object->id?>"><?
?><img style="border: #cccccc 1px solid; margin-right: 5px;" border="0px" alt="" src="/images/cache/objects/<?=$posebna_ponuda_object->id?>/<?=$photo['filename']?>/w-90.jpg" align="left" /><?
			?></a>
		</div>

<?php
	}
?>
<a href="/<?=$__language?>/<?=$posebna_ponuda_object->link?>/<?=$posebna_ponuda_object->id?>" class="stylep"><?php echo substr($posebna_ponuda_object->{'opis_' . $__language},0,100)?></a>

<div class="clear"></div>
		</div>
<?php
	}

?>

</div>

Link to comment
https://forums.phpfreaks.com/topic/158723-help-with-this-php-mysql-script/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.