bondigor69 Posted January 21, 2013 Share Posted January 21, 2013 (edited) hey guys I want to add <?php echo $_GET["q"]; ?>[/indent] instead of "news" in this PHP code <?php $rss = new DOMDocument(); $rss->load('http://wordpress.org/news/feed/'); ?>[/indent] How can I do that Thank you for help If someone posts a solution, Edited January 21, 2013 by bondigor69 Quote Link to comment https://forums.phpfreaks.com/topic/273409-add-in-my-php-code/ Share on other sites More sharing options...
trq Posted January 21, 2013 Share Posted January 21, 2013 Your going to need to be a lot clearer in your explanation. Quote Link to comment https://forums.phpfreaks.com/topic/273409-add-in-my-php-code/#findComment-1407182 Share on other sites More sharing options...
requinix Posted January 21, 2013 Share Posted January 21, 2013 1. If the "q" is set then use it, otherwise use a default value. 2. Validate it. It should be one of "news" or whatever else is valid for that feed. If it's not valid then do something besides ignore the problem. 3. Stick it in the string. There are many ways to do this and if you know even the smallest amount of PHP then you can do it. Quote Link to comment https://forums.phpfreaks.com/topic/273409-add-in-my-php-code/#findComment-1407183 Share on other sites More sharing options...
bondigor69 Posted January 21, 2013 Author Share Posted January 21, 2013 Your going to need to be a lot clearer in your explanation. I have a parameter "q" in url mysite.com?q=keyword I want to get the "q" value and insert it here <?php $rss = new DOMDocument(); $rss->load('http://wordpress.org/news/feed/'); ?> instead of news. Quote Link to comment https://forums.phpfreaks.com/topic/273409-add-in-my-php-code/#findComment-1407186 Share on other sites More sharing options...
Love2c0de Posted January 21, 2013 Share Posted January 21, 2013 Hey dude, give this a try: <?php $_GET['q'] = (isset($_GET['q'])) ? $_GET['q'] : "some_default_value"; $rss->load("http://wordpress.org/{$_GET['q']}/feeds/"); ?> Let me know how you get on. Regards, L2c. Quote Link to comment https://forums.phpfreaks.com/topic/273409-add-in-my-php-code/#findComment-1407187 Share on other sites More sharing options...
bondigor69 Posted January 21, 2013 Author Share Posted January 21, 2013 Hey dude, give this a try: <?php $_GET['q'] = (isset($_GET['q'])) ? $_GET['q'] : "some_default_value"; $rss->load("http://wordpress.org/{$_GET['q']}/feeds/"); ?> Let me know how you get on. Regards, L2c. yeahhhhh man you're amazing. thank you so much it works fine for me Quote Link to comment https://forums.phpfreaks.com/topic/273409-add-in-my-php-code/#findComment-1407189 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.