Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(1);
- $servername = "localhost";
- $username = "####";
- $password = "####";
- $dbname = "ajsearch";
- $datatable = "atbible";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //chat user enter this "@Gen1:1-Gen1:3"
- $messageText = "@Gen1:1-Gen1:2";
- //this strips the users input into a string (for use later)
- //msgat is the "call to the bot" which I remove for searching capabilities and put it in a string.
- $msgat = substr($messageText,0,1);
- //this make the users input into a clean string
- $message = substr($messageText,1);
- //this takes the entire users (cleaned) input and splits it into two strings
- list($message1, $message2) = explode("-", "$messageText", 2);
- //a test and redundant perhaps, still working on it
- $message3 = substr($message1,1);
- $message4 = substr($message2,0);
- // search sql for users input (Gen1:1 through Gen1:2) - using the (cleaned) Strings (without the '@')
- $mysqli = "SELECT verse FROM ".datatable." WHERE book BETWEEN '%".message3." AND ".message4."'";
- $result = $conn->query($mysqli);
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc())
- //$answer= " " . $row["verse"];
- //combines the results of search into one variable ($answer)
- {$answer= " " . $row["verse"].$row["verse"];
- }
- }
- // just for debugging (echos these to a page)
- echo "$answer", " | ", "$message3", " | ", "$message4", " | ", "$msgat";
- echo " |End.";
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement