Payne's SQL Note #8

Back to Payne's SQL Notebook


Reference Database

Code Snip Links
//=================================================
// Display all records
$query = "SELECT * FROM ReferenceTB";
$result = mysql_query($query, $con);

$i=1;
while($row = mysql_fetch_array($result))
{
  echo "<table><tr><th>";
  echo $i . "</th><th></th></tr><tr><td>";
  echo "RefNum</td><td>" . $row["RefNum"] . "</td></tr><tr><td>";
  echo "PMID</td><td>" . $row["PMID"] . "</td></tr><tr><td>";
  echo "Author</td><td>" . $row["Author"] . "</td></tr><tr><td>";
  echo "Title</td><td>" . $row["Title"] . "</td></tr><tr><td>";
  echo "Journal</td><td>" . $row["Journal"] . "</td></tr><tr><td>";
  echo "Year</td><td>" . $row["Year"] . "</td></tr>";
  echo "</table><br />\n";
  $i++;
}
//=================================================
// Display records with author Chang
$query = "SELECT * FROM ReferenceTB WHERE Author LIKE '%Chang%'";
$result = mysql_query($query, $con);

$i=1;
while($row = mysql_fetch_array($result))
{
  echo "<table><tr><th>";
  echo $i . "</th><th></th></tr><tr><td>";
  echo "RefNum</td><td>" . $row["RefNum"] . "</td></tr><tr><td>";
  echo "PMID</td><td>" . $row["PMID"] . "</td></tr><tr><td>";
  echo "Author</td><td>" . $row["Author"] . "</td></tr><tr><td>";
  echo "Title</td><td>" . $row["Title"] . "</td></tr><tr><td>";
  echo "Journal</td><td>" . $row["Journal"] . "</td></tr><tr><td>";
  echo "Year</td><td>" . $row["Year"] . "</td></tr>";
  echo "</table><br />\n";
  $i++;
}
  • Display data with author Changg
  • 09.php
//=================================================
// Display records with author Chang PY
$query = "SELECT * FROM ReferenceTB WHERE Author LIKE '%Chang PY%'";
$result = mysql_query($query, $con);

$i=1;
while($row = mysql_fetch_array($result))
{
  echo "<table><tr><th>";
  echo $i . "</th><th></th></tr><tr><td>";
  echo "RefNum</td><td>" . $row["RefNum"] . "</td></tr><tr><td>";
  echo "PMID</td><td>" . $row["PMID"] . "</td></tr><tr><td>";
  echo "Author</td><td>" . $row["Author"] . "</td></tr><tr><td>";
  echo "Title</td><td>" . $row["Title"] . "</td></tr><tr><td>";
  echo "Journal</td><td>" . $row["Journal"] . "</td></tr><tr><td>";
  echo "Year</td><td>" . $row["Year"] . "</td></tr>";
  echo "</table><br />\n";
  $i++;
}
  • Display data with author Chang PYPY
  • 10.php