Add 5 to a variable when a button is clicked, and re-run a for loop
Posted on
16th Feb 2014 07:03 pm by
admin
So I'm making a feedback sort of section on a website with MySQL and PHP, I've gotten the script to do everything I want except for this. I want the script to only show 5 at a time (which i have accomplished no problem), but I'm also trying to make it so that when the user clicks a button it will show the next 5 records in the database so they can view all records, but only 5 at a time. (I hope this makes sense). So I need the button to add 5 to my $start variable, and then re-run my for loop.
$start = 0;
Did you know?Explore Trending and Topic pages for more stories like this.
echo $start . "<br /><br />";
$result2 = mysql_query("SELECT * FROM testtable LIMIT $start,5") or die(mysql_error());
$row2 = mysql_fetch_array($result2);
for($counter = 1; $counter <= 5; $counter += 1)
{
echo $row2['ID'] . "<br />";
echo " Subject:<b><font color='red'> " . $row2['Subject'] . "</font></b>";
echo "<br />Message: <b>" . $row2['Message'] . "</b><br /><br />";
$row2 = mysql_fetch_array($result2);
}
mysql_close($con)
?>
<br />
<form>
<input type="button" value="submit" onclick="<?php $start += 5; ?>" />
</form>
<?php echo $start; ?>
Any help would be greatly appreciated!
No comments posted yet
Your Answer:
Login to answer
119
50
Other forums
I need an iframe that calls up a different page according to the date
hi
I don't know any php (only html) and I urgently need to do the following:
I need a
Table Control
Hi Guru's,
I've created a Module pool program, which contains the Table Control.
Trouble verifying database password
Thankyou to everyone who responded to my last post (I can't find the posting, it has been buried). <
How to assign JS screen.width to ASP.Net variable
I've got this ASP.net routine that gets the cookie value of the screen width, but now I need to chan
Hashing?
Hi, I was hoping to take a string value then convert it - consistently - across each of our pages in
php automatically escaping single quotes
I'm trying to test out my security a bit and I've noticed that php is escaping my single quotes. For
i want run some web server under the ip sharer
hello i want run some web server under the ip sharer
my ip is floating ip but it doesnt matter
Sequencing or queuing parallel process
Scenario is as follows
There is one parent process say P1 and 4 child processes say A B C D
Multi-user card game
I'm writing a batch of games and such. Lottery is finished, Poker,blackjack,etc are next. They will
xml
<?php
echo "<h1>XML Articles</h1>";
$home