Add exams from exam156 to exam199
This commit is contained in:
38
exam175/index.php
Normal file
38
exam175/index.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function findmatch(){
|
||||
if(window.XMLHttpRequest){
|
||||
xmlhttp =new XMLHttpRequest();
|
||||
} else {
|
||||
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
|
||||
}
|
||||
|
||||
xmlhttp.onreadystatechange = function(){
|
||||
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
|
||||
document.getElementById('results').innerHTML = xmlhttp.responseText;
|
||||
}
|
||||
}
|
||||
|
||||
xmlhttp.open('GET','search.inc.php?search_text=' + document.search.search_text.value ,true);
|
||||
xmlhttp.send();
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form id="search" name="search">
|
||||
Type a name: <br>
|
||||
<input type="text" name="search_text" onkeyup="findmatch();">
|
||||
|
||||
</form>
|
||||
|
||||
<div id="results"></div>
|
||||
</body>
|
||||
</html>
|
||||
26
exam175/search.inc.php
Normal file
26
exam175/search.inc.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
$mysql_db = 'example_database';
|
||||
$mysql_host = 'localhost';
|
||||
$mysql_user = 'example_user';
|
||||
$mysql_pass = 'Kolosnjaj4321!';
|
||||
|
||||
if(isset($_GET['search_text'])){
|
||||
$search_text = $_GET['search_text'];
|
||||
}
|
||||
|
||||
if(!empty($search_text)){
|
||||
$con = mysqli_connect($mysql_host,$mysql_user,$mysql_pass);
|
||||
if(mysqli_select_db($con,$mysql_db)){
|
||||
|
||||
|
||||
$query = "SELECT `name` FROM `names` WHERE `name` LIKE '". mysqli_real_escape_string($con,$search_text) ."%'";
|
||||
$query_run = mysqli_query($con,$query);
|
||||
while($query_row = mysqli_fetch_assoc($query_run)){
|
||||
echo $name = $query_row['name'] . '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user