看板 PHP 關於我們 聯絡資訊
嗯嗯~用hidden的方式之前有想過~可是現在變數是陣列~我如何一下取得它全部 陣列的值呢?? ※ 引述《kg3363 (深藍)》之銘言: : 感謝各位熱心的大大~我大概知道我那邊有問題了~我前三行的變數值是 : 從上一頁的表單所取回來的~我送出表單後~雖然還是在同一頁~但變數值 : 就都不見了~難怪整個網頁呈現空白~所以想請問一下~這三行的變數值~ : 我如何在該網頁送出表單後~這些變數值的值還可以把他留下來?? : 感恩^^~ : : <? : $rans=$_POST["rans"]; : $txt=$_POST["txt"]; : $number=$_POST["number"]; : .......(中間省略)........ : : //顯示討論區 : : include ("db.php"); : : $sql="select * from argument order by sid desc"; : : $result=mysql_query($sql)or die("sql執行失敗"); : : $num=mysql_num_rows($result); : : if($num!=0){ : : echo "<br>"; : : echo "<table width='600'>"; : : echo "<tr bgcolor='#66FFFF'><td bgcolor='#FFFFFF'></td> : : <tdalign='center'>編號</td><td align='center'>討論內容</td> : : <td align='center'>發表者</td><td align='center' >發表時間 : : </td></tr>"; : : $k=1; : : while($row=mysql_fetch_row($result)){ : : //交替的表格顏色 : : if($k % 2 >0) : : $bgcolor="PaleGreen"; : : else : : $bgcolor="LemonChiffon"; : : echo "<tr bgcolor='$bgcolor'>"; : : $row[3]=nl2br($row[3]); : : echo "<td width='5%' bgcolor='#FFFFFF'></td> : : <td align='center' width='10%'>".$k."</td> : : <td width='55%'>".$row[3]."</td> : : <td align='center' width='15%'>".$row[2]."</td> : : <td align='center' width='15%'>".$row[4]."</td>"; : : echo "</tr>"; : : $k++; : : } : : echo "</table>"; : : } : : //討論區格式 : : echo "<form name='form1' method='post' action='answer.php'> : : <p> : : <textarea name='content' cols='45' rows='5'></textarea> : : </p> : : <p> : : <input type='submit' name='submit' value='參與討論' /> : : <input type='hidden' name='sid' value='".$arr[$i]["sid"]."' > : : </p> : : </form>"; : : //討論內容寫入資料庫 : : if($submit=="參與討論"){ : : include ("db.php"); : : $time=date ( "Ymd", time() ); : : $sql = "INSERT INTO argument(number,user_name,content,timeoff) : : VALUES('$sid','$user_name','$content','$time')"; : : mysql_query($sql) or die("SQL執行錯誤:".mysql_error()); : : } : : ?> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.160.191.102
twsphere:。。大家就都給你解答了 Ajax ......你真的很不信邪 09/11 10:15
twsphere:用ajax post你就不用搞這樣多步驟了,還可達到你要的效果 09/11 10:18
Canboo:你不會上GOOGLE用關鍵字 "PHP 陣列"查嗎? 09/11 10:25
CaptainH:他php都寫不出來了還期待他寫js 09/11 10:54
b12031106:嫌麻煩就implode出去 然後explode進來 09/11 13:33
shadowjohn:這 date 寫的真是.. 09/11 13:38
carlcarl:同四樓 新手就老老實實用PHP幹吧 用Ajax有點太早 09/11 16:52
chenstin:可以用json_encode,json_decode或serialize,unserialize 09/11 21:45
chenstin:將陣列變成字串後放進hidden再轉回陣列 09/11 21:47
kg3363:-> 09/12 02:27
kg3363:感謝各位大大的指教~我弄出來了~AJAX沒學過~所以不會~ 09/12 02:29
kg3363:還有很多要學~在此感謝各位^^~ 09/12 02:29