update for Audit form Contact for Accredia M18b

This commit is contained in:
2024-09-18 16:01:31 +02:00
parent eb475f257e
commit 91ae77aff1
5 changed files with 332 additions and 200 deletions
@@ -0,0 +1,37 @@
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
//Including Database configuration file.
include "../db.php";
$iduserlog = $_SESSION["iduserlogin"];
//Getting value of "search" variable from "script.js".
if (isset($_POST['companynamevalue'])) {
//Search box value assigning to $Name variable.
$Name = $_POST['companynamevalue'];
//Search query.
$Query = "SELECT DISTINCT contacts.companyname FROM contacts LEFT JOIN `trf-details` ON `trf-details`.idtrfdetails=contacts.idtrf WHERE contacts.companyname LIKE '%$Name%' AND `trf-details`.iduser='$iduserlog' LIMIT 5";
//Query execution
$ExecQuery = MySQLi_query($conn, $Query);
//Creating unordered list to display result.
echo '
<ul>
';
//Fetching result from database.
while ($Result = MySQLi_fetch_array($ExecQuery)) {
?>
<!-- Creating unordered list items.
Calling javascript function named as "fill" found in "script.js" file.
By passing fetched result as parameter. -->
<li onclick='fill("<?php echo $Result['companyname']; ?>")'>
<a>
<!-- Assigning searched result in "Search box" in "search.php" file. -->
<?php echo $Result['companyname']; ?>
</li></a>
<!-- Below php code is just for closing parenthesis. Don't be confused. -->
<?php
}
}
?>
</ul>
@@ -0,0 +1,39 @@
//Getting value from "ajax.php".
function fill(Value) {
//Assigning value to "search" div in "search.php" file.
$('#companynamevalue').val(Value)
//Hiding "display" div in "search.php" file.
$('#display').hide()
}
$(document).ready(function () {
//On pressing a key on "Search box" in "search.php" file. This function will be called.
$('#companynamevalue').keyup(function () {
//Assigning search box value to javascript variable named as "name".
var name = $('#companynamevalue').val()
//Validating, if "name" is empty.
if (name == '') {
//Assigning empty value to "display" div in "search.php" file.
$('#display').html('')
}
//If name is not empty.
else {
//AJAX is called.
$.ajax({
//AJAX type is "Post".
type: 'POST',
//Data will be sent to "ajax.php".
url: 'searchengine/ajaxsearchcontact.php',
//Data, that will be sent to "ajax.php".
data: {
//Assigning value of "name" into "search" variable.
companynamevalue: name,
},
//If result found, this funtion will be called.
success: function (html) {
//Assigning result to "display" div in "search.php" file.
$('#display').html(html).show()
},
})
}
})
})