Rommeo Posted September 10, 2008 Share Posted September 10, 2008 Hi As I am a newbie, there is something that i dont understand. My question is : i have a mysql table which keeps the data of the pages like "about us" & "contact" etc. for to enter contact, i type : "www.mywebsite.com/page.php?id=contact" and i have a page which looks for the data by the while loop named ad "photos.php" for to see photos, i type "www.mywebsite.com/photos.php" And my question is .. What if i write the "while-loop-code" in my mysql table, would it work ? when i enter ; "www.mywebsite.com/page.php?id=photos" As i said my photos.php file is just a mysql query which shows all the photos. I wanna save that code in my mysql.. But i m not sure whether that works. Is it possible ? Is there anyway to do that ? I ll be glad if anyone can help. Thanx in advance. Quote Link to comment https://forums.phpfreaks.com/topic/123598-solved-is-this-possible/ Share on other sites More sharing options...
JonnoTheDev Posted September 10, 2008 Share Posted September 10, 2008 page.php?id=x The value of x is probably used to lookup the row containing the content for the page from a database table photos.php is a completely different file and must have code to get images from a different database table "www.mywebsite.com/page.php?id=photos" Will not work To save the php code into a mysql field will require php knowledge and modification of the code in page.php to tell it to expect code when id=photos Quote Link to comment https://forums.phpfreaks.com/topic/123598-solved-is-this-possible/#findComment-638306 Share on other sites More sharing options...
DeanWhitehouse Posted September 10, 2008 Share Posted September 10, 2008 Yes ,but it is not a good idea, here is one way to do it index.php?page=photos <?php if(isset($_GET['page'])) { $page = $_GET['page']; require_once '$page.php'; } ?> Not very secure, but it will start you off, or if you want to do it your way You will have a table called content then two rows, one called title and one called content (which will be text, not varchar) Then do <?php if(isset($_GET['page'])) { $page = $_GET['page']; $page = mysql_real_escape_string($page); //assuming you are connected to the database $sql = "SELECT*FROM content WHERE title='$page'"; $query = mysql_query($sql); while($rows = mysql_fetch_assoc($query)) { echo $rows['content']; } } ?> That should start you off. Quote Link to comment https://forums.phpfreaks.com/topic/123598-solved-is-this-possible/#findComment-638345 Share on other sites More sharing options...
Rommeo Posted September 10, 2008 Author Share Posted September 10, 2008 Thanx for the replies. I got it. Quote Link to comment https://forums.phpfreaks.com/topic/123598-solved-is-this-possible/#findComment-638349 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.