在.php文档中显示不同的mysql数据,如cms
Hey this is probably really simple, but i am still a beginner i am a bit confused about that.. I want to create something like a selfmade CMS for my website.
I have a .php document which is querying certain data from my database. Now if i change that data, the document will display the new data. (So i can edit my texts and images..)
My actual question is, how can i create something like a new page. So that i have a form which will write new data into my database and the .php document somehow displays my new data. I mean it is the same "template" like my first .php document, but how can i query different things from my database than before? How does that work in real CMS systems?
Basically i want to write new data in my database with a form. And depending on which url i will click in my index.php, different data is shown in my page1.php document.
I hope you know what i mean. Thank you
EDIT:
To give you an example: A main document with a lot of url's named "data1" "data2" "data3" and so on. If i click on "data2" the showdata.php document should display the data2 which it will find in the database.
嘿,这可能很简单,但我仍然是初学者,我对此有点困惑.. I 想为我的网站创建类似自制CMS的东西。 p>
我有一个.php文件,它从我的数据库中查询某些数据。 现在,如果我更改该数据,文档将显示新数据。 (所以我可以编辑我的文本和图像..) p>
我的实际问题是,如何创建类似新页面的内容。 所以我有一个表格,它会将新数据写入我的数据库,而.php文件会以某种方式显示我的新数据。 我的意思是它与我的第一个.php文档是相同的“模板”,但我怎样才能从我的数据库中查询不同的东西呢? 如何在真正的CMS系统中工作? p>
基本上我想用表格在我的数据库中写入新数据。 根据我在index.php中点击的URL,我的page1.php文档中会显示不同的数据。 p>
我希望你知道我的意思。 谢谢 p>
编辑: p>
举个例子:一个主文档,其中有很多url名为“data1”“data2”“data3” 等等。 如果我点击“data2”,showdata.php文档应该显示它将在数据库中找到的data2。 p> div>
Have you tried using the data in the url to write different queries ?
Something like:
if (data1) {select data1 from database} elseif(data2){select data2 from database}
and so on ? This is what a CMS does actually it, shows different data on the same page based on the url parameters which in php you can use as $_GET['data1']
or $_REQUEST['data1']
Try something like that then update your answer with some code.
I assume that you're interested in a thing called a CRUD application.
CRUD stands for Create, Read, Update, Delete application.
There are numerous examples of CRUD applications in PHP/MySQL all over the internet.
checkout this link: http://thewebmason.com/php-mysql-crud-tutorial-using-pdo-create-read-update-delete-part-1-create/