You are invited to Log in or Register a free Frihost Account!

Storing data to previous pages

OKay, maybe the headline is bit wrong but what i want to do is this:

I have textbox which sends data to my databases, you can also view what people have entered etc. What i want to do is this. Lets say i have fixed table height about 1000px. I don't want that script stores more, iwanted to old ones move to page 2 etc. example is here , My site . Thanks for helping.

PS the textbox need 10 or more chars to post and name 4 or more
It's easier to show a fixed number of posts at each page than working with pixel heights. You can do something like this in mysql:
SELECT * FROM table ORDER BY post_id LIMIT page*10,10

Here I order by post_id but you can use what ever you want (e.g. a timestamp). 10 is the number of posts per page. page should be replaced by the page number.
Hmm, I used it like that
$result = mysql_query("SELECT * FROM postid ORDER BY p_id DESC LIMIT page*10,10 ");

while($row = mysql_fetch_array($result))

and I got error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mihkel/domains/ on line 37

Any problem with fetch or ... ?
You need to replace page with the page number like:

$page = 1;
$result = mysql_query("SELECT * FROM postid ORDER BY p_id DESC LIMIT $page*10,10 ");

Also note that the way this is written page 0 will be the first page.
Gosh, that seems to be hard, I'm new at it so I cant make it.
Fire Boar
Never say "can't". If you're trying to do a database query, you definitely need to know how to make it dynamic.

Say you want to tack ?page=1 onto each page, replacing 1 with the page number. Simply use $_GET['page'] to determine which page you are after.

// Get the first entry to query for
// Default to page 1
$start = 0
if (is_numeric($_GET['page']))
  $start = ($_GET['page'] - 1) * 10;
// Run the query. Note that mysql_query returns false and flags an error if the query fails, you can
// use this if statement to discover the error. Very helpful in debugging.
if (!$result = mysql_query("SELECT * FROM postid ORDER BY p_id DESC LIMIT $start, 10"))

while ($row = mysql_fetch_array($result))
  // Do stuff
Now I got it, very appreciated, it stores 10 post per page and then others just go somewhere I don't know Wink . Now I need to create some page to lead ?page=1 ?page=2 and so ?

Someway the script must to them itself.

e/ ahh, they go ?page=2 the old posts Wink . I manually went to page2 .
Fire Boar
Yes, if you have a file like:

You'd access page 2 by

There's no need for an extra file or anything. Incidentally, you can see _GET variables in action with the forums - if you click post reply and look at the address and you'll see the file is posting.php, with some extra _GET variables (such as t=111607).
Yeap I got it thanks Wink
Related topics
What is all the hype about GMail?
PHP Question - Solved
-<[ Get the website of your greatest desires!!! ]>-
[*RESOLVED*]Please close for me
Java - Storing data in a file
question on vb language and mysql...
Programming in Assembly Language: x86 - reserved pixel?
Some not so commonly asked questions.
IBM v/s AMAZON the legal battle starts
Can a machine know?
One Click and boom! - Random Topic
New organic material for transferring data
Transfer data between pages on different servers?
Freedom and Privacy.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.