PHP Newsletter

Join now and receive weekly updates pertianing to the world of PHP.

Polls

What do you think about the new PHPMine Design?
Awesome
Not Bad
Sucks

PHP Gigs By City

PHP Jobs By Topic

Advertisements

i need some php help!?

Asked 2009-07-03 04:02:15 by Bat

hey i have these 2 pages

process.php
PHP Code:
<?php
$sport = $_POST['sports'];
$date = date("d/m/y");
$time = date("G:i:s");

$data_1 = "$sport $time $date";


setcookie("cookie",$data_1);

header("location: code.php");
?>

and code.php

PHP Code:
<form name="test" action="process.php" method="post" >



<input type="radio" name="sports" id="01" value="skate" onclick="document.test.submit();" /><label for="01">skateboard</label>
<input type="radio" name="sports" id="02" value="football" onclick="document.test.submit();" /><label for="02">football</label>


</form>





<?php
echo "<u>";
echo $_COOKIE['cookie'];
echo "<u />";

?>

so yeah when you click on one of the radio buttons you see
football 23:09:01 01/07/09

but i want a running text list showing the most recent buttons and times you clicked on it not just once. so it would be like


skate 23:53:35 01/07/09
skate 23:49:11 01/07/09
football 23:09:01 01/07/09

i've tryed using arrays but i cant get it to work so yeh wen a button is clicked it adds it to the running text list
any ideas?

Anwered 2009-07-03 04:15:55 by rbjolly

Ah ha! I'll answer it twice.

<html>
<head>
<title>Test Sport List</title>
</head>
<body>

<?php
$sport_list='';

if (isset($_POST['sports'])) {
$sport = $_POST['sports'];
$dts = date("G:i:s d/m/y");
if ($_POST['sport_list']) {
$sport_list = "<li>$sport $dts" . $_POST['sport_list'] . "</li>";
} else {
$sport_list = "<li>$sport $dts</li>";
}
}

?>


<form name="test" action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" >
<input type="hidden" name="sport_list" value="<?php echo($sport_list); ?>">
<input type="radio" name="sports" id="01" value="skate" onclick="document.test.submit();" /><label for="01">skateboard</label>
<input type="radio" name="sports" id="02" value="football" onclick="document.test.submit();" /><label for="02">football</label>
</form>

<ul>
<?php echo($sport_list); ?>
</ul>

</body>
</html>

Questions and answers provided by the Yahoo Answers Community.