Dynamic page creation PHP + MySQL Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Dynamic page creation PHP + MySQL without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Been struggling with this problem for a while now and I just can’t het my brain to understand it.

I have a very simple website where I can add items in a database. There is a list on index.php where the list is displayed and each item needs a url that directs to a “more information” page.

The “more information” page has to be a dynamic one as there are a lot of items and these items can be added or deletend.

What my code for this section looks like at the moment:

$result_set = mysql_query("SELECT id, name FROM items WHERE id = $item");
while ($item = mysql_fetch_row($result_set)) {
$name = $item['name'];
echo "<a href="/items/".$item['1'].".html">$name</a>";

This results in a link if item 1 = wrench ../items/wrench.html.

But this page obviously doesn’t excist. How can I get this to work?


use .htaccess for this. you can add this code

RewriteEngine On
RewriteRule  ^items/(.+)$ items.php?page=$1

In your items.php use $items=$_GET[page]; so you can read what is in url after items/

This is a link where you can find more about RewriteRule’s http://httpd.apache.org/docs/current/rewrite/intro.html

We are here to answer your question about Dynamic page creation PHP + MySQL - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji