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

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

目前它抓取的一行被放入一个简单的HTML表中。 / p>

有关如何获取数据匹配并输出到表的所有行的任何帮助将不胜感激。</ p>

我的代码是:</ p>

  $ 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“&lt; h2 id ='title'&gt;此用户反馈&lt; / h2&gt; “;
”&lt; table border ='2'&gt;“;

print”&lt; tr&gt;&lt; td&gt;&lt; p&gt;反馈ID:&lt; / td&gt;&lt; td&gt; $ row [ 0]&lt; / td&gt;&lt; / tr&gt;“;
print”&lt; tr&gt;&lt; td&gt;资产ID:&lt; / td&gt;&lt; td&gt; $ row [1]&lt; / td&gt;&lt; / tr&gt;“;
print”&lt; tr&gt;&lt; td&gt;反馈:&lt; / td&gt;&lt; td&gt; $ row [3]&lt; / td&gt;&lt; / tr&gt;“;
print”&lt; ; tr&gt;&lt; td&gt;添加日期:&lt; / td&gt;&lt; ; td&gt; $ row [4]&lt; / td&gt;&lt; / tr&gt;“;

print”&lt; / table&gt;&lt; / br&gt;“;

}
</ code> </ pre>
</ div>

展开原文

原文

My issue is I have a website that is linking to multiple tables in Oracle. I currently have PHP code that checks user input assigned to a variable to find data in a table, then the oci_fetch_row statement that grabs the row where the data matches. This works fine but I cannot find how to output more than one row from a table if some values are the same?

Currently the one row it grabs is put into a simple HTML table.

Any help in to how to fetch all rows that the data matches and output to table would be appreciated.

My code is:

$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>";   

}

2个回答



将oci_fetch_row语句放入while循环中。 OCI Fetch Array 代码示例</ p>

  print“&lt; h2 id ='title'&gt;此用户反馈&lt; / h2&gt;”; 
print“&lt; table border ='2'&gt;”;

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

print“&lt; tr&gt;&lt; td&gt;&lt; p&gt;反馈ID:&lt; / td&gt;&lt; td&gt; $ row [0]&lt; / td&gt;&lt; / tr&gt;“;
print”&lt; tr&gt;&lt; td&gt;资产ID:&lt; / td&gt;&lt; td&gt; $ row [1]&lt; / td&gt;&lt; / tr&gt;“ ;
print“&lt; tr&gt;&lt; td&gt;反馈:&lt; / td&gt;&lt; td&gt; $ row [3]&lt; / td&gt;&lt; / tr&gt;”;
print“&lt; tr&gt;&lt; ; td&gt;添加日期:&lt; / td&gt;&lt; td&gt; $ row [4]&lt; / td&gt;&lt; / tr&gt;“;

}
print”&lt; / table&gt;&lt; / BR&gt;“中;

</ code> </ pre>
</ div>

展开原文

原文

Put the oci_fetch_row statement into a while loop. OCI Fetch Array for a code sample

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>"; 

dtrnish3637
dtrnish3637 非常感谢你非常感谢
8 年多之前 回复



Html索引:
使用超链接引用:</ p>

 &lt; a href =“  http://localhost/yourpath.php?opt = 1&gt;显示表&lt; / a&gt; 
</ code> </ pre>

Conect to database and show table:</ p>

 &lt;?php 
echo $ opt = $ _ GET ['opt'];
$ connection = OCILogon(“user”,“password”);
if($ opt =='1 ')/ *如果你有一个菜单与其他html * /
{
$ ctab = OCIParse($ connection,“SELECT * FROM table”);
OCIExecute($ ctab)

echo“&lt; table&gt; “;
echo”&lt; tr&gt;“;
echo”&lt; th&gt; ID&lt; / th&gt ;;

....所有你的表头
echo“&lt; / tr&gt;”;

while(OCIFetch($ ctab))
{$ id = OCIResult($ ctab,“ID”);
。 ........
print(“&lt; tr&gt;”。
“&lt; td&gt; $ id&lt; / td&gt;”。
........
“&lt; / tr&gt; ;“);
}

elseif($ opt ='2')/ 如果您有表单,获取值并插入表格 /
{echo $ FirVal = $ _ POST [”firval“] ;
$ SecVal = $ _ POST [“secval”];
echo $ LastVal = $ _ POST [“lastval”];

$ ctab2 = OCIParse($ connect,“插入表值($ firval,'$ secval',$ lastval)“);
OCIExecute($ ctab2);
}
OCICIFreeStatement($ ctab2);
OCICIFreeStatement($ ctab);
OCILogOff($ connection);
?&gt;
</ code > </ pre>

html格式代码:</ p>

 &lt; form method =“POST”action =“http:// localhost / phppath。  php?opt = 2“&gt; 
Firstval:&lt; input type =”text“name =”FirVal“size = 8&gt;&lt; br&gt;
...........
&lt;输入类型 =“SUBMIT”值=“添加值”&gt;
&lt; input type =“Reset”value =“重置”&gt;
&lt; / form&gt;
</ code> </ pre>
</ div>

展开原文

原文

Html index: Use hyperlink reference:

<a href="http://localhost/yourpath.php?opt=1>Show table</a>

Conect to database and show table:

<?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);
?>

Code for html form:

<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>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问