Displaying the contents of a mysql table in a web page using php

Here is a PHP script I made to display the contents of a workshop registered participants table.

<?php
// STATE YOUR VARIABLES
////////////////////////////////////////////////////////////////////
$user = "workshops";
$pass = "FV8sbyJuJ7bdT5Rj";
$db   = "workshops";
$sql  = "SELECT * FROM `wp_workshops_fm_data_15` LIMIT 0, 100";

// ESTABLISH THE CONNECTION
////////////////////////////////////////////////////////////////////
$cxn=mysqli_connect("localhost","$user","$pass","$db");   //Declare the mysqli connection parameters.
$cxn->set_charset("utf8");   // Define the default character set.
if (mysqli_connect_errno())  // Create a check for connection, if nothing then die.
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$result = mysqli_query($cxn,"$sql");

// GET NUMBER OF ATTENDEES
////////////////////////////////////////////////////////////////////
$rows = mysqli_num_rows($result);
printf("<h2>Current number of registered attendees: %d</h2>",$rows);

// CREATE THE TABLE
////////////////////////////////////////////////////////////////////
echo "<table>
        <tr>
                <th>First name</th>
                <th>Last name</th>
                <th>Job title</th>
                <th>Organisation</th>
                <th>Country</th>
                <th>Email address</th>
        </tr>\n";

while($row = mysqli_fetch_array($result))
  {
  echo "        <tr>\n";
  echo "                <td>" . "<b>" . $row['text-526647958e563'] . "</b>" . "</td>\n";
  echo "                <td>" . "<b>" . $row['text-5266498080c9d'] . "</b>" . "</td>\n";
  echo "                <td>" . $row['text-52664992cbe3f'] . "</td>\n";
  echo "                <td>" . $row['text-526649a164f02'] . "</td>\n";
  echo "                <td>" . $row['text-526649bb26849'] . "</td>\n";
  echo "                <td>" . "<a href=\"mailto:" .$row['text-526649d2a727a'] . "\">" .$row['text-526649d2a727a'] . "</a>" . "</td>\n";
  echo "        </tr>\n";
  }
echo "</table>";

// CLOSE THE CONNECTION
////////////////////////////////////////////////////////////////////
mysqli_close($cxn);

?>
  1. No comments yet.

  1. No trackbacks yet.