fisher7679 Posted October 1, 2013 Share Posted October 1, 2013 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? Link to comment https://forums.phpfreaks.com/topic/282616-php-echo-result/ Share on other sites More sharing options...
Ch0cu3r Posted October 1, 2013 Share Posted October 1, 2013 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> Link to comment https://forums.phpfreaks.com/topic/282616-php-echo-result/#findComment-1452107 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. Link to comment https://forums.phpfreaks.com/topic/282616-php-echo-result/#findComment-1452108 Share on other sites More sharing options...
Ch0cu3r Posted October 1, 2013 Share Posted October 1, 2013 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) Link to comment https://forums.phpfreaks.com/topic/282616-php-echo-result/#findComment-1452109 Share on other sites More sharing options...
fisher7679 Posted October 2, 2013 Author Share Posted October 2, 2013 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. Link to comment https://forums.phpfreaks.com/topic/282616-php-echo-result/#findComment-1452124 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. Link to comment https://forums.phpfreaks.com/topic/282616-php-echo-result/#findComment-1452125 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.