eZe616 Posted May 17, 2007 Share Posted May 17, 2007 I was wondering if having something like this is possible: http://localhost/res/index.php?page=viewmore?id=1 If so how can you achieve it? I'm trying to put together real estate site together, now on the index page i'll have the first 5 most recent listings on the home page. Now on the index.php i already have a include script which is as followed <?php $page = $_GET['page']; $page = ($page != '') ? $page : 'home' ; $page .= '.php'; $page = preg_replace('%(?:\.\./)+%', '', $page); if (!is_dir($page) && file_exists($page)) { if (!(@include($page))) { include '404.txt'; } } else { echo 'File does not exist'; } ?> now when the listing are called. I have a link to click "View More", I want it to take the person to a page with more info on the house. would I need a similar script like the inlcuded one on the index to achieve this? Or how can this be done, to get a link like the one above Link to comment https://forums.phpfreaks.com/topic/51908-is-this-possible/ Share on other sites More sharing options...
per1os Posted May 17, 2007 Share Posted May 17, 2007 http://localhost/res/index.php?page=viewmore&id=1 Note the & If it is done that way it can be access by $_GET['id'] instead of having to do the replace and stuff, probably be easier for you. Link to comment https://forums.phpfreaks.com/topic/51908-is-this-possible/#findComment-255911 Share on other sites More sharing options...
eZe616 Posted May 17, 2007 Author Share Posted May 17, 2007 Ok, it seems to work, thanks. Now, let's say I got the ID... How would I get all the info for that 'home' from the mysql table from the ID I have this so far: $sql = "SELECT * FROM house WHERE id='". $_GET['id'] . "'"; but, when I echo it all I get is Resource id#4 how do I get all the field associated with that ID? Link to comment https://forums.phpfreaks.com/topic/51908-is-this-possible/#findComment-255936 Share on other sites More sharing options...
akitchin Posted May 17, 2007 Share Posted May 17, 2007 mysql_query() returns a RESOURCE ID, not the actual rows returned, from a query. check the manual and you'll see that it mentions this. you need to use an extraction function such as mysql_fetch_array(), mysql_result(), or similar on the resource returned by mysql_query() in order to retrieve the row(s) returned by the query. have a look in the php manual and you should find some relevant code samples. Link to comment https://forums.phpfreaks.com/topic/51908-is-this-possible/#findComment-255961 Share on other sites More sharing options...
eZe616 Posted May 17, 2007 Author Share Posted May 17, 2007 tnx, for the tip. I got it working now. Also what are the security risk, that I might worry about with this sort of navigation?? Link to comment https://forums.phpfreaks.com/topic/51908-is-this-possible/#findComment-255966 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.