Jump to content

PHP Echo result


fisher7679

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.