Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

How i can get random photos from only one category?

Asked Modified Viewed 3,721 times
F
FlancitoW
F
  • Member, joined since
  • Contributed 115 posts on the community forums.
  • Started 36 threads in the forums
  • Started this discussions
asked
Member

I need a panel to show random photos for only one category. How i can do that?
0 replies

11 posts

C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Quote

FlancitoW wrote:

I need a panel to show random photos for only one category. How i can do that?


Probably not, do you want to make it or will I make it?
0 replies
H
HobbyMan
H
Just some Guy
  • Veteran Member, joined since
  • Contributed 1,486 posts on the community forums.
  • Started 91 threads in the forums
answered
Veteran Member

Create a new panel and add this into panel content...

// Set Album ID
$album_id = "1";

  $result = dbquery("SELECT photo_id, album_id, photo_title, photo_thumb1 FROM ".DB_PHOTOS." WHERE album_id = '".$album_id."' ORDER BY RAND() LIMIT 1");

   if (dbrows($result) != 0) {
openside("Random Photo");
   echo "<div align='center'>";
     while($data = dbarray($result)) {
     
     $data_album = dbarray(dbquery("SELECT album_id, album_title FROM ".DB_PHOTO_ALBUMS." where album_id = ".$data['album_id'].""));

     $itemsubject = trimlink($data['photo_id'], 23);
     $itemdescription = trimlink($data['photo_title'], 30);
     $albumname = trimlink($data_album['album_title'], 30);
     echo "<center>".$new."<a href='".BASEDIR."photogallery.php?photo_id=".$data['photo_id']."' title='".$data['photo_title']."' class='side'>";
     echo "<img src='".BASEDIR."images/photoalbum/"."album_".$data['album_id']."/".$data['photo_thumb1']."' border='0' alt='' /><br />".$itemdescription."</a><br />";
     echo "<span class='small'><a href='".BASEDIR."photogallery.php?album_id=".$data['album_id']."' title='".$data_album['album_title']."' class='side'>".$albumname."</a></span></center>";
        }
     echo "</div>";
closeside();
         }


Set album id to suit
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Great that's it.
0 replies
— 8 months later —
H
HaYaLeT
H
  • Senior Member, joined since
  • Contributed 262 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

Very good,i like it..but how is prevention some album id..exapmle: i want album id 1,2,3,5 dont want 4

Thanks..

EDIT: Ok! should be same this: AND $album_id!='4'

Now,how to add multiple id? Dou you have any idea about it?
Example:$album_id='1,2' or $album_id!='4,5,6'

Thank you..
Edited by HaYaLeT on 08-05-2012 04:43,
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

The query needs to be changed. then seperate each album with comma and space in $album_id...
WHERE album_id IN (".$album_id.")


should work. I didn't try...
0 replies
H
HaYaLeT
H
  • Senior Member, joined since
  • Contributed 262 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

Tyler,thank you for reply.. But how to use it in latest or random contents ?

Example: how to use $album_id='1,2,8' or $album_id!='4,5,6' in latest news,latest images codes?

