shedokan Posted November 29, 2007 Share Posted November 29, 2007 what is the best way to create an article page? I want to get the article id with $_GET thanks. Quote Link to comment Share on other sites More sharing options...
marcus Posted November 29, 2007 Share Posted November 29, 2007 # using a mysql db $page = mysql_real_escape_string($_GET['page']); if(!$page){ // index page }else { $sql = "SELECT * FROM `pages` WHERE `url`='{$page}'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "Page does not exist!\n"; }else { $row = mysql_fetch_assoc($res); echo $row['title'] . "<br>" . $row['author'] . "<br><br>" . $row['text']; } } # using flat files $page = stripslashes($_GET['page']); if(!$page){ include "/home/you/public_html/includes/index.inc"; }else { if(file_exists("/home/you/public_html/includes/" . $page . ".inc")){ include "/home/you/public_html/includes/" . $page . ".inc"; }else { include "/home/you/public_html/includes/404.inc"; } } Quote Link to comment Share on other sites More sharing options...
shedokan Posted November 29, 2007 Author Share Posted November 29, 2007 isn't it better to use txt files? and what do you think is better? if mysql wouldn't it be too big for the database to handle? Quote Link to comment Share on other sites More sharing options...
marcus Posted November 29, 2007 Share Posted November 29, 2007 Yeah, I would prefer using include files and such. That way you don't have to go through the struggle of updating a page by going into a database, and yep, the strain would be at a higher max if you used the mySQL way. Quote Link to comment Share on other sites More sharing options...
shedokan Posted November 29, 2007 Author Share Posted November 29, 2007 ok thanks. do you know a good file handing with php guide? Quote Link to comment Share on other sites More sharing options...
marcus Posted November 29, 2007 Share Posted November 29, 2007 There are numerous tutorials out there. Your best chance is Google. 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.