Search the Community
Showing results for tags 'dynamic urls'.
-
Hey everyone, I'm working on teaching myself php/mysql by build a Content Management System I've got to a certain point which I'm quite proud of but I've hit a bit of a bump. at current my dynamic page urls are "index.php?pid=1" However I would like them to be actual words e.g. "/home-page" "/example-page". I have no idea how to even begin to do this, I've seen a lot of posts about using .htacess and url re-writes but I don't seem to be able to get these to work. Current build menu code in functions.php: // *************************************** // Start Build Menu // *************************************** $sqlCommand = "SELECT id, linklabel, seourl FROM pages WHERE showing='1' ORDER BY pageorder ASC"; $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); $menuDisplay = ''; while ($row = mysqli_fetch_array($query)) { $pid = $row["id"]; $linklabel = $row["linklabel"]; $seourl = $row["seourl"]; $menuDisplay .= '<a href="index.php?id=' . $pid . '">' . $linklabel . '<a><br .>'; } mysqli_free_result($query); // *************************************** // End Build Menu // *************************************** I have added the extra seourl field into the database so when a new page is created it grabs the page title, removes the spaces and replaces them with - so a page called example page one will turn into example-page-one. However I am completely lost on how to use the seourl to load the content in the page. This is also how I currently pull the content from the database for the page info. // *************************************** // Select Page ID and Content, Keywords/Description // *************************************** if (!$_GET['id']) { $pageid = '1'; } else { $pageid = ereg_replace("[^0-9]", "", $_GET['id']); } $sqlCommand ="SELECT pagebody, description, keywords FROM pages WHERE id='$pageid' LIMIT 1"; $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); while ($row = mysqli_fetch_array($query)) { $body = $row["pagebody"]; $desc = $row["description"]; $keywords = $row["keywords"]; } mysqli_free_result($query); // *************************************** // Select Page ID and Page Title // ************************************ If anyone has any advice or can point me in the right direction that would be fantastic! Thanks