Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    image displaying (through pagination)

    Hi I'm trying to get a code like this (from DB):

    <a href="#" onclick="window.open('image_1.html', 'Image', 'toolbar=no, status=no, scrollbars=no, menubar=no, width=100, height=100')"><img src="images-small/image_1_small.jpg" border="0"></a>

    etc ... another 50 images

    I'll show the way I paginated the records from DB when I had 1 record=1 row, maybe you could give me ideas, how to change the code, to show images the same:

    PHP Code:
    <?
    $konekcija
    =mysql_connect('127.0.0.1','*','*') or die ("Error");
    mysql_select_db('*',$konekcija);
    $vaicajums2="select * from `info` order by `id` desc";
    $rezultats=mysql_query($vaicajums2,$konekcija);

    $rindas=mysql_num_rows($rezultats);

    mysql_close($konekcija);

    @
    $lpp=$_GET['lpp'];
    if (empty(
    $lpp)){
    $lpp=1;}

    $lappuses=$rindas/10;
    $lappuses=ceil($lappuses);

    for(
    $i=0;$i<$rindas;$i++){
    $rezultats2=mysql_fetch_array($rezultats);

    if(
    $i>=($lpp*10-10)AND $i<($lpp*10)){
    $tests=explode(". "$rezultats2[0]);
    echo 
    "<b>[$rezultats2[3]]</b><br>";
    for (
    $k=0;$k<$rezultats2[1];$k++){
    echo 
    "$tests[$k]. ";
    }
    }
    }

    for(
    $j=1;$j<=$lappuses;$j++){
    if(
    $j == $lpp){
    echo 
    "<b><a href=\"?lpp=$j\">$j</a></b> ";
    } else {
    echo 
    "<a href=\"?lpp=$j\">$j</a> ";
    }

    echo 
    '<br><h1><a href="logout.php">Logout</a></h1><br>';
    }
    ?>
    The problem is that with this code, it took the records from every row - like this 1 row - 1 record, but now I have all images in one row. Can you help me? I don't know how can I count how many images I have, if all my code in DB is like this:
    Code:
    <a href="#" onclick="window.open('image_1.html', 'Image', 'toolbar=no, status=no, scrollbars=no, menubar=no, width=100, height=100')"><img src="images-small/image_1_small.jpg" border="0"></a>
    
    <a href="#" onclick="window.open('image_2.html', 'Image', 'toolbar=no, status=no, scrollbars=no, menubar=no, width=100, height=100')"><img src="images-small/image_2_small.jpg" border="0"></a>
    
    etc

  • #2
    New Coder
    Join Date
    Jun 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Does substr_count function read data from mysql too. It should be, I think. But something's wrong. Take a look. It just gives me 0 when I print out $images.

    PHP Code:
    // logging to DB...
        
    $vaicajums2="select * from `section2` where `section`= 'photo2006'";
        
    $result=mysql_query($vaicajums2,$konekcija);

        
    $images substr_count($result"</a>");
        echo 
    "$images";

        
    mysql_close($konekcija);

        @
    $lpp=$_GET['lpp'];
        if (empty(
    $lpp)){
        
    $lpp=1;}

        
    $lappuses=$images/10;
        
    $lappuses=ceil($lappuses);

        for(
    $i=0;$i<$images;$i++){
        
    $result2=mysql_fetch_array($result);

        if(
    $i>=($lpp*10-10)AND $i<($lpp*10)){
        
    $test=explode("</a> "$result2[1]);
        echo 
    "$result2[1]<br>";
        for (
    $k=0;$k<$result2[1];$k++){
        echo 
    "$test[$k]. ";
        }
        }
        }
        
    ?> 


  •  

    Posting Permissions

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