[請益] 想請教php&mysql網頁傳遞資料的問題

看板PHP作者時間15年前 (2010/04/09 17:40), 編輯推噓3(307)
留言10則, 5人參與, 最新討論串1/1
大家好~ 小弟算是php的新手 目前在練習做簡易的網路書店 但遇到了一個問題… 我的主頁是由左右兩個框架網頁組成 以下框架左邊稱a.php,右邊簡稱b.php 如下圖: http://img202.imageshack.us/img202/1917/phpe.jpg
a.php的部份程式碼: <?php include ('link.php'); $result = mysql_query("SELECT * FROM category"); $id_index=mysql_num_rows($result); for($index=0;$index<$id_index;$index++){ $arr[$index]=mysql_fetch_array($result); ?> // <a href="booklist.php?categoryID= // <?php echo $arr[$index]['id']; ?> // &category=<?php echo $arr[$index]['category']; ?>" target="BOOK"> // <?php echo $arr[$index]['category']; ?></a><p> <?php } ?> b.php的部份程式碼: <table border=1> <? include('link.php'); // $categoryID=isset($categoryID)?$categoryID:0; // $str="select * from book where categoryID='$categoryID' order by bookID;"; $result=mysql_query($str,$link); $book_index=mysql_num_rows($result); for($index=0;$index<$book_index;$index++){ $arrb[$index]=mysql_fetch_array($result); ?> <tr> <td><input type="checkbox" name="txb[<?php echo $index;?>]" value="<?php echo $arrb[$index]['psn'];?>"></td> <td><input type="textbox" size="2" name="txt[<?php echo $index; ?>]" value="1"></td> <td><?php echo $arrb[$index]['bookID'];?></td> <td><?php echo $arrb[$index]['bookname'];?></td> <td><?php echo $arrb[$index]['author'];?></td> <td><?php echo $arrb[$index]['price'];?></td> </tr> <?php }?> </table> 重點是劃註解的那幾行 我現在想做的功能是,按下a.php的分類選項,就會從資料庫 讀取資料,到b.php並顯示出來 我是用"categoryID"這個欄位來辨別書籍的分類(1~6) 但小弟一直想不出來如將a.php中得到的"categoryID"資料 傳遞到b.php,是用$_POST嗎?? 希望高手幫小弟解答阿~~~ 感謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.42.233.215

04/09 20:15, , 1F
不要用frame啊
04/09 20:15, 1F

04/09 20:55, , 2F
用frame就牽扯到client端要怎麼pass資料,於是
04/09 20:55, 2F

04/09 20:55, , 3F
你又得學JS XD
04/09 20:55, 3F

04/09 23:35, , 4F
用 iframe 最重要就是傳值給母 frame 或者子 frame
04/09 23:35, 4F

04/10 03:05, , 5F
你在a.php不是已經有把categoryID從網址傳過去了嗎@@?
04/10 03:05, 5F

04/10 03:06, , 6F
就用$_GET['categoryID']不就可以抓到了
04/10 03:06, 6F

04/10 03:07, , 7F
$categoryID=isset($categoryID)?$categoryID:0;
04/10 03:07, 7F

04/10 03:09, , 8F
上面這行你有用到$categoryID,register_globals?
04/10 03:09, 8F

04/10 03:12, , 9F
register_globals建議還是不要用啦,不是每台機器都有開
04/10 03:12, 9F

04/10 15:52, , 10F
感謝各位熱心解答~我用table、div做看看-_-
04/10 15:52, 10F
文章代碼(AID): #1BllOQy7 (PHP)
文章代碼(AID): #1BllOQy7 (PHP)