从另一个包含post方法的html文件调用html文件

时间:2016-05-04 09:49:32

标签: php html

如何在html文件中调用html文件2(它显示我需要的图片)1,其中包含两个文本字段和一个用户将填充的列表,我将在.php文件中恢复。 我的问题是当我点击显示按钮时,我发现自己在.php页面中感谢方法=" post" action ="在html文件中找到transfert.php 1 我需要将这些值传输到.php文件,但我不想领导它,因为我想显示我需要的图像。 这是我的html文件1:



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Interface</title>
</head>
<body>

<form name="form1" method="post" action="transfert.php">
<p>Date de Debut : 
<input type="text" name="date1" id="champ_date1" size="12" maxlength="20" /></p>

<p>Date de Fin : 
<input type="text" name="date2" id="champ_date1" size="12" maxlength="20" /> </p>

<p> choisir KPI  
<select name="list" size="1" id="0">
<option value="TotalVoiceTrafficBH1" id="1">TotalVoiceTrafficBH1</option>
<option value="TotalVoiceTrafficBH2" id="2">TotalVoiceTrafficBH2</option>
<option value="CSSRBH1" id="3">CSSRBH1</option>
<option value="CSSRBH2" id="4">CSSRBH2</option>
<option value="TCHBlockingBH1" id="5">TCHBlockingBH1</option>
<option value="TCHBlockingBH2" id="6">TCHBlockingBH2</option>
<option value="SDCHHBlockingBH1" id="7">SDCHHBlockingBH1</option>
<option value="SDCCHBlockingBH2" id="8">SDCCHBlockingBH2</option>
<option value="SDCCHDropBH1" id="9">SDCCHDropBH1</option>
<option value="SDCCHDropBH2" id="10">SDCCHDropBH2</option>
<option value="TCHDropBH1" id="11">TCHDropBH1</option>
<option value="TCHDropBH2" id="12">TCHDropBH2</option>
<option value="HOSRBH1" id="13">HOSRBH1</option>
<option value="HOSRBH2" id="14">HOSRBH2</option>
</select>	 
</p>
<p><input type="submit" value="Afficher" size="15"/>
</p>
</form>
// here i wanna to insert my html file 2 so i can get my picture
</body>
</html>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:0)

似乎英语不是您的主要语言,所以您的问题不是那么清楚。 我不知道你的问题是什么以及你打算实现什么,但是有两个观察结果。

  1. 为什么不发布html2文件和transfert.php。它可能会为我们提供有关您遇到问题的原因的线索
  2. 为什么要在一个应用程序中混合使用php和html文件类型?由于你的网站不会是静态的,我建议你坚持使用php全部通过

答案 1 :(得分:0)

所以这是我的php文件和我的html2文件,我需要从我的html1文件中获取由我的html2文件生成的图表。问题是我在点击显示按钮的同时自动重定向到我的transfert.php页面,但我想将变量发送到transfert.php并从我的html2文件中获取我的图表。

1

//transfert.php
<?php
$var1=$_POST['date1'];
$var2=$_POST['date2'];
$var3=$_POST['list'];

    if($var1 != NULL AND $var2 != NULL AND $var3 != NULL)
   {
//address of the server where db is installed
$servername = "localhost";

//username to connect to the db
//the default value is root
$username = "root";

//password to connect to the db
//this is the value you would have specified during installation of WAMP stack
$password = "";

//name of the db under which the table is created
$dbName = "test";

//establishing the connection to the db.
$conn = new mysqli($servername, $username, $password, $dbName);

//checking if there were any error during the last connection attempt
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
                           }

//the SQL query to be executed
$query = "SELECT A,$var3 FROM `feuil1` WHERE A >= '$var1' AND A<= '$var2'";

//storing the result of the executed query
$result = $conn->query($query);
 //initialize the array to store the processed data
//initialize the array to store the processed data
$jsonArray = array();
//check if there is any data returned by the SQL Query
if ($result->num_rows > 0) {

  //Converting the results into an associative array
 while($row = $result->fetch_assoc()) 
  {
    $jsonArrayItem = array();
    $jsonArrayItem['label'] = $row['A'];
    $jsonArrayItem['value'] = $row[$var3];
	
    //append the above created object into the main array.
    array_push($jsonArray, $jsonArrayItem);
  }             


//Closing the connection to DB
//$conn->close();
$con = new mysqli($servername, $username, $password, $dbName);
					if ($con->connect_error) 
					{
                      die("Connection failed: " . $con->connect_error);
                    }
					
					

          if (is_array($jsonArray)) {
		  
				$sql = "TRUNCATE TABLE `table_temporaire`";
				$res = $con->query($sql);

         foreach ($jsonArray as $row) { 

                    $id = $row['label'];
                    $na = $row['value']; 
	$st = $con-> prepare("INSERT INTO `table_temporaire`(A, $var3) VALUES (?, ?)");
    $st->bind_param('ss', $id, $na);
					
             $st->execute();
	
                                     
									  }
                                   }
								   
				    }
					$con->close();
				}
		if($var1 == NULL)
    {
        echo 'Vous devez entrer date de Debut';
    }
    if($var2 == NULL)
    {
        echo 'Vous devez entrer date de Fin';
    }
	
							
  ?>

答案 2 :(得分:0)

啊哈!我知道了! 我认为如果你使用fusionchart.php包装,它会让你的生活更轻松。

这允许您从数据库加载数据, 在jsonarray中编码,然后像下面那样调用它

$columnChart = new FusionCharts("column2D", "myFirstChart" , 600, 300, "chart-1", "json", $jsonEncodedData);
// Render the chart
$columnChart->render();