my latest news codes:

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$cat_id1 = "1";
echo '<div class="duyuruarka">
<div id="duyuru">';
$result = dbquery("SELECT tn.*, tc.*, user_id, user_name FROM ".DB_NEWS." tn
LEFT JOIN ".DB_USERS." tu ON tn.news_name=tu.user_id
LEFT JOIN ".DB_NEWS_CATS." tc ON tn.news_cat=tc.news_cat_id
WHERE ".groupaccess('news_visibility'wink."
AND (news_start='0'||news_start<=".time()."wink
AND (news_end='0'||news_end>=".time()."wink
AND news_draft='0'
AND news_cat_id='$cat_id1'
ORDER BY news_sticky DESC, news_datestamp DESC LIMIT 0,4"wink;
if (dbrows($result)) {
while ($data = dbarray($result)) {
echo ' <div class="ic"><a class="haber" href="'.BASEDIR.'news_cats.php?cat_id='.$data['news_cat_id'].'" title="'.$data['news_subject'].'">'.trimlink(stripslashes($data['news_subject']),40).'</a></div>';

}}

echo '</div>
</div>';[/syntaxhighlighter]
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

This is how you set multiple id's
$cat_id1 = "1, 3, 7";

my phone cuts off geshi coding so I couldnt just edit..

find
AND news_cat_id='$cat_id1'

change to
AND news_cat_id IN (".$cat_id1.")
0 replies
H
HaYaLeT
H
  • Senior Member, joined since
  • Contributed 262 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

That's it,great..Thank you Tyler
dizaynegitim.com/images/smiley/bravo.gif


Can we prevention multiple cat id ?


$cat_id!='4,5,6' (prevention news cat id 4,5 and 6)


Latest news (all cats)
  $result = dbquery("SELECT photo_id, album_id, photo_title, photo_thumb1 FROM ".DB_PHOTOS." WHERE album_id = '".$album_id."' ORDER BY RAND() LIMIT 4");

    if (dbrows($result) != 0) {
 openside("Random Photo");
    echo "<div align='center'>";
      while($data = dbarray($result)) {
     
      $data_album = dbarray(dbquery("SELECT album_id, album_title FROM ".DB_PHOTO_ALBUMS." where album_id = ".$data['album_id'].""));

      $itemsubject = trimlink($data['photo_id'], 23);
      $itemdescription = trimlink($data['photo_title'], 30);
      $albumname = trimlink($data_album['album_title'], 30);
      echo "<center>".$new."<a href='".BASEDIR."photogallery.php?photo_id=".$data['photo_id']."' title='".$data['photo_title']."' class='side'>";
      echo "<img src='".BASEDIR."images/photoalbum/"."album_".$data['album_id']."/".$data['photo_thumb1']."' border='0' alt='' /><br />".$itemdescription."</a><br />";
      echo "<span class='small'><a href='".BASEDIR."photogallery.php?album_id=".$data['album_id']."' title='".$data_album['album_title']."' class='side'>".$albumname."</a></span></center>";
         }
      echo "</div>";
 closeside();
          }
0 replies
T
Tyler
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums
answered
Member

you can simply use
AND news_cat_id NOT IN (".$cat_id1.")
0 replies
H
HaYaLeT
H
  • Senior Member, joined since
  • Contributed 262 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

Oh, thank you very much..
0 replies
— 1 year later —
R
Ralph68
R
Regards,
Ralph
  • Member, joined since
  • Contributed 108 posts on the community forums.
  • Started 1 thread in the forums
answered
Member

I realize this is a old thread but I could really use this for my website but when I paste the code in to panel content it messes up the hole website. Can this be adjusted to work with v7.02.06? and can the image size be set to a specific value?

Quote

HobbyMan wrote:

Create a new panel and add this into panel content...

// Set Album ID
$album_id = "1";

  $result = dbquery("SELECT photo_id, album_id, photo_title, photo_thumb1 FROM ".DB_PHOTOS." WHERE album_id = '".$album_id."' ORDER BY RAND() LIMIT 1");

   if (dbrows($result) != 0) {
openside("Random Photo");
   echo "<div align='center'>";
     while($data = dbarray($result)) {
     
     $data_album = dbarray(dbquery("SELECT album_id, album_title FROM ".DB_PHOTO_ALBUMS." where album_id = ".$data['album_id'].""));

     $itemsubject = trimlink($data['photo_id'], 23);
     $itemdescription = trimlink($data['photo_title'], 30);
     $albumname = trimlink($data_album['album_title'], 30);
     echo "<center>".$new."<a href='".BASEDIR."photogallery.php?photo_id=".$data['photo_id']."' title='".$data['photo_title']."' class='side'>";
     echo "<img src='".BASEDIR."images/photoalbum/"."album_".$data['album_id']."/".$data['photo_thumb1']."' border='0' alt='' /><br />".$itemdescription."</a><br />";
     echo "<span class='small'><a href='".BASEDIR."photogallery.php?album_id=".$data['album_id']."' title='".$data_album['album_title']."' class='side'>".$albumname."</a></span></center>";
        }
     echo "</div>";
closeside();
         }


Set album id to suit
Edited by Ralph68 on 24-05-2013 05:09,
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 11 posts
  • Votes 0 votes
  • Topic users 6 members

6 participants

C
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
R
R
Regards,
Ralph
  • Member, joined since
  • Contributed 108 posts on the community forums.
  • Started 1 thread in the forums
H
H
Just some Guy
  • Veteran Member, joined since
  • Contributed 1,486 posts on the community forums.
  • Started 91 threads in the forums
F
F
  • Member, joined since
  • Contributed 115 posts on the community forums.
  • Started 36 threads in the forums
  • Started this discussions
H
H
  • Senior Member, joined since
  • Contributed 262 posts on the community forums.
  • Started 28 threads in the forums
T
T
Tyler 10
Helping, would be pointing you in the right direction, not doing it all for you.
  • Member, joined since
  • Contributed 198 posts on the community forums.
  • Started 3 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet