Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $sql = $_POST['query'];
- if ($sql == ''){
- echo "Empty search!";
- }
- else{
- $result = mysqli_query($conn, $sql);
- if (($result)||(mysql_errno == 0))
- {
- echo "<table width='50%'><tr>";
- if (mysqli_num_rows($result)>0)
- {
- //loop thru the field names to print the correct headers
- //$i = 0;
- //while ($i < mysqli_num_fields($result))
- //{
- //echo "<th>". mysqli_fetch_fields($result) . "</th>";
- //$i++;
- //}
- //echo "</tr>";
- //display the data
- while ($rows = mysqli_fetch_assoc($result))
- {
- echo "<tr>";
- foreach ($rows as $data)
- {
- echo "<td align='center'>". $data . "</td>";
- }
- }
- }else{
- echo "<tr><td colspan='" . ($i+1) . "'>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax.</td></tr>";
- }
- echo "</table>";
- }
- else{
- echo "Error in running query :". mysqli_error();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement