Android Question PHP and WebView (XAMPP)

Hedgar

Member
Hi. I'm trying to display a PHP file from (XAMPP Local server) in a webview but i get nothing to show. Is there something i'm missing? I Should mention that the PHP page utilizes CSS and Javascript.

Also, the PHP file is just a table that displays records. Is there a better way to do this?
thanks
The Webview Code:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private webReport As WebView
    Public IPAddress As String = "192.168.2.111"
    Dim currentURL As String
    'Private webview1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Resulttable")
    webReport.LoadUrl("http://${IPAddress}/results/index.php")
    webReport.JavaScriptEnabled = True
    
    
End Sub

Sub Activity_Resume
    ToastMessageShow(currentURL, False)
    webReport.LoadUrl(currentURL)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub webReport_PageFinished (Url As String)
    currentURL = webReport.Url
    ToastMessageShow("Page Finished Loading " & webReport.Url, False)
End Sub
The PHP Code:
<?php
$con=mysqli_connect("localhost","root","","students_results");
$result=mysqli_query($con,"SELECT * FROM  results  WHERE Admission_No='BSCS/2017/42251' ");
?>
<!DOCTYPE html>
<html>
<head>
    <title>Form</title>
</head>
 <link href="index.css" rel="stylesheet">
<body>
<section> 
  <h1>Semester 8</h1>
  <div class="tbl-header">
    <table cellpadding="0" cellspacing="0" border="0">
      <thead>
        <tr>
          <th>ID</th>
          <th>Unit Code</th>
          <th>Unit Name</th>
          <th>Grade</th>
          <th>SEMESTER</th>
        </tr>
        </thead>
          </table>
  </div>
        
  <div class="tbl-content">
    <table cellpadding="0" cellspacing="0" border="0">
      <tbody>
        <?php
        while($rows=mysqli_fetch_assoc($result))
        {
          ?>
        <tr>
          <td><?php echo $rows['ID']; ?></td>
          <td><?php echo $rows['Code']; ?></td>
          <td><?php echo $rows['Name']; ?></td>
          <td><?php echo $rows['Grade']; ?></td>
           <td><?php echo $rows['Semester']; ?></td>
          
        </tr>
        </tbody>
          <?php     
        }
    ?>   
      
    </table>
  </div>
</section>
<script src="index.js"></script>
</body>
</html>
 

Attachments

  • Screenshot (3).png
    Screenshot (3).png
    53.2 KB · Views: 402

Biswajit

Active Member
Licensed User
Longtime User
webReport.LoadUrl("http://${IPAddress}/results/index.php")
Change this line to
B4X:
currentURL="http://${IPAddress}/results/index.php"
 
Upvote 0

Hedgar

Member
Thank you. This worked but brought ERR_Name Resolve. So I Replaced
B4X:
currentURL="http://${IPAddress}/results/index.php"
with
B4X:
currentURL="http://192.168.2.111/results/index.php"
 
Upvote 0
Top