gvanto Posted June 26, 2006 Share Posted June 26, 2006 I would very much like to find out the implementation of:www.myurl.com/myfile.html where this URL actually calls the location (and shows content) www.myurl.com/content.php?id=4I have seen this done somewhere just cant remember where :-)Any help much appreciated!Gerry Quote Link to comment https://forums.phpfreaks.com/topic/12926-html-urls-calling-php-help-plz/ Share on other sites More sharing options...
.josh Posted June 26, 2006 Share Posted June 26, 2006 can you be more specific? it seems what you are asking is how to have say, index.php?id=xand depending on x, it includes a different page on index.php is that what you are asking? if not, then be more specific. Quote Link to comment https://forums.phpfreaks.com/topic/12926-html-urls-calling-php-help-plz/#findComment-49614 Share on other sites More sharing options...
gvanto Posted June 26, 2006 Author Share Posted June 26, 2006 Umm, OK thought it was quite clear but here goes:I have content in a database, and depending on the value of ‘id’ depends which content is shown. BUT, for each ‘page’ (ie. Page with different content, in reality still index.php), I want an HTML page as follows (ie. The html page is called / linked to / whatever):url.com/myPage.html calls-> url.com/Index.php?id=4&someother=trueurl.com/myRandomlyNamedOtherPage.html calls-> url.com/index.php?id=39&someother=blahHope this makes more sense,Thanks,GerryUmm, OK thought it was quite clear but here goes:I have content in a database, and depending on the value of ‘id’ depends which content is shown. BUT, for each ‘page’ (ie. Page with different content, in reality still index.php), I want an HTML page as follows (ie. The html page is called / linked to / whatever):url.com/myPage.html calls-> url.com/Index.php?id=4&someother=trueurl.com/myRandomlyNamedOtherPage.html calls-> url.com/index.php?id=39&someother=blahHope this makes more sense,Thanks,Gerry Quote Link to comment https://forums.phpfreaks.com/topic/12926-html-urls-calling-php-help-plz/#findComment-49656 Share on other sites More sharing options...
hackerkts Posted June 26, 2006 Share Posted June 26, 2006 Create 1 more column in table which you had stored those id's, name it urlExample of the table:| id | url || 1 | url.com/12312vawafwa.html || 2 | url.com/2352g352vc352v352.html |Etcs ...In your index.php you should have:[code]<?php$id = $_GET['id'];if (isset($id)) { function go_to_page($id) { $query = "SELECT * FROM `page` WHERE id ='$id'"; $result = mysql_query($query) or die("Query failed: " . mysql_error()); $row = mysql_fetch_array($result); $pageid = $row['id']; $pageurl = $row['url']; $go = "<META HTTP-EQUIV='refresh' CONTENT='0;URL=". $pageurl ."'>"; return $go; } echo go_to_page($id);} else { echo "You didn't select any page."; }?>[/code]Tell me if there's any error, I have test it yet.Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/12926-html-urls-calling-php-help-plz/#findComment-49661 Share on other sites More sharing options...
gvanto Posted June 26, 2006 Author Share Posted June 26, 2006 Dear Kear,Thanks for your reply, but i just read up to here:if (isset($id))and immediately I sense that you have the INVERSE of the function that I want, fully explained.In your code, you're expecting the user to enter: url.com/index.php?id=somenumber into the address bar, then call the .html file depending what this id is.I'm looking for a way of: entering the .html file: url.com/myrandom.html which THEN calls url.com/index.php?contentid=somethingBasically, a way of running a php file but which somehow has a .html extension (after which you can retrieve the current URL string, then FIND ID depending on the url location, ie. the inverse of what your code does)Hope this makes more sense now. Any help much appreciated!Gerry Quote Link to comment https://forums.phpfreaks.com/topic/12926-html-urls-calling-php-help-plz/#findComment-49671 Share on other sites More sharing options...
hackerkts Posted June 26, 2006 Share Posted June 26, 2006 There's a way using .htaccess, but it's really trouble that a html file act as a php file.Why not just use .php it's just 3 letters while .html 4 letters ?[code]RewriteRule ^home\.html index.php [L]RewriteRule ^index\.html index.php [L]RewriteRule ^(.*)\.html index.php?write=$1 [L][/code] Quote Link to comment https://forums.phpfreaks.com/topic/12926-html-urls-calling-php-help-plz/#findComment-49672 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.