whare Posted May 13, 2011 Share Posted May 13, 2011 index.php?page=1 that link style but there is not hard files it is all to be stored in the DB here is what i have got so far <? $result = mysql_query("SELECT * FROM page") or die(mysql_error()); $row = mysql_fetch_array( $result ); if(isset($_GET['page'])) { echo $row['text']; } else { $result = mysql_query("SELECT * FROM page WHERE id='1'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['text']; } ?> but always shows page ID 1 (home page) so i no i am missing something just not sure what hehe DB structure: menu ----id (auto increase) ----name (home, about etc) ----id2 (page weight) pages ----id (auto increase) ----name (page name home, about etc) ----text (page text) link structure from the menu <? $result = mysql_query("SELECT * FROM menu ORDER BY id2") or die(mysql_error()); ?> <table> <? while($row = mysql_fetch_array( $result )) { ?> <tr><td> <a href="index.php?page=<? echo $row['id'];?>"><? echo $row['name']; ?></a> </td></tr> <? } ?> </table> dont think i have missed any info that i have on file but not sure why it will not link so thought of you guys hehe Thanx in advance Quote Link to comment Share on other sites More sharing options...
wigwambam Posted May 13, 2011 Share Posted May 13, 2011 <? if(isset($_GET['page']) && is_numeric($_GET['page'])) { $result = mysql_query("SELECT * FROM page WHERE id='" . $_GET['page'] . "'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['text']; } else { $result = mysql_query("SELECT * FROM page WHERE id='1'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['text']; } ?> Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 13, 2011 Share Posted May 13, 2011 Why are you selecting everything from the database? $page = (int)$_GET['page']; $sql = mysql_query("select * from page where page_id = $page"); if(mysql_num_rows($sql)>0){ $row = mysql_fetch_assoc($sql); echo $row['text']; }else{ // No rows were returned } 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.