I am trying to make a tutorial database script... I haven't really topped it up yet, just got the basic frame work, anyway.. I can't use my webserver as Cpanel is not working to create the databases and such.
Can someone check this code on there server? If there are any problems PLEASE get back to me!
Code:
<?
// Connect to DB
mysql_connect("localhost", "dbuser", "dbpass");
mysql_select_db("dbname") or die("Unable to select DB");
$result=mysql_query("SELECT * FROM tutorials ORDER BY cat");
while ($row=mysql_fetch_array($result)) {
// Pull all information needed from the database
$id = $row['id']; // The ID for the tutorial / category
$cat = $row['cat']; // The category names
$tname = $row['tname']; // The tutorial name inside the category
$tdesc = $row['tdesc']; // A small description of the tutorial
$tutorial = $row['tutorial']; // The full tutorial
}
if ($_GET['p']=="$cat") { // If the action is categorys, show the tutorials in that category
echo("You have selected <a href=\"./?p=tutorials&cat=".$cat."\">$cat</a> tutorials");
echo("<br><br>");
echo("<a href=\"./?p=tutorials&cat=".$cat."&id=".$id."\">$tname</a> - $tdesc");
} else if ($_GET['p']=="$tutorial") { // If the action is a tutoril, show the tutorial
echo("<a href=\"./?p=tutorials&cat=".$cat."\">$cat</a> - $tutorial");
echo("<br><br>");
echo("$tutorial");
} else {($num_rows > 0) { // If the rows in the database are more than 0, show a list
echo("<a href=\"./?p=tutorials&cat=".$cat."\">$cat</a>");
echo("<br><br>");
echo("<a href=\"./?p=tutorials&cat=".$cat."&id=".$id."\">$tname</a> - $tdesc");
echo("<br><br>");
}}
mysql_close(); // Close the MySQL connection to the database
?>
|