Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

if ($wa_no . $wa_text == '') { exit ; }

$exp = explode(' ', $wa_text) ; $text1 = $exp[0]; $text2 = $exp[1]; $text3 = $exp[2];

if ($text1 == 'INFO') {

$msg = "Halo ini bot perpustakaan SLIMS

Silahkan gunakan kata kunci berikut untuk melakukan pencarian.

Untuk mencari berdasarkan judul Ketik : search title judul yg mau dicari Contoh : search title sejarah

Untuk mencari berdasarkan penulis Ketik : search author nama penulis Contoh : search author andi

Untuk mencari berdasarkan ISBN Ketik : search isbn kode isbn Contoh : search isbn 0123456789

Untuk mencari berdasarkan ISSN Ketik : search isbn kode issn Contoh : search issn 0123456789

Terima kasih.";

sendMessage($wa_no, $msg);

}

if ($text2 == 'TITLE') {

$result = (mysqli_query($conn,"SELECT * FROM biblio a left join biblio_author b on a.biblio_id=b.biblio_id left join mst_author c on b.author_id=c.author_id WHERE title LIKE '%$text3%'")) or die (mysqli_error($result)); if(mysqli_num_rows($result) > 0){ while ($row=mysqli_fetch_array($result)){ $msg .= 'Title: '.$row['title'].' Author: '.$row['author_name'].' ISBN/ISSN: '.$row['isbn_issn'].' Year: '.$row['publish_year'].'

'; } } else { $msg .= 'Data tidak ditemukan'; }

sendMessage($wa_no, $msg);

}

if ($text2 == 'AUTHOR') {

$result = (mysqli_query($conn,"SELECT * FROM biblio a left join biblio_author b on a.biblio_id=b.biblio_id left join mst_author c on b.author_id=c.author_id WHERE author_name LIKE '%$text3%'")) or die (mysqli_error($result)); if(mysqli_num_rows($result) > 0){ while ($row=mysqli_fetch_array($result)){ $msg .= 'Title: '.$row['title'].' Author: '.$row['author_name'].' ISBN/ISSN: '.$row['isbn_issn'].' Year: '.$row['publish_year'].'

'; } } else { $msg .= 'Data tidak ditemukan'; }

sendMessage($wa_no, $msg);

}

if ($text2 == 'ISBN') {

$result = (mysqli_query($conn,"SELECT * FROM biblio a left join biblio_author b on a.biblio_id=b.biblio_id left join mst_author c on b.author_id=c.author_id WHERE isbn_issn LIKE '%$text3%'")) or die (mysqli_error($result)); if(mysqli_num_rows($result) > 0){ while ($row=mysqli_fetch_array($result)){ $msg .= 'Title: '.$row['title'].' Author: '.$row['author_name'].' ISBN/ISSN: '.$row['isbn_issn'].' Year: '.$row['publish_year'].'

'; } } else { $msg .= 'Data tidak ditemukan'; }

sendMessage($wa_no, $msg);

}

if ($text2 == 'ISSN') {

$result = (mysqli_query($conn,"SELECT * FROM biblio a left join biblio_author b on a.biblio_id=b.biblio_id left join mst_author c on b.author_id=c.author_id WHERE isbn_issn LIKE '%$text3%'")) or die (mysqli_error($result)); if(mysqli_num_rows($result) > 0){ while ($row=mysqli_fetch_array($result)){ $msg .= 'Title: '.$row['title'].' Author: '.$row['author_name'].' ISBN/ISSN: '.$row['isbn_issn'].' Year: '.$row['publish_year'].'

'; } } else { $msg .= 'Data tidak ditemukan'; }

sendMessage($wa_no, $msg);

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment