vendredi 30 janvier 2015

how to initialize session inside function of a script tag?



<?php
// Start the session
session_start();
?>
<script src="../../js/jquery.js"></script>
<script>
function hello(y){
alert( y);
}
</script>


<?php
{


require 'db_connect.php';
$count=0;
$count = mysql_query ('SELECT COUNT(ques_no) FROM asg_cre_mcq') ;
$row = mysql_fetch_array($count);
//echo $count;
for ($y = 1; $y <=$row[0]; $y++)
{
echo "<button style='width:30px;height:30px' onclick='hello($y);'>". $y."</button>";
// $_SESSION["buttons"] =$y;


}
}
?>


I am dynamically generating buttons depending on the value coming from database. Then using onclick function I am performing check of click on button i.e. which button is clicked. what I want is to pass this vale of y i.e. button number to another php page in hello function using sessions. How can i do that?





Aucun commentaire:

Enregistrer un commentaire