Note that there are some explanatory texts on larger screens.

plurals
  1. POdisplay data from database into html table
    text
    copied!<p>I'm trying to display data from database into a table in html. here is my code:</p> <p>php code: <pre><code>if($_SERVER['REQUEST_METHOD'] =='POST') { $type_user=$_POST['type_user']; $sql="SELECT staff_id, name, email, role FROM user WHERE role='$type_user'"; $run= $db-&gt;query($sql) or die($db -&gt; error); $num=mysqli_num_rows($run); $row=mysqli_fetch_array($run, MYSQLI_ASSOC); //$yana = $row['staff_id']; //echo "dd".$yana; echo "&lt;table &gt; &lt;tr&gt; &lt;td &gt;Staff ID &lt;/td&gt; &lt;td &gt;Name&lt;/td&gt; &lt;td &gt;Email&lt;/td&gt; &lt;td &gt;Role&lt;/td&gt; &lt;/tr&gt;"; while($row = mysqli_fetch_array($run, MYSQLI_ASSOC)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;".$row['staff_id']."&lt;/td&gt;"; echo "&lt;td&gt;".$row['name']."&lt;/td&gt;"; echo "&lt;td&gt;".$row['email']."&lt;/td&gt;"; echo "&lt;td&gt;".$row['role']."&lt;/td&gt;"; echo "&lt;/tr&gt;"; echo "&lt;/table&gt;";} } ?&gt; </code></pre> <p>html code:</p> <pre><code>&lt;form id="list_of_user" method="post" action="user_list.php" accept-charset='UTF-8'&gt; &lt;h2&gt; Table Example&lt;/h2&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;table width="729" border="0" &gt; &lt;tr valign ="center"&gt; &lt;td width="85" valign ="center"&gt;User: &lt;/td&gt; &lt;td width="196" valign ="center"&gt;&lt;select name="type_user"&gt; &lt;option value="TELLER" selected="selected"&gt;TELLER&lt;/option&gt; &lt;option value="MANAGER"&gt;MANAGER&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;td width="97" valign ="center"&gt;&lt;input name="Go" type="submit" id="Go" value="Go" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I have php and html in one page. </p> <p>originally, I have a html table ready to display the data, but it won't show up. so I changed it into php. but the page goes here and there. . i'm using template for the page.</p> <p>Can you please show me how to ..say. pass the data from php to html?? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload