i am using datatables with iframe (iframe parent page -> icontent.php -> var.php)
populating the table works fine but i cannot seem to pass the variable to the other page (var.php)
, I have this code on my php page (icontent.php)
<?php
while ($row=$ result->fetch_row()){
$array = array($row[0], $row[1]);
$arraytemp = serialize($array);
?>
<tr>
<td>
<?=$row[0]?>
</td>
<td>
<?php
echo "<a href=\"../variety.php?array=$ arraytemp\ ">$row[1]</a>";
?>
</td>
<td>
<?=$row[2]?>
</td>
<td>
<?php
if(!is_null($row[3]))echo $row[3]; else echo 0;
?>
</td>
<?php
echo " <td><a href=\"updateprice.html\ " class=\"btn btn-outline btn-primary btn-sm btn-block btn-block\ ">Update Market Price</a>
<a href=\"updatebatchspoilage.html\ " class=\"btn btn-outline btn-primary btn-sm btn-block btn-block\ ">Manage Spoilage</a></td>";
?>
<tr>
<?php } ?>
but once i click the row link on the table i get this error "Notice: Undefined index: array in C:\\xampp\\htdocs\\introse\\views\\variety.php on line 46"
with this code on the other page ( var.php
)
<?php
session_start();
$tarray=$ _GET[ 'array'];
$tarray=unserialize($tarray);
echo $array[0];
?>
See this line right here:
echo "<a href=\"../variety.php?array=$ arraytemp\ ">$row[1]</a>";
I don't think you need that space after the $
.
Also, you got another one here:
$tarray=$ _GET[ 'array'];
<?php session_start(); $tarray=$ _GET[ 'array']; $tarray=unserialize($tarray); echo $tarray[0]; ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.