Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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_Html_Database_Hyperlink_Oracle10g - Fatal编程技术网

Php 从数据库中获取行并使它们链接到其他页面

Php 从数据库中获取行并使它们链接到其他页面,php,html,database,hyperlink,oracle10g,Php,Html,Database,Hyperlink,Oracle10g,我认为题目不太准确,但以下是我所面临问题的细节。 我有Oracle10g中的电影数据库 我为用户提供了一个选项,可以在数据库中按标题搜索电影。 我正在使用这段代码显示返回的行 <h1>Search Results</h1> <table border = "1px"> <thead> <tr> <th>ID</th> <th>RATING</th> <th&g

我认为题目不太准确,但以下是我所面临问题的细节。 我有Oracle10g中的电影数据库 我为用户提供了一个选项,可以在数据库中按标题搜索电影。 我正在使用这段代码显示返回的行

<h1>Search Results</h1>
<table border = "1px">
<thead>
<tr>
    <th>ID</th>
    <th>RATING</th>
    <th>Title</th>
    <th>Description</th>
    <th>Category</th>
    <td>Duration</td>
    <td>Actor</td>
</tr>
</thead>
<tbody>
<?php
$search = $_POST['search'];
$search = sanitize($search);
$search = '%'.$search.'%';
$conn = oci_connect("asim","asim","localhost/xe");
$stid = oci_parse($conn,"SELECT 
                film.film_id AS FID,
                film.title AS title,
                film.description AS description,
                category.name AS category,
                film.duration AS length,
                film.rating AS rating,
                CONCAT ( actor.first_name ,CONCAT(' ', actor.last_name)) AS actors
                FROM category 
                LEFT JOIN film_category ON category.category_id = film_category.category_id
                    LEFT JOIN film ON film_category.film_id = film.film_id
                     JOIN film_actor ON film.film_id = film_actor.film_id
                     JOIN actor ON film_actor.actor_id = actor.actor_id
                WHERE title LIKE '".$search."'");
    oci_execute($stid);
    while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
        print "<tr>\n";
    foreach ($row as $item) {
        print "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
    }
           print "</tr>\n";
    }
?>
</tbody>
</table>
搜索结果
身份证件
评级
标题
描述
类别
期间
演员

如果您查看找到的
oci\u fetch\u array
文档,您将看到,由于您使用的是
oci\u ASSOC
参数,因此您可以使用其命名键访问结果

在您的
循环中,您应该能够使用您在Oracle SELECT查询中指定的列名
FID
访问胶片id

$row['FID']
然后,您可以使用
”生成指向该链接的链接;
与此类似的是将所有这些联系在一起,我有一个示例,您可以在下面尝试,它将向您展示如何访问上面提到的数据,您应该能够从那里继续

while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    print $row['PID'] . '<br />';
}
while($row=oci\u fetch\u数组($stid,oci\u ASSOC+oci\u RETURN\u NULLS)){
打印$row['PID']。
; }
如何在此语句中将数组元素包装在锚定标记中?而($row=oci_fetch_array($stid,oci_ASSOC+oci_RETURN_NULLS)){print$row['PID'].
;}第二,当你制作锚链接时,我如何制作一个像“href=”index.php$row['FILM_ID']”这样的链接,你可以像以前一样为你的
print
语句连接php和html,使用连接
运算符。所以<代码>打印“”更新了我的答案以包含锚链接生成示例。
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    print $row['PID'] . '<br />';
}