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.
Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question problems displaying 15 things at a time.

    I want to be able to display 15 tables at a page, without making multiple pages and without using a database. Look at the page below. I want it to look like that. with links at the bottom to displat the next 15, all on the same page.
    Can anyone please help me with this?

    http://www.hostultra.com/~sponkindustries/templates.php

    Thank you.

  • #2
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    so will all the tables of info be hard coded in? if so:

    you could use a GET command in the url as to the page to view and then 'if' s in the document and program in the tables to view e.g.

    PHP Code:

    <?PHP

    $page 
    $_GET['page'];

    if (
    "$page" == 1){

    // first 15 go here

    }
    elseif (
    "$page" == 2){

    //next 15 go here

    }


    ?>
    and then at the bottom just put links

    www.domain.com/tables.php?page=1
    www.domain.com/tables.php?page=2

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, but what if in the future I had more than 30 tables, what would happen then? whould I have to add more pages to the code? I dunno, Im quite new to php and stuff.

  • #4
    New Coder
    Join Date
    Apr 2004
    Location
    Texas
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I personally found this tutorial on pagination helpful, thought I would pass it along. It's not exactly what you're trying for, but it may still be helpful.

    http://www.phpfreaks.com/tutorials/43/0.php
    Jason B

  • #5
    New Coder
    Join Date
    Apr 2004
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry but i think that is a really clever way of doing it , you gotta have some logic sense for php havent you ...woah
    ...not bad for a thirteen year old

  • #6
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    if you do use my method which is not necessarily the best but is easy you just add anouther elseif e.g.

    PHP Code:
    <?PHP 

    $page 
    $_GET['page']; 

    if (
    "$page" == 1){ 

    // first 15 go here 


    elseif (
    "$page" == 2){ 

    //next 15 go here 


    elseif (
    "$page" == 3){ 

    //next 15 go here 



    ?>
    then link to page 3

  • #7
    Regular Coder
    Join Date
    Apr 2004
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    so i put the html for the 15 tables where it says //next 15 go here

    is that right?

    and what goes where it says 'page' ???

  • #8
    Regular Coder
    Join Date
    Apr 2004
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SORRY FOR DOUBLE POSTING!

    but, I need and answer for the questions above , thank you.

  • #9
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    why don't you use a db?
    where will you store the data in?

    i would store it inside an array (if db's are no option)
    then give the links an ofset value in the querystring so that you can loop through the array and get the elements you need (your chunk of 15)

    so say your array looks like
    PHP Code:
    $arraytemplates[0]= array('title'=>' title of templateone will be here''screenshot'=>'./templates/template1.gif''comment'=>'blablabla');
    $arraytemplates[1]= array('title'=>' title of template two will be here''screenshot'=>'./templates/temp2.gif''comment'=>'more blablabla');
    ...
    $arraytemplates[89]= array('title'=>' title of template 90 will be here''screenshot'=>'./templates/templateshot12.gif''comment'=>'some blablabla'); 
    then your links will be build like
    PHP Code:
    for ($i=0;$i <= (count($arraytemplates)-1);$i += 15){
       echo 
    '<a href="' $_SERVER['PHP_SELF'] . '?ofset=' $i ' title="Show templates from ' . ($ + 1)' till ' . ($i 15) . '">' . ($ + 1)'-' . ($i 15) . '</a>&nbsp;&nbsp;';

    and your code to display them
    PHP Code:
    $cutof $_GET['ofset'] + 15 ;
    if (
    $cutof > (count($arraytemplates)-1)){
       
    $cutof = (count($arraytemplates)-1);
    }
    for (
    $i=$_GET['ofset'];$i <= $cutof;$i += 15){
       echo 
    'Template n ' . ($i+1) . ' : ' $arraytemplates[$i]['title']  
     . 
    '<br />
               Comment : ' 
    $arraytemplates[$i]['comment'] . '<br /> etc' ;  

    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #10
    Regular Coder
    Join Date
    Apr 2004
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I cant use a database because my host charges for them

    So the array will go???????
    In a seporate file?

    Im sorry, I dont have a clue, im just starting out with PHP and stuff.

  • #11
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i would store it in a seperate file.
    like
    PHP Code:
    <?php
     $arraytemplates
    [0]= array('title'=>' title of templateone will be here''screenshot'=>'./templates/template1.gif''comment'=>'blablabla'); 
    $arraytemplates[1]= array('title'=>' title of template two will be here''screenshot'=>'./templates/temp2.gif''comment'=>'more blablabla'); 
    ... 
    $arraytemplates[89]= array('title'=>' title of template 90 will be here''screenshot'=>'./templates/templateshot12.gif''comment'=>'some blablabla');  
    ?>
    and the, inside the page where you show these templates, you include it
    PHP Code:
    require('./templatearray.php');
    //rest of your code 
    This way, you can easely use it inside multiple pages + to update it, you only need to alter that one page.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #12
    Regular Coder
    Join Date
    Apr 2004
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Last edited by cragllo; 05-27-2004 at 10:39 PM.

  • #13
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    why dont you use a database?

  • #14
    Regular Coder
    Join Date
    Apr 2004
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I cant use a databese, my host wont let me, they charge.

    Someone told me that a way to do it is to have a seporade document with the html for each table in it, and each table is seporated by a charicter that is set in the code that displays the 15 per page.

    Can anyone tell me how to do that please? None of the other codes have worked for me...

  • #15
    New Coder
    Join Date
    Jun 2004
    Location
    Newcastle, England
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by cragllo
    I cant use a databese, my host wont let me, they charge.

    Dear god...get a different host!!!!!
    Beauty is in the eye of the beer-holder

    Man who smoke pot, choke on handle


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

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