I am learning PHP from from Murach's book and I am facing some issues to understand this code,
<nav>
<ul>
<?php foreach ($categories as $category) : ?>
<li>
<a href="?category_id=<?php echo $category['categoryID']; ?>">
<?php echo $category['categoryName']; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</nav>
My problem is with this part,
<a href="?category_id=<?php echo $category['categoryID']; ?>">
<?php echo $category['categoryName']; ?>
</a>
All this is trying to do is to display the category list. So each time user clicks this pass the category ID.Why this is written like that ? why the question mark with category_id (?category_id)in the beginning ? is that a variable and assigning it with remaining code ? and why is an echo statement for categoryID in anchor tag ? Because in the webpage it displays only the categoryName. I am just beginner so please excuse me if it sounds so stupid.
?denotes that there is variables to be found. Multiple can be added like soexample.com?foo=bar&bar=foo