Hello everyone,
I am trying to put a value into $value;
after the value is clicked the count stays at one or it resets itself any help will be awesome

Thank you.

<table width="61%" border="1" align="center" cellpadding="4">
<?php

$count = 1;
if (isset($_GET['value'])) {
	$count++;
	$value[$count] = $_GET['value'];
	print "<tr><td><big>You clicked: $value[$count]</big></td></tr>";
}
$data = 10;
for ($i=1; $i<=$data; $i++) {
    print "<tr><td><a href=\"?value=$i\">Data: $i</a></td></tr>";
}
?>
</table>

Recommended Answers

All 2 Replies

Seems to work fine for me, I modified it a little so you could see the value of $value[$count] at the bottom of the script

<table width="61%" border="1" align="center" cellpadding="4">
<?php

$count = 1;
if (isset($_GET['value'])) {
	$count++;
	$value[$count] = $_GET['value'];
	print "<tr><td><big>You clicked: $value[$count]</big></td></tr>";
}
$data = 10;
for ($i=1; $i<=$data; $i++) {
    print "<tr><td><a href=\"?value=$i\">Data: $i</a></td></tr>";
}
?>
</table>
<br />value of $value[$count] = <?php echo $value[$count]; ?>

Thanks R0bb0b,
I added this at then very end of the code and count doesn't seem to increase, please help thank yo

<br />value $count = <?php echo $count ?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.