Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['phone']))
- {
- $db_server = "localhost";
- $db_username = "username";
- $db_password = "password";
- $db_database = "dbName";
- $conn = new PDO("mysql:host=$db_server;dbname=$db_database", $db_username, $db_password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $search_query=$_GET['phone'];
- $sql = 'SELECT receipt,phonenumber,transday FROM transactions where MATCH(phonenumber) AGAINST(:search_query)';
- $statement = $conn->prepare($sql);
- // echo $statement;
- $statement->bindParam(':search_query', $search_query, PDO::PARAM_STR);
- $statement->execute();
- if($statement->rowCount())
- {
- $row_all = $statement->fetchall(PDO::FETCH_ASSOC);
- header('Content-type: application/json');
- echo json_encode($row_all);
- }
- elseif(!$statement->rowCount())
- {
- $error = "No Data Found For This User \n";
- header('Content-type: application/json');
- echo json_encode($error);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment