Archive for November, 2013

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);

?>

How to turn off YouTube related videos

At the end of a YouTube video, you might see a bunch of “related videos”.

When you embed a video on your website, the YouTube player may end up showing your user related videos that are distasteful or offensive.

YouTube_related

In order to prevent this, we can actually turn off the feature.

All you need to do is add the text “?rel=0” to the URL being viewed or embedded.

<iframe width="640" height="480" src="//www.youtube.com/embed/bDVz4ZCA4a0?rel=0" frameborder="0" allowfullscreen></iframe>