Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在帧之间传递php变量_Php_Javascript_Mysql_Ajax_Variables - Fatal编程技术网

在帧之间传递php变量

在帧之间传递php变量,php,javascript,mysql,ajax,variables,Php,Javascript,Mysql,Ajax,Variables,我在一个帧集中有一个PHP变量,它需要同时传递给另外两个帧。其中一个帧每5秒刷新一次,可以轻松地从URL获取变量。另一个框架不刷新,因为它是一个窗体。在发送信息之前,该框架/表单需要填充一个禁用的字段。我不知道在AJAX中是否可行 除了HTML、CSS和基本PHP之外,我什么都不精通,所以我对这个问题很感兴趣 请参考代码和更多解释-谢谢 嗯,我有一张照片,但由于我的声誉太低,我不能给你看。。。数字 不管怎样,代码如下: 主框架页面: <!DOCTYPE html> <html

我在一个帧集中有一个PHP变量,它需要同时传递给另外两个帧。其中一个帧每5秒刷新一次,可以轻松地从URL获取变量。另一个框架不刷新,因为它是一个窗体。在发送信息之前,该框架/表单需要填充一个禁用的字段。我不知道在AJAX中是否可行

除了HTML、CSS和基本PHP之外,我什么都不精通,所以我对这个问题很感兴趣

请参考代码和更多解释-谢谢

嗯,我有一张照片,但由于我的声誉太低,我不能给你看。。。数字

不管怎样,代码如下:

主框架页面:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Incident Entry</title>
</head>
<frameset border="0" frameborder="0" rows="50%,50%">
<frameset border="0" frameborder="0" cols="40%,60%">
<frame src="incidententry.php" name="topleft">
<frameset border="0" frameborder="0" rows="56%,44%">
<frame src="detailentry.php" name="toprighttop">
<frame src="details.php" name="toprightbottom">
</frameset>
</frameset>
<frame src="incidents.php" name="bottom">
</frameset>
</html>
events.php:

<?php header ('Refresh: 5');
session_start();
if($username);
?>
<!DOCTYPE html>
<html lang="en">
<title>Incidents</title>
<?php mysql_connect("-----", "-----", "------");
@mysql_select_db(-----_incidents);
$sql2="SELECT * FROM  incidents ORDER BY id DESC LIMIT 10";
$result2=mysql_query($sql2);
$num=mysql_numrows($result2);
?>
<head>
<link rel="stylesheet" type="text/css" href="output1.css">
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0)">
<meta http-equiv="Page-Enter" content="revealtrans(duration=0.0">
<style type="text/css">
body{background-color:black}
body{font-family:'trebuchet ms' }
</style>
</head>
<body>
<font color="white">
<div class="CSSTableGenerator">
<table border='0' rules='all' width='75%'>
<tr class="hideextra">
<td>Inc #</td>
<td>Date</td>
<td>Time</td>
<td>City</td>
<td>Dept</td>
<td>Alarm Level</td>
<td>Incident Type</td>
<td>Address</td>
<td width="53px">User</td>
<td>Upgr</td>
</tr>
<?php
$_GET['id'];
while($row=mysql_fetch_array($result2)){
$id2 = $row['id'];
$id = str_pad($id2,9, "2013-0000", STR_PAD_LEFT);
$date=rtrim(ltrim($row['date'], "2013-"), "0..9,:");
$time=$row['time'];
$city=$row['city'];
$fire=$row['fire'];
$addy=$row['addy'];
$level=$row['level'];
$desc=$row['desc'];
$units=$row['units'];
$who=$row['who'];
echo "<tr>";
echo "<td style='white-space:nowrap;'><center>&nbsp<a href='http://www.------.com/pages/CAD/details.php?inci_num=$id' target='toprightbottom'>" . str_pad($row['id'],9,"2013-00000",STR_PAD_LEFT) . "</a></center></td>";
echo "<td style='white-space:nowrap;'><center>" . str_pad($date,6,'0',STR_PAD_LEFT) . "</center></td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['fire'] . "</td>";
echo "<td>" . $row['level'] . "</td>";
echo "<td>" . $row['desc'] . "</td>";
echo "<td>" . $row['addy'] . "</td>";
echo "<td>" . strtoupper($row['who']) . "</td>";
echo "<td><center><a href='http://www.------.com/pages/CAD/upgrade.php?id=$id2' target='_self'><img src='http://www.------.com/images/arrow_red_up.gif' height='16'></a></center></td>";
echo "</tr>"; 
echo "</div>";
}
?>
</table>
</html>
details.php:

<?php header ('Refresh: 5'); ?>
<!DOCTYPE html>
<html lang="en">
<title>Incident Details</title>

<?php 
mysql_connect("-------", "-------", "------");
@mysql_select_db(------);
$inci_num2=$_GET['inci_num'];
$sql3="SELECT * FROM notes2 WHERE inci_num='$inci_num2' ORDER BY id DESC";
$result4=mysql_query($sql3);
?>
<head>
<link rel="stylesheet" type="text/css" href="output1.css">
<style type="css/text">
body{background-color:black}
body{font-family:'trebuchet ms' }
</style>
</head>
<body bgcolor="black">
<font color="white">
<div class="CSSTableGenerator">
<table rules="all">
<tr class="hideextra">
<td>#</td>
<td width="46px">Time</td>
<td>Incident Notes</td>
<td width="53px">User</td>
</tr>
<?php
$_POST['inci_num'];
while($row=mysql_fetch_array($result4)){
$id=$row['id'];
$ipaddress=$row['ipaddress'];
$inci_num=$row['inci_num'];
$notes=$row['notes'];
$Time1=$row['Time1'];
$user=$row['who'];
echo "<tr>";
echo "<td>&nbsp" . $row['inci_num'] . "</td>";
echo "<td>" . $row['Time1'] . "</td>";
echo "<td>" . $row['notes'] . "</td>";
echo "<td>" . $row['who'] . "</td>";
echo "</tr>";
echo "</div>";
}
?>
</table>
</body>
最后是detailentry.php:

