daniel_son Posted July 2, 2012 Share Posted July 2, 2012 Hi all, beginner here. I'm have a single page with a PHP dropdown which lists phone names from my database and an iframe on the same page. Im trying to pass the value (Phone_Make and Phone_Model) from what is selected to the dropdown to an iframe url which is called below. So when someone selects a certain mobile name from the dropdown, the iframe gets loaded with that value in its URL. With a bit of googling I've managed to get the phone drop working but thats as far as I've got. I'm sure this is straight forward to most coders. Willing to send someone a small thankyou payment (for a beer/coffee) if they can provide me with the needed code to get this working. I was also wondering if this should be approached with javascript not php. Many thanks in advance. J <html> <body> <?php ini_set('display_errors',1); $dbh = mysql_connect("localhost", "DB_USER", "DB_PASSWORD"); mysql_select_db("DB_NAME"); // Write out our query. $query = "SELECT CONCAT(Phone_Make, ' ', Phone_Model AS Full_Phone_Name FROM Mobile_DB_table ORDER BY Full_Phone_Name"; // Execute it, or return the error message if there's a problem. $result = mysql_query($query) or die(mysql_error()); $dropdown = "<select name='Mobile_DB_table'>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['Full_Phone_Name']}'>{$row['Full_Phone_Name']}</option>"; } $dropdown .= "\r\n</select>"; echo $dropdown; ?> <iframe src='http://www.somedomain.com/iframe.php?make=INSERT_MAKE_HERE&model=INSERT_MODEL_HERE' style='width:100%; height: 1000px' scrolling='auto' frameborder='0' ></iframe> </body> </html> Quote Link to comment Share on other sites More sharing options...
n1concepts Posted July 2, 2012 Share Posted July 2, 2012 You should look at AJAX for this - Here's a simple solution that works. All you have to do is modify the code to suit your objectives. http://www.w3schools.com/php/php_ajax_database.asp That should get you squared away! brgds, Craig Quote Link to comment Share on other sites More sharing options...
daniel_son Posted July 2, 2012 Author Share Posted July 2, 2012 Thanks, I actually looked at that earlier today. Im afraid Im far from a coder so couldn't make sense of it. I really need someone to provide the code for me. Happy to donate to somebody if they could knock this functionality up for me. (Dropdown list of phone names, where the iframe underneath loads according to the item in the list they select) I need to start making attempts to network with new php devs as the guy I normally use is unavailable. Hope someone can help with this, thanks J Quote Link to comment Share on other sites More sharing options...
n1concepts Posted July 2, 2012 Share Posted July 2, 2012 Shoot me a private message and I'll do it for you - no problem. Quote Link to comment Share on other sites More sharing options...
sloth456 Posted July 3, 2012 Share Posted July 3, 2012 Can you please post the contents of iframe.php, also a link to view in the browser would be useful but not essential. The code you have posted has a drop down, but no 'submit' button to click and update the iframe. You can either include a submit button or use javascript to automatically detect when the drop down changes and reload the iframe. If you can show us the code iframe.php and give us a link to the page you are trying to change this should be pretty easy to solve. 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.