SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php paging with JS slider

    Hello,

    can we do something like this using JS slider/mysql/php?


    http://sorgalla.com/projects/jcarous...ic_simple.html

    I want to show my one database selection into this slider instead of paging. can we do that? because i am trying it but as soon as i add my query and php code into it its not working.


    can anyone has worked previously on JS slider with php?

    please help me.

    thanks in advance.

  2. #2
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah its easy
    u have to replace everything with ur data only through looping with php

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    HTML Code:
      <ul id="mycarousel" class="jcarousel-skin-tango">
        <li><img src="http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg" width="75" height="75" alt="" /></li>
        <li><img src="http://static.flickr.com/75/199481072_b4a0d09597_s.jpg" width="75" height="75" alt="" /></li>
        <li><img src="http://static.flickr.com/57/199481087_33ae73a8de_s.jpg" width="75" height="75" alt="" /></li>
        <li><img src="http://static.flickr.com/77/199481108_4359e6b971_s.jpg" width="75" height="75" alt="" /></li>
        <li><img src="http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg" width="75" height="75" alt="" /></li>
        <li><img src="http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg" width="75" height="75" alt="" /></li>
    
        <li><img src="http://static.flickr.com/58/199481218_264ce20da0_s.jpg" width="75" height="75" alt="" /></li>
        <li><img src="http://static.flickr.com/69/199481255_fdfe885f87_s.jpg" width="75" height="75" alt="" /></li>
        <li><img src="http://static.flickr.com/60/199480111_87d4cb3e38_s.jpg" width="75" height="75" alt="" /></li>
        <li><img src="http://static.flickr.com/70/229228324_08223b70fa_s.jpg" width="75" height="75" alt="" /></li>
      </ul>
    Replace the width, height and src attributes with your data.

  4. #4
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah its easy
    u have to replace everything with ur data only through looping with php
    ausge, may be its easy. but the way you are suggesting its not working for me.


    thanks oddz for your reply. i know if you are if you are not using any php loop. but is not working when i am trying somthing like this

    PHP Code:
    <?  if(mysql_num_rows($sqlpage) > 0){

           while(
    $row1 $op->select($sqlpage)){ ?>
    <div class="NewArrivals">
    <div id="New_Arrivalsthum1">
    <ul id="mycarousel" class="jcarousel-skin-tango">
     <li> <a href='/profile/<?=$blog->spacereplace($row1['username']);?>/' title="<?=$row1['username']?>"><img src="<?=$retpath;?>/<?=$imagearr[0];?>" width="40" height="40" alt="<?=$row1['username']?>"/></a></li>

    <? }} ?>
    this is not working. any suggestion?

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    You should have a look at what your loop outputs. Its not what you want even if the query was functioning.

    (untested)
    PHP Code:
    $sql 'query string';
    $result mysql_query($sql);

    if(
    $result && mysql_num_rows($result)!=0) {

        echo 
    '<ul id="mycarousel" class="jcarousel-skin-tango">';
        
        while(
    $row mysql_fetch_assoc($result)) {
            
            
    $userName $row1['username'];
            
    $uri '/profile/'.$blog->spacereplace($userName);
            
    $uriImage $retpath.'/'.$imagearr[0];
        
            echo 
    '<li><a href="',$uri,'" title="',$userName,'"><img src="',$uriImage,'" width="40" height="40" alt="',$userName,'" /></li>';
        
        }
        
        echo 
    '</ul>',


    Not quite certain where variables $blog,$imagearr and $retpath are coming from though. From the way you have the code structured the image isn't changing either. Not sure whether that is a mistake or not.

    One small thing to note is that the whole point of using mysql_num_rows() is to check whether any rows have been returned. This is useful because a unordered list element shouldn't be outputted to the browser for each row but once before the loop. The loop is used to build the unordered list only if one or more rows have been returned by the query.

  6. #6
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    echo '<li><a href="',$uri,'" title="',$userName,'"><img src="',$uriImage,'" width="40" height="40" alt="',$userName,'" /></li>'
    this is somthing what you have suggested but if we are passing this value.dont you thing it should be somthing like this?

    PHP Code:
    echo '<li><a href='".$uri."' title='".$userName."'><img src='".$uriImage."' width="40" height="40" alt='".$userName."' /></li>'
    anyways this line giving me the error which says-
    parse error, unexpected '"', expecting ',' or ';' in
    Not quite certain where variables $blog,$imagearr and $retpath are coming from though.
    these are my class variables. i can understand you wont understand this since i am not putting here my entire code.

    One small thing to note is that the whole point of using mysql_num_rows() is to check whether any rows have been returned. This is useful because a unordered list element shouldn't be outputted to the browser for each row but once before the loop. The loop is used to build the unordered list only if one or more rows have been returned by the query.
    yes, you are right. actually i want to show recent visitor on perticular visitors profile with the help of ($userid) so every time i have to check with this perticular userid recent visitor are there or not.

    well using your suggestion my status is now. showing me blank page?
    any more suggestion?

  7. #7
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    PHP Code:
    $sql 'query string';
    $result mysql_query($sql);

    if(
    $result && mysql_num_rows($result)!=0) {

        echo 
    '<ul id="mycarousel" class="jcarousel-skin-tango">';
        
        while(
    $row mysql_fetch_assoc($result)) {
            
            
    $userName $row1['username'];
            
    $uri '/profile/'.$blog->spacereplace($userName);
            
    $uriImage $retpath.'/'.$imagearr[0];
        
            echo 
    '<li><a href="',$uri,'" title="',$userName,'"><img src="',$uriImage,'" width="40" height="40" alt="',$userName,'" /></a></li>';
        
        }
        
        echo 
    '</ul>';


    Is the query resulting in the expected data? That is the first thing that should be checked.

  8. #8
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    If the below doesn't work by itself with the query then your query is either incorrect or returning a empty result.

    PHP Code:
    if($result) {
            
    $rows = array();
        while(
    $row mysql_fetch_assoc($result$rows[] = $row;
            echo 
    '<pre>',print_r($rows),'</pre>';
    } else {
       echo 
    '<p>no result</p>';


  9. #9
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo '<ul id="mycarousel" class="jcarousel-skin-tango">';
    yes, if i remove this jcarousel class. its showing me result. infact i have done simple paging with my result. but the thing is i want to show all my record in the same page( i have to rather) so, i can see the on the same page.

    here is my code with paging
    PHP Code:
    <?

    $sqlpage    
    $op->runsql("SELECT  a.username,a.avatar,r.visitor_id,r.visiting_count,TIMESTAMPDIFF(MINUTE, r.recent_visited, NOW()) AS MinsSinceLastVisit FROM recent_visitor as r ,author as a WHERE (r.visitor_id = a.id) AND r.profile_owner = '$blogdata->author' ORDER BY r.recent_visited DESC  LIMIT $start$limit_value");
     if(
    mysql_num_rows($sqlpage) > 0){
    ?>
    <p class="msgText">Total <strong><?=$total_records;?></strong><?if($total_records >1){
    ?> Recent Visitor's<?}else{?> Recent Visitor<?}}?></p>
    <?
                          
    if(mysql_num_rows($sqlpage) > 0){

           while(
    $row1 $op->select($sqlpage)){
           
    $minutes_dif $row1['MinsSinceLastVisit'];

           
    $imagearr explode(",",$row1['avatar']);
            
    $imagearr[0]= preg_replace("/\/avatar\//","/small/"$imagearr[0]);


          
    ?>
          <a href='/profile/<?=$blog->spacereplace($row1['username']);?>/' title="<?=$row1['username']?>"><img src="<?=$retpath;?>/<?=$imagearr[0];?>" width="40" height="40" alt="<?=$row1['username']?>"/></a><?

           $minutes_dif 
    $row1['MinsSinceLastVisit'];
           
    $Ymin 60 24 365;
           
    $Mmin 60 24 30;
           
    $Wmin 60 24 7;
           
    $Dmin 60 24;
           
    $Hmin 60;


           
    $Y = (int)($minutes_dif $Ymin);
           
    $minutes_dif $minutes_dif &#37; $Ymin;

           
    $MON = (int)($minutes_dif $Mmin);
           
    $minutes_dif $minutes_dif $Mmin;

           
    $W = (int)($minutes_dif $Wmin);
           
    $minutes_dif $minutes_dif $Wmin;

           
    $D = (int)($minutes_dif $Dmin);
           
    $minutes_dif $minutes_dif $Dmin;

           
    $H = (int)($minutes_dif $Hmin);
           
    $minutes_dif $minutes_dif $Hmin;

            if(
    $Y ){
                  echo 
    "$Y year(s) ";

                  }else if(
    $MON 0){
                  echo 
    "$MON month(s) ";
                  }
                  else if(
    $W 0){
                  echo 
    "$W week(s) ";
                  }
                  else if(
    $D 0){
                  echo 
    "$D day(s) ";
                  }
                  else if(
    $H 0){

                  echo 
    "$H hour(s) ";
                  }


    else if(
    $minutes_dif 0) echo "$minutes_dif minute(s) ";
          echo 
    "ago";   ?>(<?=$row1['visiting_count']?>visits)<? echo"\t";

                 
    $i++;
                 }
                }
                
    /*------Paging starts-----*/
                        
    $redirect "/profile/$usrname";
                         if(
    $total_records $limit_value){
                         echo 
    "<div class='shoutboxPage'>";
                         
    msg_paging($total_records$total_rows$limit_value$start$page$total_pages$redirect);
                         echo 
    "</div>";
                         
    /*-------Paging ends------*/
                //}
                      
    }
                      
    mysql_free_result($result);
            
    mysql_free_result($sqlpage);
    }}
    can i do this with slider. dont know. please help me...

  10. #10
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <div class="NewArrivals">
    <div id="New_Arrivalsthum1"> <?
        echo '<ul id="mycarousel" class="jcarousel-skin-tango">';
    
    	   while($row1 = $op->select($sqlpage)){
    	   $minutes_dif = $row1['MinsSinceLastVisit'];
    
    	   $imagearr = explode(",",$row1['avatar']);
            $imagearr[0]= preg_replace("/\/avatar\//","/small/", $imagearr[0]);
     $userName = $row1['username'];
            $uri = '/profile/'.$blog->spacereplace($userName);
            $uriImage = $retpath.'/'.$imagearr[0];
    
            echo '<li><a href="',$uri,'" title="',$userName,'"><img src="',$uriImage,'"  width="40" height="40" alt="',$userName,'" /></a></li>';
    
        }
    
        echo '</ul>';
    
    } ?>
    </div>
    </div>
    oddz, this showing me all the records but not into sliders. showing me one be one. like this:
    meera
    john
    rahul

    my JS script
    Code JavaScript:
    <script>
    <!--
      jQuery library
    -->
    <script type="text/javascript" src="lib/jquery-1.2.3.pack.js"></script>
     
    <!--
      jCarousel library
    -->
    <script type="text/javascript" src="lib/jquery.jcarousel.pack.js"></script>
     
    <!--
      jCarousel core stylesheet
    -->
    <link rel="stylesheet" type="text/css" href="lib/jquery.jcarousel.css" />
     
    <!--
      jCarousel skin stylesheet
    -->
    <link rel="stylesheet" type="text/css" href="skins/tango/skin.css" />
     
    <style type="text/css">
     
    /**
     * Overwrite for having a carousel with dynamic width.
     */
    .jcarousel-skin-tango .jcarousel-container-horizontal {
        width: 100%;
    }
     
    .jcarousel-skin-tango .jcarousel-clip-horizontal {
        width: 100%;
    }
     
    </style>
     
    <script type="text/javascript">
     
    jQuery(document).ready(function() {
        jQuery('#mycarousel').jcarousel({
            visible: 4
        });
    });
     
    </script>
    Do i need to do any changes here?

  11. #11
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    solved my problem..

    i just need to place loop properly here.and dont need to use echo.
    here is my code
    Code:
    if(mysql_num_rows($sqlpage) > 0){
    while($row1 = $op->select($sqlpage)){
    
    
    	    $imagearr = explode(",",$row1['avatar']);
            $imagearr[0]= preg_replace("/\/avatar\//","/small/", $imagearr[0]);
           
    ?>
    <li><a href='/profile/<?=$blog->spacereplace($row1['username']);?>/' title="<?=$row1['username']?>"><img src="<?=$retpath;?>/<?=$imagearr[0];?>" width="75" height="75" alt=""/></a></li>
    <? } }?>
    
    </ul>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •