kg Posted March 9, 2011 Share Posted March 9, 2011 Hi I'm using codeigniter for my php project i' already have a drop down list displayed in one page of the web browser which had dynamic values from my database, as soon as you click on the submit button it takes you to another page which has to display the cities from my database and that is not happening at the moment, this code used to work nicely when i had the cities displayed in a single page as the drop menu but doesn't anymore since i need the cities displayed on another page ,any help will be highly appreciated. <? function writeCities($id) { $con = mysql_connect("localhost","root",""); if (!$con) die('Could not connect: ' . mysql_error()); mysql_select_db("msansi", $con); $query = "SELECT cities FROM provinces WHERE id ="; $query .= $id; $result = mysql_query($query); $row = mysql_fetch_array($result); echo $row[0]; } function onChangeDropBox() { var selected =0; selected = document.myform.province.value; var t = ["<? writeCities(9);?>";] document.myform.submit.value = t; } Link to comment https://forums.phpfreaks.com/topic/230092-php-code-problem/ Share on other sites More sharing options...
cyberRobot Posted March 9, 2011 Share Posted March 9, 2011 I think the issue is that you're trying to call a PHP function from within JavaScript. Unfortunately, you can't do that on the client side. If you want PHP to process the drop-down selection, you need to submit the form back to the server where PHP is processed. What are you trying to accomplish? Link to comment https://forums.phpfreaks.com/topic/230092-php-code-problem/#findComment-1184992 Share on other sites More sharing options...
cyberRobot Posted March 9, 2011 Share Posted March 9, 2011 Actually, I'm a bit confused. Which page is the above code for? Is it the code for the second page; after the initial form is submitted? We may need to see a little more of the code. Also, please use the code tags ([ code ][ /code ]) when posting code. You'll need to remove the spaces from the code tag. I just added them to prevent the forum from interpreting them. Or you could just click the button that looks like a pound/hash sign (#) when composing a message. Link to comment https://forums.phpfreaks.com/topic/230092-php-code-problem/#findComment-1184997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.