点击链接不会将我带到目标页面。 来自Murach PHP书籍

Hi I'm very new to php and I'm going over the Murach PHP book. I'm having a problem with clicking on a link in the categories section because when it clicks on the link it ads ?category_id=3 but the problem is it adds it after add_product.php like-> http://localhost/my_murach_php/add_product.php?category_id=3

I want it to add after http://localhost/my_murach_php/ so it looks like http://localhost/my_murach_php/?category_id=3

I am able to see the categories when i click on the links before I do anything with adding products. I could see the category info on the index page and when I click on it from the index page I get to go to http://localhost/my_murach_php/add_product_form.php (good) to add a product I click on the button and it takes me to http://localhost/my_murach_php/add_product.php(good) then when I click a category I get this page http://localhost/my_murach_php/add_product.php?category_id=1 (not good) I would like it to be this page http://localhost/my_murach_php/?category_id=3

Here's how I Included the link on the index page

        <li>
            <a href="?category_id=<?php echo $category['categoryID']; ?>">
                <?php echo $category['categoryName']; ?>
            </a>
        </li>

I have include("index.php"); in the add_product.php file

I guess the problem is going back to the root directory when I am on the http://localhost/my_murach_php/add_product.php?category_id=1 page.

Thank you

if you use a href like "?category_id=..." then the browser assumes you just want to add this to your CURRENT url. So to go to the url you want, just use the full url you need, like:

<a href="http://localhost/my_mutach_php?category_id=<?php echo $category['categoryID']; ?>">

Btw. <?php echo can be written as <?= to make it simpler and more readable.