Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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和oracle获取多个查询结果并显示到表中_Php_Html_Sql_Oracle - Fatal编程技术网

使用php和oracle获取多个查询结果并显示到表中

使用php和oracle获取多个查询结果并显示到表中,php,html,sql,oracle,Php,Html,Sql,Oracle,我的问题是我有一个链接到Oracle中多个表的网站。我目前有PHP代码,它检查分配给变量的用户输入,以查找表中的数据,然后是oci_fetch_row语句,该语句获取数据匹配的行。这很好,但如果某些值相同,我找不到如何从表中输出多行 目前,它获取的一行被放入一个简单的HTML表中 对于如何获取数据匹配的所有行并将其输出到表中的任何帮助,我们都将不胜感激 我的代码是: $userfeedback = "SELECT * FROM ASSET_FEEDBACK WHERE USER_EMAIL =

我的问题是我有一个链接到Oracle中多个表的网站。我目前有PHP代码,它检查分配给变量的用户输入,以查找表中的数据,然后是oci_fetch_row语句,该语句获取数据匹配的行。这很好,但如果某些值相同,我找不到如何从表中输出多行

目前,它获取的一行被放入一个简单的HTML表中

对于如何获取数据匹配的所有行并将其输出到表中的任何帮助,我们都将不胜感激

我的代码是:

$userfeedback = "SELECT * FROM ASSET_FEEDBACK WHERE USER_EMAIL = '$userEmail' ORDER BY FEEDBACK_DATE";

$stmt3 = oci_parse($conn, $userfeedback);

if(oci_execute($stmt3))

{


    $row=oci_fetch_row($stmt3) ;

    print"<h2 id='title'>This Users Feedback</h2>";
    "<table border='2'>";

    print"<tr><td><p>Feedback ID:</td><td>$row[0]</td></tr>";
    print"<tr><td>Asset ID:</td><td>$row[1]</td></tr>";
    print"<tr><td>Feedback:</td><td>$row[3]</td></tr>";
    print"<tr><td>Date added:</td><td>$row[4]</td></tr>";

    print"</table></br>";   

}

将oci_fetch_row语句放入while循环。对于代码示例

print"<h2 id='title'>This Users Feedback</h2>";
print"<table border='2'>";

while ($row=oci_fetch_row($stmt3))
{

    print"<tr><td><p>Feedback ID:</td><td>$row[0]</td></tr>";
    print"<tr><td>Asset ID:</td><td>$row[1]</td></tr>";
    print"<tr><td>Feedback:</td><td>$row[3]</td></tr>";
    print"<tr><td>Date added:</td><td>$row[4]</td></tr>";


}
print"</table></br>"; 
Html索引: 使用超链接引用:

<a href="http://localhost/yourpath.php?opt=1>Show table</a>
连接到数据库并显示表:

<?php
echo $opt=$_GET['opt'];
$connection=OCILogon("user","password");
if($opt=='1') /*if u have a menu with other html*/
{
$ctab =OCIParse($connection,"SELECT * FROM table");
OCIExecute($ctab)

echo "<table>";
echo "<tr>";
echo "<th>ID</th>; 
....all your table header
echo "</tr>";

while(OCIFetch($ctab))
{ $id = OCIResult($ctab,"ID");
.........
print( "<tr>".
       "<td>$id</td>".
         ........
       "</tr>");
}

elseif($opt='2')  /*if you have a form , to get values and insert into table*/
{ echo $FirVal=$_POST["firval"];
$SecVal=$_POST["secval"];
echo $LastVal=$_POST["lastval"];

$ctab2=OCIParse($connect,"insert into table values($firval , '$secval', $lastval)");
OCIExecute($ctab2);
}
OCIFreeStatement($ctab2);
OCIFreeStatement($ctab);
OCILogOff($connection);
?>
html表单的代码:

<form method="POST" action="http://localhost/phppath.php?opt=2">
Firstval:<input type="text" name="FirVal" size=8><br>
...........
<input type="SUBMIT" value="Add Values">
<input type="Reset" value ="Reset">
</form>