I use
while($row = mysqli_fetch_array($result))
to print all sql result.
and I have a button for each row... " onclick="Pos.action='wantToRent.php';Pos.submit();"> to convey value immediately to other page. and if I try convey next value likes:
<?php $_SESSION['SID']= $row[7];?>
or
<input type=hidden name=SID value="<?php echo $row[7];?>">
it will be influence by loop and convey the last value $row[7] of table...
how I get the correct SID of row without influence?
full code:
<form name = "Pos" action = "" method = "post">
<?php
include('phpfile/db_connect.php');
$sql = " SELECT * FROM product";
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result)){?>
<div class='proList'>
<h3 class='proTitle'><a href='https://www.google.com'><?php echo $row[1];?></a></h3>
<div class='proleft pro'><img src='' alt='abc'/></div>
<div class='proright pro'><a class='seller protxt' href='https://www.google.com'> <?php echo $row[2];?> </a>
<div class='proPri protxt'> <?php echo $row[3];?> </div>
<div class='proTim protxt'> <?php echo $row[4];?> </div>
<div class='proPosi protxt'> <?php echo $row[5];?> </div>
<div class='proDeti protxt'><?php $row[6];?> </div><br/>
<button name="iwantR" value="<?php echo $row[0];?>" onclick="Pos.action='wantToRent.php';Pos.submit();">rent</button>
<?php $_SESSION['SID']= $row[7];?> //where I try send out SID without loop influence.
</div>
</div>
<?php
}
?>
</form>