bujashaka Posted August 20, 2013 Share Posted August 20, 2013 (edited) Hello! I've been into mysql and encountered a problem, not serious one but it is bugging me. I can do dynamic page linking as follows, in short hand.... echo "<a href=\"foo.php?page=" . $vastaus['id'] ."\">" . $vastaus['menu_name'] . "</a><br />"; // URL LINK function showcontent() { /// FUNCTION TO DISPLAY CONTENT FROM SERVER. global $yhteys; $sql = "SELECT * "; $sql .= "FROM subjects "; $sql .= "WHERE id=" . $_GET['page']; $kysely= mysql_query($sql, $yhteys); $content = mysql_fetch_assoc($kysely) or die(mysql_error()); echo strip_tags($content['content'], "<br><dt><dl>"); Problem is... I can make this work with the ID, how ever, i want the URL bar saying it like this -> index.php?page=Info. This way it looks smarter (tells more to a user) and not just numbers as IDs. If i try to do the query like this... $sql = "SELECT * "; $sql .= "FROM subjects "; $sql .= "WHERE menu_name=" . $_GET['page']; It says unknown column "Info, Services". etc etc. It can only regonize the first column in each row. ( aka the id=number) I've tryed num_rows, fetch_array and fetch_assoc. I can't find a way to accomplish it. PLEASE i know this is simple, need help. Thanks in advance! Edited August 21, 2013 by Zane Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted August 20, 2013 Share Posted August 20, 2013 you have to surround it in quotes if it's text $sql .= "WHERE menu_name='" . $_GET['page']."'"; Hello! I've been into mysql and encountered a problem, not serious one but it is bugging me. I can do dynamic page linking as follows, in short hand.... echo "<a href=\"foo.php?page=" . $vastaus['id'] ."\">" . $vastaus['menu_name'] . "</a><br />"; // URL LINK function showcontent() { /// FUNCTION TO DISPLAY CONTENT FROM SERVER. global $yhteys; $sql = "SELECT * "; $sql .= "FROM subjects "; $sql .= "WHERE id=" . $_GET['page']; $kysely= mysql_query($sql, $yhteys); $content = mysql_fetch_assoc($kysely) or die(mysql_error()); echo strip_tags($content['content'], "<br><dt><dl>"); Problem is... I can make this work with the ID, how ever, i want the URL bar saying it like this -> index.php?page=Info. This way it looks smarter (tells more to a user) and not just numbers as IDs. If i try to do the query like this... $sql = "SELECT * "; $sql .= "FROM subjects "; $sql .= "WHERE menu_name=" . $_GET['page']; It says unknown column "Info, Services". etc etc. It can only regonize the first column in each row. ( aka the id=number) I've tryed num_rows, fetch_array and fetch_assoc. I can't find a way to accomplish it. PLEASE i know this is simple, need help. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
bujashaka Posted August 20, 2013 Author Share Posted August 20, 2013 yeah it is text. Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted August 20, 2013 Share Posted August 20, 2013 yeah it is text. I know it's text that's why I told you that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.