...

View Full Version : problems displaying 15 things at a time.



cragllo
05-15-2004, 11:28 PM
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.

anarchy3200
05-15-2004, 11:39 PM
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

$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

cragllo
05-15-2004, 11:47 PM
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.

black3842
05-16-2004, 11:29 AM
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

aspdude2004
05-16-2004, 12:47 PM
sorry but i think that is a really clever way of doing it , you gotta have some logic sense for php havent you ...woah

anarchy3200
05-16-2004, 01:13 PM
if you do use my method which is not necessarily the best but is easy you just add anouther elseif e.g.



<?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

cragllo
05-16-2004, 07:21 PM
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' ???

cragllo
05-27-2004, 09:33 PM
SORRY FOR DOUBLE POSTING! :(

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

raf
05-27-2004, 11:05 PM
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


$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


for ($i=0;$i <= (count($arraytemplates)-1);$i += 15){
echo '<a href="' . $_SERVER['PHP_SELF'] . '?ofset=' . $i . ' title="Show templates from ' . ($ + 1)i . ' till ' . ($i + 15) . '">' . ($ + 1)i . '-' . ($i + 15) . '</a>&nbsp;&nbsp;';
}

and your code to display them


$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' ;
}

cragllo
05-27-2004, 11:13 PM
I cant use a database because my host charges for them :mad:

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

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

raf
05-27-2004, 11:19 PM
i would store it in a seperate file.
like


<?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


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.

cragllo
05-27-2004, 11:23 PM
It is not working.

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

::..craig..::
06-12-2004, 09:37 PM
why dont you use a database? :confused:

cragllo
06-12-2004, 09:52 PM
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... :mad: :( :o

MrShed
06-12-2004, 10:25 PM
I cant use a databese, my host wont let me, they charge.




Dear god...get a different host!!!!! :p

cragllo
06-12-2004, 10:28 PM
name some please,

i still need to get this sorted tho...

damnnet
06-13-2004, 07:40 AM
name some please,

i still need to get this sorted tho...

http://www.2globalmart.com/multiple-domain-hosting/unix-hosting.html

plan 05. best i've ever had. good pricing.

cragllo
06-13-2004, 06:38 PM
that is good, but i dont want to pay, im only 15, and dont make much money.

fimi
06-13-2004, 08:59 PM
that is good, but i dont want to pay, im only 15, and dont make much money.
Oh ok, you might like this then:
LINK ME (http://www.freewebspace.net/forums/forumdisplay.php?f=32)
hope you find a good host!

cragllo
06-13-2004, 09:10 PM
WOW, loads of hosts!

But can anyone please answer my question?

fimi
06-13-2004, 09:51 PM
can you rephrase your question?

cragllo
06-13-2004, 10:02 PM
i want to display 10 tables per page, without creating loads of pages, and without having to move around lost of html every time i update. I dont want to use a database, coz my host wont let me (new host soon, but still i want to get this done a.s.a.p)

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

each table is a diffrent download, and i want to display 10 per page. One way i've been told is by putting the html for the tables in a seporate document and seporate each table with a defined charicter. But I have no idea how to do this, and thats why I need help...

anyone?

MrShed
06-13-2004, 10:44 PM
Why not store each different table in its own html file. Then, in a loop in php code, display each html page by reading it(using something like fread) or by including it eg:

include "table".$tableno.".php";

If you want info on these methods look them up at www.php.net....tis easy enough to understand

cragllo
06-13-2004, 10:52 PM
look at the second post, i want something like that, that did not work for me, if you could get it to work, then ill use that.
~~~~~~~~~~~~~
waht i mean is:

html for table 3
~
html for table 2
~
html for table 1

the '~' is a seporator for each table. and the code reads from that, displaying 10 tables per page, without using loads of pages, and links like
templaes.php?page=1
templaes.php?page=2
and so on...
(i can insert the links normaly)

and thats what i realy want...

newmand2
06-13-2004, 11:00 PM
im not so great at PHP, so I like to make things simple, even if it means going the long way around...

How about you have like 4 arrays stored in a separate file, for example

$picture = array('template1','template2',etc)
$description = array('description1','description2')

... you get me ...

and then sort them by date or alphabetical order or something?

and that way you can just display $picture[0] - $picture[9] etc, with the array file included at the top of each page?

thats just an idea, perhaps you can elaborate

cragllo
06-13-2004, 11:02 PM
let me just say one thing,

"I have no idea what you are saying"

MrShed
06-13-2004, 11:25 PM
let me just say one thing,

"I have no idea what you are saying"

Which to my mind means that you know virtually no PHP, and are wanting someone to basically write it for you. Do a tutorial or something from somewhere, then try and utilise some of the(very good) ideas from this thread, and if you still have trouble, come back. But no-one is going to tell you how to write it from scratch. And.....GET MYSQL

cragllo
06-13-2004, 11:29 PM
I thought this was a community, you help people...

All i want to know is one thing, yes, people have told me a few tings, but they did not work. all I want to know I how or why?

You must have startes somewhere, and I am too. I'm leaning.

newmand2
06-13-2004, 11:40 PM
OK... here goes:

Variables of each table: Picture, Title, URL, Description

In a separate file, perhaps arrays.php:


$picture = array(1 => 'picture1',2 => 'picture2')
$description = array(1 => 'description1',2 => 'description2')

and then at the top of each page: include arrays.php

then sort them, so perhaps by their key (1 and 2 in this case)

then loop through displaying the array for 1 - 10

yes, it is not explained well because it is a very unorthodox idea, yet it can be done i think

MrShed
06-13-2004, 11:45 PM
I thought this was a community, you help people...

All i want to know is one thing, yes, people have told me a few tings, but they did not work. all I want to know I how or why?

You must have startes somewhere, and I am too. I'm leaning.

Yes I totally agree. We help people on here. And yes you want to know 1 thing, but then you are ridiculing and shooting down peoples ideas because you don't know enough PHP to implement their ideas. And yes you do have to start somewhere, but not on here, this is not a PHP intro/tutorial thread. There are plenty other sites for that.

To paraphrase:
"CodingForums helps those that helps themselves"

MrShed
06-13-2004, 11:48 PM
I've just re-read that post and realised it seems harsher than i meant. What I meant was actually to help you....at your level of PHP, this forum is not really the right place for you to look. You won't manage to learn how to do anything by asking specific questions here, you need to get a decent general grounding on the language from one of the other good PHP sites that are more for starting out. You will then be in a much better position to understand and gain usefullness from help posted on here for you. It will be much more productive for you that way!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum