php - Using a MYSQL database to create div tags -


recently started project in theory create new div tags or table rows each row of information in mysql database.

i'm unsure of language tackle with. semi-familiar writing in php.

here theoretical code:

<?php include 'header.php'; ?> <div id="coursewrap"> <?php   $sql="select * details"; $result = mysqli_query($sql);  echo "<table border='1'> <tr> <th>employer</th> <th>learningprovider</th> <th>contractedprovider</th> </tr>";  while($row = mysqli_fetch_array($result))   {   echo "<tr>";   echo "<td>" . $row['employer'] . "</td>";   echo "<td>" . $row['learningprovider'] . "</td>";   echo "<td>" . $row['contractedprovider'] . "</td>";  echo "</tr>";   } echo "</table>";  mysqli_close($con); ?> </div> 

in header.php connect db so:

<?php //create connection $con=mysqli_connect("localhost", "jobboard","*****", "jobboard");  // check connection  if (mysqli_connect_errno($con))   {   echo "failed connect mysql: " . mysqli_connect_error();   } else {     echo "connected";   } ?> 

note: i'm pretty sure i'm getting wrong mysqli side of things.

question:

how go tackling this? best option , why?

thanks

mysqli_query() requires 2 parameters. example:

$con=mysqli_connect('','','',''); $results=mysqli_query($con,'select * table'); while($row=mysqli_fetch_array($results)){     echo'<tr><td>'.$row['employer'].'</td></tr>'; } mysqli_close($con); 

mysqli_query('connection here','your query here');


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -