- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试获取一个 php 页面以从数据库中检索,我是 php 的新手,我已经用 google 搜索并阅读了,但我只是没有得到它。我有一个链接到 php 的 htm 页面,因为我试图根据所选的复选框和条件框中提交的信息返回一些数据。这是我到目前为止所拥有的,我一直在搞乱一些查询,试图让它工作,所以如果我能让其中一个工作,我就可以让剩下的去做我想做的事情。我知道我的代码可能不符合标准,但这不是我的职业,我只是一个试图让他的项目正常运行的学生。请引导我走向正确的方向。
编辑:这是我的一个学校项目,我必须使用他们服务器上的内容,在本例中恰好是 mysql。我没有得到任何返回,没有错误或任何东西。当我从 htm 页面转到 php 页面时,没有任何反应。我只是认为我可能必须从运行一个简单的查询开始只是为了调试以确保我可以获得任何内容,然后从那里进行修改。我以前从未使用过复选框,也从未运行过查询,所以我不得不相信这就是我的错误所在。我的所有插入和更新语句都在我的其他页面上工作,但代码用于选择语句并将它们放入变量的方式让我非常困惑。
我的htm页面:
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<span class="spanFormat"><form><input type="button" value="Create a New Ticket" onClick="window.location.href='listinput.htm'"></form></span>
<span class="spanFormat"><form><input type="button" value="Resolve a Ticket" onClick="window.location.href='resolution.htm'"></form></span>
<span class="spanFormat"><form><input type="button" value="Search for a Ticket" onClick="window.location.href='searchinput.htm'"></form></span>
<span class="spanFormat"><form><input type="button" value="View Documentation" onClick="window.location.href='documentation.htm'"></form></span>
<?php
DEFINE('DB_USER',);
DEFINE('DB_PASSWORD',);
DEFINE('DB_NAME',);
DEFINE('DB_HOST','localhost');
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$con){
die('Could not connect: '.mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $con);
if(!$db_selected){
die('can\'t use'. DB_NAME . ':'.mysql_error());
}
?>
<form action="searchinput.php" method="post">
<p>
How would you like to search?<br/>
<input type="checkbox" name="formDoor[]" id="Ticket_ID" value="Ticket_ID" />By Ticket Number<br />
<input type="checkbox" name="formDoor[]" id="Last_Name" value="Last_Name" />By Last Name<br />
<input type="checkbox" name="formDoor[]" id="Station_ID" value="Station_ID" />By Station ID<br />
<input type="checkbox" name="formDoor[]" id="Date" value="Date" />By Date<br />
<input type="checkbox" name="formDoor[]" id="Description" value="Description" />By Description
</p>
<td>Criteria</td>
<td><input type=text name="Criteria" size=30> </td>
</form>
<input type=submit name="submit" value="Search">
</body>
</html>
这是我的 php:
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<span class="spanFormat"><form><input type="button" value="Create a New Ticket" onClick="window.location.href='listinput.htm'"></form></span>
<span class="spanFormat"><form><input type="button" value="Resolve a Ticket" onClick="window.location.href='resolution.htm'"></form></span>
<span class="spanFormat"><form><input type="button" value="Search for a Ticket" onClick="window.location.href='searchinput.htm'"></form></span>
<span class="spanFormat"><form><input type="button" value="View Documentation" onClick="window.location.href='documentation.htm'"></form></span>
<?php
DEFINE('DB_USER',);
DEFINE('DB_PASSWORD',);
DEFINE('DB_NAME',);
DEFINE('DB_HOST','localhost');
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$con){
die('Could not connect: '.mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $con);
if(!$db_selected){
die('can\'t use'. DB_NAME . ':'.mysql_error());
}
extract($_POST);
$Ticket_ID = ($_POST['Criteria']);
$Last_Name = ($_POST['Criteria']);
$Station_ID = ($_POST['Criteria']);
$Date = ($_POST['Criteria']);
$Description = ($_POST['Criteria']);
if(isset($_POST['$Ticket_ID']))
{$sql = "select Ticket_ID, customer.Customer_ID, First_Name, Last_Name, Phone_Num, Email, stations.Station_ID, Room_ID, Floor_ID, building.Building_ID, Location, incident_sheet.Description, Summary, assign_groups.Group_ID, assign_groups.Description, resolutions.Resolution_ID, resolutions.Description from customer,stations,resolutions,assign_groups, building, incident_sheet WHERE customer.Customer_ID=incident_sheet.Customer_ID AND stations.Station_ID = customer.Station_ID AND building.Building_ID=stations.Building_ID AND resolutions.Resolution_ID = incident_sheet.Resolution_ID AND assign_groups.Group_ID = incident_sheet.Group_ID AND customer.Customer_ID = ($_POST[Criteria]);";
$result = mysql_query($sql, $con);
while($row = mysql_fetch_array($result))
{
$Ticket_ID = $row['Ticket_ID'];
echo
}
}
if(IsChecked('formDoor[]','Last_Name'))
{ $select_query = "select I.Ticket_ID, I.Customer_ID, I.Description, I.Date, C.Station_ID, C.First_Name, C.Last_Name, C.Phone_num, C.Email, S.Building_ID, S.Floor_ID, S.Room_ID, B.Location, A.Assign_Groups, R.Resolutions;
from incident_sheet I, customer C, stations S, building B, assign_groups A, resoultions R;
where I.Customer_ID = C.Customer_ID,
and C.Station_ID = S.Station_ID,
and S.Building_ID = B.Building_ID,
and I.Group_ID = A.Group_ID,
and I.Resoultion_ID = R.Resoultion_ID,
order by Last_Name;"
}
if(IsChecked('formDoor[]','Station_ID'))
{ $select_query = "select I.Ticket_ID, I.Customer_ID, I.Description, I.Date, C.Station_ID, C.First_Name, C.Last_Name, C.Phone_num, C.Email, S.Building_ID, S.Floor_ID, S.Room_ID, B.Location, A.Assign_Groups, R.Resolutions;
from incident_sheet I, customer C, stations S, building B, assign_groups A, resoultions R;
where I.Customer_ID = C.Customer_ID,
and C.Station_ID = S.Station_ID,
and S.Building_ID = B.Building_ID,
and I.Group_ID = A.Group_ID,
and I.Resoultion_ID = R.Resoultion_ID,
order by Station_ID;"
}
if(IsChecked('formDoor[]','Date'))
{ $select_query = "select I.Ticket_ID, I.Customer_ID, I.Description, I.Date, C.Station_ID, C.First_Name, C.Last_Name, C.Phone_num, C.Email, S.Building_ID, S.Floor_ID, S.Room_ID, B.Location, A.Assign_Groups, R.Resolutions;
from incident_sheet I, customer C, stations S, building B, assign_groups A, resoultions R;
where I.Customer_ID = C.Customer_ID,
and C.Station_ID = S.Station_ID,
and S.Building_ID = B.Building_ID,
and I.Group_ID = A.Group_ID,
and I.Resoultion_ID = R.Resoultion_ID,
order by Date;"
}
if(IsChecked('formDoor[]','Description'))
{ $select_query = "select I.Ticket_ID, I.Customer_ID, I.Description, I.Date, C.Station_ID, C.First_Name, C.Last_Name, C.Phone_num, C.Email, S.Building_ID, S.Floor_ID, S.Room_ID, B.Location, A.Assign_Groups, R.Resolutions;
from incident_sheet I, customer C, stations S, building B, assign_groups A, resoultions R;
where I.Customer_ID = C.Customer_ID,
and C.Station_ID = S.Station_ID,
and S.Building_ID = B.Building_ID,
and I.Group_ID = A.Group_ID,
and I.Resoultion_ID = R.Resoultion_ID,
order by Description;"
}
?>
<h3>This is the current ticket information: </h3>
<p>
<table>
<tr>
<td>First Name:</td>
<td><?php echo ("$First_Name"); ?></td>
</tr>
<tr>
<td>Last Name:</td>
<td><?php echo "$Last_Name"; ?></td>
</tr>
<tr>
<td>Email:</td>
<td><?php echo "$Email"; ?></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><?php echo "$Phone_Num"; ?></td>
</tr>
<tr>
<td>Building:</td>
<td><?php echo "$Building_ID"; ?></td>
</tr>
<tr>
<td>Floor:</td>
<td><?php echo "$Floor_ID"; ?></td>
</tr>
<tr>
<td>Room:</td>
<td><?php echo "$Room_ID"; ?></td>
</tr>
<tr>
<td>Group:</td>
<td><?php echo "$Group_ID"; ?></td>
</tr>
<tr>
<td>Description:</td>
<td><?php echo "$Description"; ?></td>
</tr>
</table>
</p>
</body>
</html>
如果您能提供任何帮助使其正常工作,我们将不胜感激,感谢您花时间查看此内容。
最佳答案
你没有忘记定义这个值,对吧?不显示调试信息的服务器不会向您显示任何内容(可能是 500 错误页面)
DEFINE('DB_USER',<something>);
DEFINE('DB_PASSWORD',<something>);
DEFINE('DB_NAME',<something>);
DEFINE('DB_HOST','localhost');
关于Php 到 MySql 选择查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12113765/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!