Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $servername = "mysql.idhostinger.com";
- $username = "u660303303_neko";
- $password = "password";
- $dbname = "u660303303_mhs";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt = $conn->prepare("SELECT nama, nim, prodi, email FROM dbarchive WHERE nama LIKE :nama");
- $stmt->bindValue(':nama', $searchkey);
- $stmt->execute();
- // set the resulting array to associative
- $res = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- foreach($stmt->fetchAll() as $k=>$v) {
- $sentence = $sentence . ", " . $v;
- }
- }
- catch(PDOException $e) {
- $sentence = "Error: " . $e->getMessage();
- }
- unset($conn);
- return $sentence;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement