fisher7679 Posted October 1, 2013 Share Posted October 1, 2013 (edited) Still learning...............So I have now been able to make my dropdown menu pass the results to the php page from the data stored in mysql and show the results with echo on the php page. But I would like those results to be displayed on the same page. How would I start going about this? Edited October 1, 2013 by fisher7679 Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 1, 2013 Share Posted October 1, 2013 (edited) So the form and database code are in two separate files? For example the the html form is in form.php and it submits the form to add_to_database.php. But what you're wanting it do is display the form and database results on same page? If so make the form in form.php submit to itself (<form action="form.php" method="post">) Then just include add_to_database.php in form.php where you want the results to appear. Example <?php include 'add_to_database.php'; ?> <form action="form.php" method="post"> // your form fields here </form> Edited October 1, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
fisher7679 Posted October 1, 2013 Author Share Posted October 1, 2013 The page the form is located on is a html page, it then submits the results to the php page to get the data from the database. I would like the results to appear under the submit button on the html page if able to do so. Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted October 1, 2013 Solution Share Posted October 1, 2013 (edited) Change the html page to a php page (by changing the file extension to .php). Then change the forms submit action to submit to itself. And include the php page below the form using include (like my example above) Edited October 1, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
fisher7679 Posted October 2, 2013 Author Share Posted October 2, 2013 (edited) Ok, not sure why but the echo results are not showing on the page. Here is the form code. Also I changed it to .php, added the include and set the action to post to itself like stated above. <form action="f0rm.php" method="post"> <p align="center" style="margin-bottom: 0"> <b><font size="3">Test</font></b></p> <p align="center" style="margin-bottom: 0"> <option value=""></option> <option value=""></option> <option value=""></option> <option value=""></option> </select> <br /> <br /> </p> <p align="center"> <input class="button" type="submit" name="submit" value="Submit"> </p> </form> <!--?php include 'data.php'; ?--> Could it be an issue with the echo? Here us the php code I am using for tetsting <?php mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error()); $term1 = $_POST['term1']; $term2 = $_POST['term2']; $term3 = $_POST['term3']; $term4 = $_POST['term4']; $term5 = $_POST['term5']; $term6 = $_POST['term6']; $term7 = $_POST['term7']; $term8 = $_POST['term8']; $term9 = $_POST['term9']; $term10 = $_POST['term10']; $sql = ("my sql string here"); $rs_result = mysql_query ($sql); $num_rows = mysql_num_rows($rs_result); $total_rows = mysql_num_rows($data2); $result = ($num_rows/($total_rows)); $percent = round($result*100, 4, PHP_ROUND_HALF_UP); { } echo "$percent%"; ?> Any further help her would be appreciated as I am stumped. Thanks in advance. Edited October 2, 2013 by fisher7679 Quote Link to comment Share on other sites More sharing options...
fisher7679 Posted October 2, 2013 Author Share Posted October 2, 2013 I figured it out, didnt catch the -- in the insert code that had to be removed. Thanks for the help earlier. 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.