我試圖解決一個問題,但沒有成功。我從谷歌分析檢索數據,我必須發送開始和結束日期。我有兩個文本框和用戶選擇的開始和結束日期。但是,但在用戶選擇開始和結束日期。出現該問題的..php - isset按鈕
,我使用isset是這裏的地方,
這是我的全功能HTML
<?php
define('ga_email','[email protected]');
define('ga_password','************');
define('ga_profile_id','*******');
require 'gapi.class.php';
require 'connectDB.php';
$ga = new gapi(ga_email,ga_password);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>İçerik</title>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com
</script>
</head>
<div></div>
<body>
<table align="center">
<tr>
<td><br />
<br />
<form action="#" method="post" name="formDates" id="form1" >
<table width="303" height="40" border="0" align="center">
<table width =""
<tr>
<td>Başlangıç Tarihi</td>
<td>
<label for="txtStartDate"></label>
<input type="text" name="txtStartDate" id="txt1" value="" /><a href="javascript:NewCal('txt1','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Başlangıç Tarihi Seçin">
</a>
</td>
</tr>
<tr>
<td>Bitiş Tarihi</td>
<td>
<label for="txtEndDate"></label>
<input type="text" name="txtEndDate" id="txt2" /><a href="javascript:NewCal('txt2','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Bitiş Tarihi Seçin">
</a>
</td>
</tr>
</form>
<tr>
<td><input type="submit" name="btnSubmit" value="Gönder"</td>
</tr>
</table>
<table width="1250" height="26" align="center">
<tr>
<td width="138"><strong>Kanal Adı</strong>
<td width="150"><b>Kategori Adı</b></td>
<td width="130"><p><strong>Event Adı</strong></td>
<td width="145"><strong>Toplam</strong>
</tr>
</table>
<?php
if(isset($_POST['submit'])){
$startDate = $_POST['txtStartDate'];
$endDate = $_POST['txtEndDate'];
}
$arrDates = explode("-",$startDate);
$startDate=$arrDates[2]."-".$arrDates[1]."-".$arrDates[0];
$arrDates = explode("-",$endDate);
$endDate = $arrDates[2]."-".$arrDates[1]."-".$arrDates[0];
echo $startDate;
echo $endDate;
$ga->requestReportData(ga_profile_id,array('eventCategory','eventAction'),array('totalEvents'),$sort_metric=null,$filter='eventAction==InitPlayer',$start_date='2012-02-02',$end_date='2012-02-16');
foreach($ga->getResults() as $result2);
{
echo $result2->geteventCategory();
echo $result2->geteventAction();
echo $result2->gettotalEvents();
}
$ga->requestAccountData();
$mysql = new mysql();
$mysql->connect();
$counter = 0;
foreach($ga->getResults() as $result)
{
echo $result . ' (' . $result->getProfileId() . ")<br />";
echo "<br />";
$counter++;
}
$result = mysql_query("select profile_id from profiles");
$num_rows = mysql_num_rows($result);
if($counter != $num_rows)
{
$mysql->query("delete from profiles");
foreach($ga->getResults() as $result)
{
$mysql->query("insert into profiles values(".$result->getProfileId().",'".$result."')");
}
}
?>
</td>
</tr>
</table>
</body>
</head>
</html>
有什麼不好?
如果選擇開始和結束日期的問題是解決了,之前發生的問題,我選擇
郵政HTML表單的類型 btnSubmit按鈕=名稱。爲什麼不測試$ _POST ['txtStartDate']是否被設置?如果txtStartDate和textEndDate未通過發送錯誤消息或拋出異常來設置,請確保相應地作出反應。 – busypeoples 2012-02-17 07:49:24
你確定在你的html表單中,輸入元素有'name'屬性嗎? (isset($ _ POST ['txtStartDate'])&& isset($ _ POST ['txtEndDate'])) { {0} {start} = $ _POST [*]如果沒有HTML代碼很難提供幫助,但這是我在黑暗中拍攝的 – xbonez 2012-02-17 07:55:36