<?php 
session_start();
if($username)

ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
$id2=$_GET['inci_num2'];
if(isset($_POST['submit'])){
$db=mysql_connect("------", "-----", "------") or die ("Cant connect");
$mydb=mysql_select_db("----_incidents") or die ("Cant find db");
$notes = mysql_real_escape_string($_POST['notes']);
$who = strtoupper($_COOKIE['username']);
$ipaddress = $_SERVER['REMOTE_ADDR']."\r\n";
$inci_num1 = $_POST['inci_num'];
$inci_num = str_pad($inci_num1,9, "2013-0000", STR_PAD_LEFT);
if(!isset($_POST["auto"])){
$sql = "INSERT INTO `notes2` (`id` , `inci_num` , `notes` , `who` , `ipaddress` , `Date` , `Time1`) VALUES (NULL, '".$inci_num."' , '".$notes."' , '".$who."' , '".$ipaddress."' , NOW(), DATE_ADD(NOW(),INTERVAL 120 MINUTE))";
}else{
$sql = "INSERT INTO `notes2` (`id` , `inci_num` , `notes` , `who` , `ipaddress` , `Date` , `Time1`) VALUES (NULL, '".$inci_num."' , '".$notes."' , '".$who."' , '".$ipaddress."' , NOW(), DATE_ADD(NOW(),INTERVAL 120 MINUTE))";
}
$result = mysql_query($sql) or die ("Cant insert ".mysql_error());
if($result)
{
}
else
{
}}
?>
<title>Detail Entry</title
<head>
<style type="css/text">
body{overflow-y:hidden; 
white-space-collapse:collapse;}
body{background-color:black}
body{font-family:'trebuchet ms' }
.body{font-family:'trebuchet ms' }
.hide{visibility:collapse; }
#hide{visibility:collapse; }
.nopad{padding-bottom:0px; margin-bottom:0px; }
.borders{ }
</style>
</head>
<body bgcolor="black" class="body" style="font-family:'trebuchet ms';">
<form action="detailentry.php" method="POST" style="white-space-collapse:collapse;">
<font color="white">
<table border="0" class="borders">
<tr>
<td><font color="white" size="3">Inc #:</font></td>
<td><font color="white"><input type="text" maxlength="11" value="<?php echo $id2;?>" required name="inci_num">&nbsp RM911 ID:</font></td>
<td><center><font color="white"><? echo strtoupper($_COOKIE['username']);?></font></center></td>
</tr>
<tr>
<td><font color="white">Notes:</td>
<td colspan="2"><textarea placeholder="Enter Incident Notes here" required rows="4" cols="36" name="notes"></textarea></td>
</tr><input id="hide" style="visibility:collapse;" class="hide" hidden type="checkbox" name="auto" value="auto" checked>
<tr class="nopad">
<td class="nopad" colspan="3" align="center"><input class="nopad" type="submit" name="submit" value="Submit"><input class="nopad" type="reset"></td>
</tr>
</table>
</form>
</body>
</html>
**注意:我知道我应该使用新语法,请一次做一件事。同时,我也意识到,代码应该变得更好,更容易阅读。同样,这是次要的解决这个问题

这就是我努力实现的目标: 我需要从events.php页面获取$id2变量,并在用户单击events.php上的事件编号时将其同时传输到details.php和detailentry.php。在detailentry.php上,$id2需要位于Inc:文本输入框中


提前感谢您的帮助

嗯。一个8岁的问题没有人回答。还有两个答案只是不屑一顾的评论

这里有一个真正的答案:您可以通过创建会话变量在帧之间传递数据。会话变量可在帧之间访问。有完整的信息

我看到您在3个php文件中的两个文件中启动了会话。将其添加到第三个的顶部。然后为会话变量指定要传递给另一帧的任何值:

$\会话['vartopass']=$varyouwanttopass

现在$\u SESSION['vartopass']在以SESSION\u start开头的其他帧中可用

$variwantedinthisframe=$\会话['vartopass']


所以,是的,晚了8年。到现在为止,你可能已经明白了这一点,但其他人还没有,我讨厌对任何人都没有帮助的轻蔑言论。

很抱歉,我没有真正理解你想要实现的目标,但是:$inci_num2=$\u GET['inci_num'$sql3=从notes2中选择*,其中inci_num=“$inci_num2”按id DESC排序;这部分是一个真正的问题,请阅读:您需要$username变量吗?我很抱歉-我已经用我希望实现的目标更新了它。我认为每个人和他们的祖母都在1998年停止使用框架,这是有充分理由的。您使用PHP本身就足以保证不使用框架。我们距离第一家特易购公司开业已经有2013年了。请停止使用框架其他框架不会刷新,因为它是表单。在发送信息之前,该框架/表单需要填充一个禁用的字段——我不知道这在AJAX中是否可行——单独使用会话是不可能的,除非您刷新所有其他框架以侦听此类更改