0

我在一个框架集中的一个框架中有一个 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>

事件.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>

详细信息.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>

**注意:我知道我应该使用新语法,请一次做一件事。另外,我意识到代码变得更好更容易阅读。同样,这是解决此问题的次要问题。

这就是我想要完成的事情:我需要$id2从页面中获取变量incidents.php并同时将其传输到两者details.php,并且detailentry.php当用户点击事件编号时incidents.php。开detailentry.php$id2需要在Inc #:文本输入框中。

提前谢谢你的帮助!!!

4

1 回答 1

-1

唔。一个8岁的问题,没人回答。和 2 个“答案”只是不屑一顾的评论。

这是一个真正的答案:您可以通过创建会话变量在帧之间传递数据。会话变量可在帧之间访问。https://www.php.net/manual/en/reserved.variables.session.php有完整的信息。

我看到你session_start()在你的 3 个 php 文件中有两个。将其添加到第三个的顶部。然后使用您想要传递给另一个框架的任何值分配一个会话变量:

$_SESSION['vartopass']=$varyouwanttopass;

now在以 .$_SESSION['vartopass']开头的其他框架中可用session_start()

$variwantedinthisframe=$_SESSION['vartopass'];

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

于 2021-03-25T05:46:16.100 回答