jd2007 Posted August 9, 2007 Share Posted August 9, 2007 i serialize it here : $db=$_GET[db]; $query2="use $db"; $result2=mysql_query($query2); $sql = "select * from $_GET[t]"; $result2 = mysql_query($sql); $num=mysql_num_rows($result2); $r=0; $c=0; $arr=array(); echo "<script src='myareaajax.js'></script><form method='get' ><table border=1><tr>"; for ($b=1; $b<=$num; $b++) { $sql2 = "select * from $_GET[t] where id='$b'"; $result4 = mysql_query($sql2); while ($record = mysql_fetch_assoc($result4)) { while (list($fieldname, $fieldvalue) = each ($record)) { $c++; echo "<td><input type=text id=$c value=$fieldvalue /></td>"; $arr[]=$fieldvalue; } echo "</tr>"; } $r++; } //print_r($arr); $arr2=serialize($arr); //echo $arr2; $table=$_GET["t"]; echo "</table>"; echo "<input type='hidden' name='c' value='$c' />"; echo "<input type='hidden' name='r' value='$r' />"; echo "<input type='hidden' name='t' value='$t' />"; echo "<input type='hidden' name='db' value='$db' />"; echo " <input type='button' name='update' value='Update' onclick=my_area('update.php','db=$db&arr=$arr2&t=$t&c=$c&r=$r','3'); /> </form><br />"; } then, i unserialize here after sending through ajax: <?php $c=$_GET["c"]; echo $c; $r=$_GET["r"]; echo $r; $t=$_GET["t"]; echo $t; //$arr=; echo $db=$_GET["db"]."<br />"; //echo $arr=; $arr2=unserialize($_GET["arr"]); echo $arr2; $d=$c/$r; $server = mysql_connect('localhost', 'root', 'jd2008') or die(mysql_error()); $db_selected = mysql_select_db($db, $server); $v=0; for ($f=1; $f<=$c; $f+=$d) { for ($e=1; $e<=$d; $e++) { $que.="'$arr2[$v]',"; $v++; } echo $que."<br />"; //$num=strrchr($que, ","); $que=substr($que, 0, strlen($que)-1); $quet="truncate table $t"; $quet=mysql_query($quet); $queb="insert into $t values ($que)"; $quec=mysql_query($queb); $que=""; echo $queb."<br />"; } ?> $arr2 shows nothing when echoed....why...pls help ? Quote Link to comment https://forums.phpfreaks.com/topic/64077-why-im-not-getting-the-array-after-unserializing/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.