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;
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
Move array index to end
Hey guys,
Quick question:
I have an array that looks like this:
Code: [Select]$var =
php and downloading
I want to use a php script to create two files. Then I want it to redirect (or whatever) to have tho
How to give the privillege for triggers?
Hi,
How to give the privillage for triggers to particular user?
Please let me
phpmailer class & pop.gmail.com?
Code: <?php
$mail->IsSMTP();
$mail->Host = "pop.gmail.com";
Web Application Recipe
Hi Guys!
I am working with the Web Application recipes. I am currently working on the sen
using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the butto
php/mysql auto logout after 2 hour and reset password
Hi all,
This I hope will make sense. I've the following code which when a user logins in, cr
onclick problem
I have <input type="text" name="message">
<a href=page2.
Array question
Does anyone know how to create a program that takes the $ amount for 8 different departments and gi
str_replace help
I am thinking str_replace is my only option to filter outputs from my database to convert them to sa