<!DOCTYPE html>
<html>
<head>
<title>Assignment 6</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="search.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="screen6.js"></script>
</head>
<style>
.course_margin
{
position: relative;
left: 45px;
}
.search
{
margin-top: 10px;
}
</style>
<body>
<form name="search_form" id="search_form" action="#" method="post">
<div class="container">
<div class="row search">
<div class="col-xs-8 col-xs-offset-2">
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" name="audience_list" id="audience_list" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="current_search">All</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li onclick="displayCourse('My Library')"><a class="dropdown-item" href="#">My Library</a></li>
<li class="divider"></li>
<li onclick="displayCourse('All')"><a class="dropdown-item" href="#">All</a></li>
<li onclick="displayCourse('IT Certification')"><a class="dropdown-item" href="#">IT Certification</a></li>
</ul>
</div>
<input type="text" class="form-control" name="text_to_search" id="text_to_search" placeholder="Search titles..." onkeyup="showSuggestion(this.value);" required="required"/>
<input type="hidden" name="hidden_search" id="hidden_search" value="All" />
<span class="input-group-btn">
<button class="btn navbar-inverse btn-primary" onclick="check();" type="button" name="submit_btn" id="submit_btn">Go</button>
</span>
</div>
<ul id="search_result" class="list-group search_result">
</ul>
</div>
</div>
<div class="row course_margin">
<ul>
<li class="searched_book list-unstyled">
<a href="#">
<span class="resulting_book">
oca: oracle java certified associate
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
mos: microsoft access 2013
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
adobe photoshop cs6 java certified
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
ccna security 210-260 official cert guide
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
adobe certified expert on indesign
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
google search advertising advanced certification
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
New Merged Internal Apps Prepkit
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
cloud essentials: comptia authorized courseware
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
linux essentials dvanced security practitioner
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
comptia advanced security practitioner
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
cw81-testing Java SE 8 Programmer
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
oracle database 12c: sql fundamentals
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
oracle certified associate java se 8 programmer
<div id="course_img"></div>
</span>
</a>
<a href="#">
<span class="resulting_book">
ocp java se 8 programmer ii
<div id="course_img"></div>
</span>
</a>
</li>
</ul>
</div>
</div>
</form>
</body>
</html>
&#13;
我正在尝试使用php创建搜索栏。我做了所有的事情。但当我点击我的下拉按钮并选择它的认证和我的图书馆的价值。然后我得到了这个错误。我应该怎么做才能消除这个错误。
注意:未定义的索引:第51行的E:\ website \ php practice \ s \ search.php中的str 有谁能告诉我。?
这是我的代码:
<?php
$all = array('New Merged Internal Apps Prepkit','CW81-testing Java SE 8 Programmer');
$it_certification = array('CCNA Security 210-260 Official Cert Guide','CompTIA Advanced Security Practitioner','Adobe Certified Expert on InDesign','Google Search Advertising Advanced Certification','OCA: Oracle Java Certified Associate','Adobe Photoshop CS6 With Cloud Computing','Cloud Essentials: CompTIA Authorized Courseware','Linux Essentials administrator','Oracle Database 12c: SQL Fundamentals','Oracle Certified Associate Java SE 8 Programmer I','MOS: Microsoft Access 2013','OCP Java SE 8 Programmer II','Zend Study Guide with CSS advance');
if(isset($_POST["submit_btn"])||$_REQUEST['act']=='final_image')
{
final_image($all,$it_certification);
}
if($_REQUEST['act']== 'search_item')
{
search_item($all,$it_certification);
}
else if($_REQUEST['act'] == 'search_image')
{
search_image($all,$it_certification);
}
function search_item($all,$it_certification)
{
if((isset($_REQUEST['str']) && strlen($_REQUEST['str']) != 0))
{
$str = $_REQUEST['str'];
if($_REQUEST['search_area'] == 'My Library')
{
$search_array = $all;
}else if($_REQUEST['search_area'] == 'IT Certification')
{
$search_array = $it_certification;
}else
{
$search_array = array_merge($all,$it_certification);
}
$search_array = array_map('strtolower', $search_array);
$str = strtolower($str);
$result = preg_grep('~'.$str.'~', $search_array);
foreach($result as $key => $item)
{
echo "<li class='list-unstyled'><a href='#' onclick='display(\"$item\");' class='list-group-item'>$item</a></li>";
}
}
else
{
echo "";
}
}
function search_image($all,$it_certification)
{
if(isset($_REQUEST['search_area']))
{
$str = $_REQUEST['str'];
if($_REQUEST['search_area'] == 'My Library')
{
$search_array = $all;
}
else if($_REQUEST['search_area'] == 'IT Certification')
{
$search_array = $it_certification;
}
else
{
$search_array = array_merge($all,$it_certification);
}
$search_array = array_map('strtolower', $search_array);
$str = strtolower($str);
$result = preg_grep('~'.$str.'~', $search_array);
foreach($result as $key => $item)
{
echo "<a href='#'><span class='resulting_book'>$item<div id='course_img'></div></span></a>";
}
}
else
{
echo "no matches to search";
}
}
function final_image($all,$it_certification)
{
$search_array = array_merge($all,$it_certification);
$search_array = array_map('strtolower', $search_array);
$str1="";
$str = strtolower($_POST['text_to_search']);
$result = preg_grep('~'.$str.'~', $search_array);
foreach($result as $key => $item)
{
$str1="<a href='#'><span class='resulting_book'>$item<div id='course_img'></div></span></a>";
}
}
?>
&#13;