我有一個簡單的博客應用程序,我將PHP和MySQL放在一起(條目位於那裏)。我有一個博客位於一些網址www.url.com/blog.php,但顯示「所有」博客條目,但每個人必須有它自己的網址,當你點擊它,導致www.url.com/blog.php?postID=1
,www.url.com/blog.php?postID=2
,www.url.com/blog.php?postID=3
,www.url.com/blog.php?postID=so on
。 如何在URL上附加這些postID?如何在問號'?'後創建這些網址追加URL創建個人博客條目頁面
所以我的博客看起來像......
#FORM shown like, a PHP script insert the entry into MySQL database
name: ___________
Date: ___________
Blog entry:______
_________________ SUBMIT
# All blog entries are shown here where PHP script select * from blog_table
BlogID Author Date Entry
1 john 1-1-1 Something
2 dave 1-2-1 Something else
.
.
.
但這些blogID必須有附加的URL,這樣,這樣當你點擊1
應該有它自己的鏈接
BlogID 1 = www.url.com/blog.php?postID=1
BlogID 2 = www.url.com/blog.php?postID=2
BlogID 3 = www.url.com/blog.php?postID=3
你們會如何做到這一點?建議。謝謝。
您創建的任何其他鏈接的方式相同。 '?'後面的東西只是一個傳遞給你的PHP腳本的變量。在您的PHP腳本中,您將可以訪問'$ _GET ['postID']'變量,這將是字符串末尾的數字。使用它從數據庫中獲取正確的條目。 –
@JustinWood hmm – mythoslife
@JustinWood我在我的博客入口頁面上使用$ _POST。我是否必須將其更改爲$ _GET才能訪問變量? – mythoslife