Jump to content

Bojan86

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Bojan86's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php //Getting the file db.php which includes our database settings. define( 'DB_PATH' , "" ); require DB_PATH."db.php"; // Setting up some variables $request_id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; // Page: admin.php?act=addnew if (isset($_GET['act']) && $_GET['act'] == 'addnew') { echo " <form name='form' method='post' action='admin.php?act=addnew'> <table width='80%' border='0' cellspacing='3' cellpadding='0'> <tr> <td width='20%'>Name:</td> <td width='79%'> <input name='name' type='text' id='name' size='40'></td> </tr> <tr> <td>Avatar:</td> <td> <input name='avatar' type='text' id='avatar' value='http//' size='40'></td> </tr> <tr> <td>Category:</td> <td> <input name='category' type='text' id='category' value='Automatically makes new category' size='40'> </td> </tr> <tr> <td>Description:</td> <td> <input name='description' type='text' id='description' size='40'></td> </tr> <tr> <td>Author:</td> <td> <input name='author' type='text' id='author' size='40'></td> </tr> <tr> <td>Email:</td> <td> <input name='email' type='text' id='email' size='40'></td> </tr> <tr> <td>Content</td> <td> <textarea name='content' cols='65' rows='10'></textarea></td> </tr> <tr> <td><input name='submit' type='submit' id='submit' value='Submit'> <input name='reset' type='reset' id='reset' value='Reset'></td> <td>If you mess up, a edit link will be available on submit. </td> </tr> </table> </form>"; if (isset($_POST['submit'])) { $name = $_POST['name']; $avatar = $_POST['avatar']; $category = $_POST['category']; $description = $_POST['description']; $author = $_POST['author']; $email = $_POST['email']; $content = $_POST['content']; $date = date('m-d-Y'); if (!$name || !$avatar || !$category || !$description || !$author || !$email || !$content) { die ('Sorry, a field was left blank. Check all fields again!'); } else { mysql_query("INSERT INTO $mysql_table(id, title, avatar, date, category, description, author, email, content, views) VALUES('', '$name', '$avatar', '$date', '$category', '$description', '$author', '$email', '$content', '' ) " ) or die('Sorry, it failed'); echo "Success! You have added the tutorial <strong>$name</strong> to the category <strong>$category.</strong><br>What would you like to do?<br> <a href='?act=addnew'>Add a new tutorial</a> ---- <a href='?act=view'>Edit / Delete a previous tutorial</a>"; } } } // Page: admin.php?act=edit&id=## if (isset($_GET['act']) && $_GET['act'] == 'edit' && $_GET['id'] == $request_id) { $result = mysql_query("SELECT * FROM $mysql_table WHERE id='$request_id'"); while($row = mysql_fetch_array($result)){ echo " <form name='form' method='post''> <table width='80%' border='0' cellspacing='3' cellpadding='0'> <tr> <td width='20%'>Name:</td> <td width='79%'> <input name='name' type='text' id='name' ] value='".$row['title']."' size='40'></td> </tr> <tr> <td>Avatar:</td> <td><input name='avatar' type='text' id='avatar' value='".$row['avatar']."' size='40'></td> </tr> <tr> <td>Category:</td> <td> <input name='category' type='text' id='category' value='".$row['category']."' size='40'> </td> </tr> <tr> <td>Description:</td> <td> <input name='description' type='text' id='description' value='".$row['description']."' size='40'></td> </tr> <tr> <td>Author:</td> <td><input name='author' type='text' id='author' value='".$row['author']."' size='40'></td> </tr> <tr> <td>Email:</td> <td><input name='email' type='text' id='email' value='".$row['email']."' size='40'></td> </tr> <tr> <td>Content</td> <td><textarea name='content' cols='65' rows='10'> ".$row['content']."</textarea></td> </tr> <tr> <td><input name='submit' type='submit' id='submit' value='Edit'></td> <td></td> </tr> </table> </form> "; if (isset($_POST['submit'])) { $name = $_POST['name']; $avatar = $_POST['avatar']; $category = $_POST['category']; $description = $_POST['description']; $author = $_POST['author']; $email = $_POST['email']; $content = $_POST['content']; mysql_query("UPDATE $mysql_table SET title='$name', avatar='$avatar', category='$category', description='$description', author='$author', email='$email', content='$content' WHERE id='$request_id'") or die('Sorry, it failed'); echo "Success! Your tutorial has been edited.<br> What would you like to do?<br><a href='?act=addnew'> Add a new tutorial</a> ---- <a href='?act=view'> Edit / Delete a previous tutorial</a>"; } } } // Page: admin.php?act=delete&id=## if (isset($_GET['act']) && $_GET['act'] == 'delete' && $_GET['id'] == $request_id) { $result = mysql_query("SELECT * FROM $mysql_table WHERE id='$request_id'"); while($row = mysql_fetch_array($result)){ echo " <form action='?act=delete&id=".$row['id']."' method='post' name='form1'> Are you sure you want to delete the tutorial: <strong>".$row['title']."<strong>? <br> <input name='yes' type='checkbox' id='yes' value='checkbox'> Yes<br> <input name='no' type='checkbox' id='no' value='checkbox'> No <br> <input name='submit' type='submit' id='submit' value='Submit'> </form>"; } if (isset($_POST['submit'])){ if ($_POST['yes'] && $_POST['no']){ die('Error! : Are you trying to confuse me?'); } if ($_POST['yes']){ $result = mysql_query("SELECT * FROM $mysql_table WHERE id='$request_id'"); while($row = mysql_fetch_array($result)){ mysql_query("DELETE FROM $mysql_table WHERE id='$request_id'"); echo " Thanks, the tutorial <strong>".$row['title'].".</strong> has been deleted. <a href='?'>Click here</a> to continue. "; } } if ($_POST['no']){ die('<a href="?">Click here</a> to continue.'); } if (!$_POST['yes'] && !$_POST['no']){ die('Oops, you forgot to respond to my question.'); } } } // Page: admin.php?act=view if (isset($_GET['act']) && $_GET['act'] == 'view') { echo " <table width='700' border='0' cellspacing='0' cellpadding='0'> <tr> <td><strong>ID</strong></td> <td><strong>Name</strong></td> <td><strong>Author</strong></td> <td><strong>Category</strong></td> <td><strong>Edit / Delete</strong></td> </tr> "; $result = mysql_query("SELECT * FROM $mysql_table ORDER BY ID ASC"); while($row = mysql_fetch_array($result)){ echo " <tr> <td>".$row['id']."</td> <td>".$row['title']."</td> <td><a href='mailto:".$row['email']."'>".$row['author']."</a></td> <td>".$row['category']."</td> <td><a href='admin.php?act=edit&id=".$row['id']."'>Edit</a> / <a href='admin.php?act=delete&id=".$row['id']."'>Delete</a></td> </tr> "; } echo "</table>"; } // Page: admin.php if (!isset($_GET['act'])) { echo " What would you like to do?<br><a href='?act=addnew'> Add a new tutorial</a> ---- <a href='?act=view'>Edit / Delete a previous tutorial </a> "; } ?> This is first file... <?php $mysql_host = "localhost"; $mysql_user = "root"; $mysql_pass = ""; $mysql_data = "crap_cms"; $mysql_table = "tutorials"; // Feel free to change this to your liking... /* --Working some magic-- */ mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die("Error connecting to Database! Please Try again. " . mysql_error()); mysql_select_db($mysql_data) or die("Cannot select database! Please Try again. " . mysql_error()); // ---------------------- // ?> This is connection between admin.php and database <?php //Getting the file db.php which includes our database settings. define( 'DB_PATH' , "./" ); require DB_PATH."db.php"; //Setting up a variable to request the category which is in the URL $request_cat = isset($_REQUEST['category']) ? $_REQUEST['category'] : ''; //Displaying an actual tutorial if (isset($_GET['id'])) { // Updating the views, and grabbing a tutorial based on what id it has. $update = mysql_query("UPDATE $mysql_table SET views = views + 1 WHERE id='{$_GET['id']}'"); $result = mysql_query("SELECT * FROM $mysql_table WHERE id='{$_GET['id']}'"); while($row = mysql_fetch_array($result)){ // Template for the tutorial echo " <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='400'> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td><table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='275'><div align='left'><strong> <a href='tutorials.php?category=".$row['category']."&id=".$row['id']." '>".$row['title']."</a> </strong></div></td> <td width='125'><div align='right'> [ Views: ".$row['views']." ]</div></td> </tr> </table></td> </tr> <tr> <td><div align='left'>Description: ".$row['description']."</div></td> </tr> <tr> <td><div align='left'>".$row['content']."</div></td> </tr> <tr> <td><div align='left'> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='150'><div align='left'>Added: ".$row['date']."</div> </td> <td><div align='right'>Author: <a href='mailto:".$row['email']."' >".$row['author']."</a> </div></td> </tr> </table> </div></td> </tr> <tr> <td><div align='left'>Category: <a href='tutorials.php?category=".$row['category']." >".$row['category']."</a> </div></td> </tr> </table></td> </tr> </table> "; // End of template of tutorial } // End of grabbing data exit(); // Stopping anything below from interfearing with this sectiom } // End of Displaying an actual tutorial //Displaying tutorials in a cateogry. if (isset($_GET['category']) && $_GET['category'] == $request_cat) { //Grabbing information from the database. $result = mysql_query("SELECT * from $mysql_table where category = '{$_GET['category']}' ORDER BY ID DESC"); while($row = mysql_fetch_array($result)) { //Template for the tutorials in a category. echo " <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='100' align='center' valign='middle'><div align='center'> <a href='tutorials.php?category=".$row['category']."&id=".$row['id']."'> <img src='".$row['avatar']."' alt='".$row['title']."' title='".$row['title']."' width='90' height='60' border='0'></a> </div></td> <td width='300'> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td> <div align='center'><strong>".$row['title']."</strong></div></td> </tr> <tr> <td> <div align='left'>Description: ".$row['description']."</div></td> </tr> <tr> <td> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td><div align='left'>Added: ".$row['date']."</div></td> <td><div align='left'>Category: <a href='tutorials.php?category=".$row['category']." >".$row['category']."</a></div></td> </tr> </table></td> </tr> <tr> <td><table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='175'><div align='left'>Author: <a href='mailto:".$row['email']."'>".$row['author']."</a></div></td> <td width='100'><div align='left'>Views: ".$row['views']."</div></td> </tr> </table></td> </tr> </table></td> </tr> </table><br> "; // End of Template for the tutorials in a category. } // End of grabbing information from database. } // End of Displaying tutorials in a cateogry. // Main Tutorial page. This is where all your categories will be listed. if (!isset($_GET['category'])) { //This makes a list of all the cateogries that are in the database! No need to make the links yourself! $result = mysql_query("SELECT DISTINCT category from $mysql_table "); while($row = mysql_fetch_array($result)) { // Showing all the categories echo " <a href='tutorials.php?category=".$row['category']."' >".$row['category']."</a><br> "; // End of showing all the categories } // End of grabbing unique categories in database }// End of main tutorial page ?> And third file, tutorial.php
  2. I need hel with this cms... I'm noob when it comes to PHP, so I really need help... Anyway, I would like to delete some parts of code in every file... I would like to delete AVATAR and DESCRIPTION fields... I'll attach files, so if someone could do that for me, that would be great! P.S. Instead of AVATAR I would like to put some link, like Click here to view tutorial... [attachment deleted by admin]
  3. Ooooo, some detective job... OK, I'll look into it.
  4. You're kidding me? That's all?! Um, thanks... But, can I (or U, it's better to be U) change that avatar into link that says somethin like "view tutorial here"? I don't like avatars very much...
  5. I'm sorry if I bored you with this s*it... Believe me, I would be more than happy if I don't have to do this... Anyway, now it shows category, I will delete views from code and mysql, so it won't be a problem anymore, but it still doesn't show content, and it's most important... So please, help me... I'm so close to shift+del everything...
  6. It should show all... Category, views, content, name of tutorial and so on... Everything but ID...
  7. In the attachment... [attachment deleted by admin]
  8. I'm going crazy over this bulls*it! :facewall: Now, tutorials.php doesn't works... It shows some of data, but not all of it (category, views, content...) Please, help me! Here's code! <?php //Getting the file db.php which includes our database settings. define( 'DB_PATH' , "./" ); require DB_PATH."db.php"; //Setting up a variable to request the category which is in the URL $request_cat = isset($_REQUEST['category']) ? $_REQUEST['category'] : ''; //Displaying an actual tutorial if (isset($_GET['id'])) { // Updating the views, and grabbing a tutorial based on what id it has. $update = mysql_query("UPDATE $mysql_table SET views = views + 1 WHERE id='{$_GET['id']}'"); $result = mysql_query("SELECT * FROM $mysql_table WHERE id='{$_GET['id']}'"); while($row = mysql_fetch_array($result)){ // Template for the tutorial echo " <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='400'> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td><table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='275'><div align='left'><strong> <a href='tutorials.php?category=".$row['category']."&id=".$row['id']." '>".$row['title']."</a> </strong></div></td> <td width='125'><div align='right'> [ Views: ".$row['views']." ]</div></td> </tr> </table></td> </tr> <tr> <td><div align='left'>Description: ".$row['description']."</div></td> </tr> <tr> <td><div align='left'>".$row['content']."</div></td> </tr> <tr> <td><div align='left'> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='150'><div align='left'>Added: ".$row['date']."</div> </td> <td><div align='right'>Author: <a href='mailto:".$row['email']."' >".$row['author']."</a> </div></td> </tr> </table> </div></td> </tr> <tr> <td><div align='left'>Category: <a href='tutorials.php?category=".$row['category']." >".$row['category']."</a> </div></td> </tr> </table></td> </tr> </table> "; // End of template of tutorial } // End of grabbing data exit(); // Stopping anything below from interfearing with this sectiom } // End of Displaying an actual tutorial //Displaying tutorials in a cateogry. if (isset($_GET['category']) && $_GET['category'] == $request_cat) { //Grabbing information from the database. $result = mysql_query("SELECT * from $mysql_table where category = '{$_GET['category']}' ORDER BY ID DESC"); while($row = mysql_fetch_array($result)) { //Template for the tutorials in a category. echo " <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='100' align='center' valign='middle'><div align='center'> <a href='tutorials.php?category=".$row['category']."&id=".$row['id']."'> <img src='".$row['avatar']."' alt='".$row['title']."' title='".$row['title']."' width='90' height='60' border='0'></a> </div></td> <td width='300'> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td> <div align='center'><strong>".$row['title']."</strong></div></td> </tr> <tr> <td> <div align='left'>Description: ".$row['description']."</div></td> </tr> <tr> <td> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td><div align='left'>Added: ".$row['date']."</div></td> <td><div align='left'>Category: <a href='tutorials.php?category=".$row['category']." >".$row['category']."</a></div></td> </tr> </table></td> </tr> <tr> <td><table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='175'><div align='left'>Author: <a href='mailto:".$row['email']."'>".$row['author']."</a></div></td> <td width='100'><div align='left'>Views: ".$row['views']."</div></td> </tr> </table></td> </tr> </table></td> </tr> </table><br> "; // End of Template for the tutorials in a category. } // End of grabbing information from database. } // End of Displaying tutorials in a cateogry. // Main Tutorial page. This is where all your categories will be listed. if (!isset($_GET['category'])) { //This makes a list of all the cateogries that are in the database! No need to make the links yourself! $result = mysql_query("SELECT DISTINCT category from $mysql_table "); while($row = mysql_fetch_array($result)) { // Showing all the categories echo " <a href='tutorials.php?category=".$row['category']."' >".$row['category']."</a><br> "; // End of showing all the categories } // End of grabbing unique categories in database }// End of main tutorial page ?>
  9. Thanks man/woman... God bless you!
  10. Notice: Undefined index: id in C:\wamp\www\cms\admin.php on line 9 Notice: Use of undefined constant addnew - assumed 'addnew' in C:\wamp\www\cms\admin.php on line 12 Notice: Undefined index: submit in C:\wamp\www\cms\admin.php on line 61 Notice: Use of undefined constant edit - assumed 'edit' in C:\wamp\www\cms\admin.php on line 93 Notice: Use of undefined constant delete - assumed 'delete' in C:\wamp\www\cms\admin.php on line 169 Notice: Use of undefined constant view - assumed 'view' in C:\wamp\www\cms\admin.php on line 220 Notice: Undefined variable: act in C:\wamp\www\cms\admin.php on line 248
  11. Um... This is not working... I can't save any of my data in database... Why? :'(
  12. That's OK... I need this as project for school so I don't bother much with learning... I work with Flash, so PHP is basics only...
  13. This is not working... Can't connect link with form... Help please! <?php //Getting the file db.php which includes our database settings. define( 'DB_PATH' , "" ); require DB_PATH."db.php"; // Setting up some variables $request_id = $_REQUEST['id']; // Page: admin.php?act=addnew if ($act == addnew) { echo " <form name='form' method='post' action='admin.php?act=addnew'> <table width='80%' border='0' cellspacing='3' cellpadding='0'> <tr> <td width='20%'>Name:</td> <td width='79%'> <input name='name' type='text' id='name' size='40'></td> </tr> <tr> <td>Avatar:</td> <td> <input name='avatar' type='text' id='avatar' value='http//' size='40'></td> </tr> <tr> <td>Category:</td> <td> <input name='category' type='text' id='category' value='Automatically makes new category' size='40'> </td> </tr> <tr> <td>Description:</td> <td> <input name='description' type='text' id='description' size='40'></td> </tr> <tr> <td>Author:</td> <td> <input name='author' type='text' id='author' size='40'></td> </tr> <tr> <td>Email:</td> <td> <input name='email' type='text' id='email' size='40'></td> </tr> <tr> <td>Content</td> <td> <textarea name='content' cols='65' rows='10'></textarea></td> </tr> <tr> <td><input name='submit' type='submit' id='submit' value='Submit'> <input name='reset' type='reset' id='reset' value='Reset'></td> <td>If you mess up, a edit link will be available on submit. </td> </tr> </table> </form>"; if ($_POST['submit']) { $name = $_POST['name']; $avatar = $_POST['avatar']; $category = $_POST['category']; $description = $_POST['description']; $author = $_POST['author']; $email = $_POST['email']; $content = $_POST['content']; $date = date('m-d-Y'); if (!$name || !$avatar || !$category || !$description || !$author || !$email || !$content) { die ('Sorry, a field was left blank. Check all fields again!'); } else { mysql_query("INSERT INTO & #036;mysql_table(id, title, avatar, date, category, description, author, email, content, views) VALUES('', '$name', '$avatar', '$date', '$category', '$description', '$author', '$email', '$content', '' ) " ) or die('Sorry, it failed'); echo "Success! You have added the tutorial <strong>$name</strong> to the category <strong>$category.</strong><br>What would you like to do?<br> <a href='?act=addnew'>Add a new tutorial</a> ---- <a href='?act=view'>Edit / Delete a previous tutorial</a>"; } } } // Page: admin.php?act=edit&id=## if ($act == edit && $id == $request_id) { $result = mysql_query("SELECT * FROM $mysql_table WHERE id='$request_id'"); while($row = mysql_fetch_array($result)){ echo " <form name='form' method='post''> <table width='80%' border='0' cellspacing='3' cellpadding='0'> <tr> <td width='20%'>Name:</td> <td width='79%'> <input name='name' type='text' id='name' ] value='".$row['title']."' size='40'></td> </tr> <tr> <td>Avatar:</td> <td><input name='avatar' type='text' id='avatar' value='".$row['avatar']."' size='40'></td> </tr> <tr> <td>Category:</td> <td> <input name='category' type='text' id='category' value='".$row['category']."' size='40'> </td> </tr> <tr> <td>Description:</td> <td> <input name='description' type='text' id='description' value='".$row['description']."' size='40'></td> </tr> <tr> <td>Author:</td> <td><input name='author' type='text' id='author' value='".$row['author']."' size='40'></td> </tr> <tr> <td>Email:</td> <td><input name='email' type='text' id='email' value='".$row['email']."' size='40'></td> </tr> <tr> <td>Content</td> <td><textarea name='content' cols='65' rows='10'> ".$row['content']."</textarea></td> </tr> <tr> <td><input name='submit' type='submit' id='submit' value='Edit'></td> <td></td> </tr> </table> </form> "; if ($_POST['submit']) { $name = $_POST['name']; $avatar = $_POST['avatar']; $category = $_POST['category']; $description = $_POST['description']; $author = $_POST['author']; $email = $_POST['email']; $content = $_POST['content']; mysql_query("UPDATE $mysql_table SET title='$name', avatar='$avatar', category='$category', description='$description', author='$author', email='$email', content='$content' WHERE id='$request_id'") or die('Sorry, it failed'); echo "Success! Your tutorial has been edited.<br> What would you like to do?<br><a href='?act=addnew'> Add a new tutorial</a> ---- <a href='?act=view'> Edit / Delete a previous tutorial</a>"; } } } // Page: admin.php?act=delete&id=## if ($act == delete && $id == $request_id) { $result = mysql_query("SELECT * FROM $mysql_table WHERE id='$request_id'"); while($row = mysql_fetch_array($result)){ echo " <form action='?act=delete&id=".$row['id']."' method='post' name='form1'> Are you sure you want to delete the tutorial: <strong>".$row['title']."<strong>? <br> <input name='yes' type='checkbox' id='yes' value='checkbox'> Yes<br> <input name='no' type='checkbox' id='no' value='checkbox'> No <br> <input name='submit' type='submit' id='submit' value='Submit'> </form>"; } if ($_POST['submit']){ if ($_POST['yes'] && $_POST['no']){ die('Error! : Are you trying to confuse me?'); } if ($_POST['yes']){ $result = mysql_query("SELECT * FROM $mysql_table WHERE id='$request_id'"); while($row = mysql_fetch_array($result)){ mysql_query("DELETE FROM $mysql_table WHERE id='$request_id'"); echo " Thanks, the tutorial <strong>".$row['title'].".</strong> has been deleted. <a href='?'>Click here</a> to continue. "; } } if ($_POST['no']){ die('<a href="?">Click here</a> to continue.'); } if (!$_POST['yes'] && !$_POST['no']){ die('Oops, you forgot to respond to my question.'); } } } // Page: admin.php?act=view if ($act == view) { echo " <table width='700' border='0' cellspacing='0' cellpadding='0'> <tr> <td><strong>ID</strong></td> <td><strong>Name</strong></td> <td><strong>Author</strong></td> <td><strong>Category</strong></td> <td><strong>Edit / Delete</strong></td> </tr> "; $result = mysql_query("SELECT * FROM $mysql_table ORDER BY ID ASC"); while($row = mysql_fetch_array($result)){ echo " <tr> <td>".$row['id']."</td> <td>".$row['title']."</td> <td><a href='mailto:".$row['email']."'>".$row['author']."</a></td> <td>".$row['category']."</td> <td><a href='admin.php?act=edit&id=".$row['id']."'>Edit</a> / <a href='admin.php?act=delete&id=".$row['id']."'>Delete</a></td> </tr> "; } echo "</table>"; } // Page: admin.php if (!$act) { echo " What would you like to do?<br><a href='?act=addnew'> Add a new tutorial</a> ---- <a href='?act=view'>Edit / Delete a previous tutorial </a> "; } ?> This would be first code... Second is for connecting to database. <?php $mysql_host = "localhost"; $mysql_user = "root"; $mysql_pass = ""; $mysql_data = "cms"; $mysql_table = "tutorials"; // Feel free to change this to your liking... /* --Working some magic-- */ mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die("Error connecting to Database! Please Try again. " . mysql_error()); mysql_select_db($mysql_data) or die("Cannot select database! Please Try again. " . mysql_error()); // ---------------------- // ?> And finally... <?php //Getting the file db.php which includes our database settings. define( 'DB_PATH' , "./" ); require DB_PATH."db.php"; //Setting up a variable to request the category which is in the URL $request_cat = $_REQUEST['category']; //Displaying an actual tutorial if (isset($id)) { // Updating the views, and grabbing a tutorial based on what id it has. $update = mysql_query("UPDATE $mysql_table SET views = views + 1 WHERE id='$id'"); $result = mysql_query("SELECT * FROM $mysql_table WHERE id='$id'"); while($row = mysql_fetch_array($result)){ // Template for the tutorial echo " <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='400'> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td><table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='275'><div align='left'><strong> <a href='tutorials.php?category=".$row['category']."&id=".$row['id']." '>".$row['title']."</a> </strong></div></td> <td width='125'><div align='right'> [ Views: ".$row['views']." ]</div></td> </tr> </table></td> </tr> <tr> <td><div align='left'>Description: ".$row['description']."</div></td> </tr> <tr> <td><div align='left'>".$row['content']."</div></td> </tr> <tr> <td><div align='left'> <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='150'><div align='left'>Added: ".$row['date']."</div> </td> <td><div align='right'>Author: <a href='mailto:".$row['email']."' >".$row['author']."</a> </div></td> </tr> </table> </div></td> </tr> <tr> <td><div align='left'>Category: <a href='tutorials.php?category=".$row['category']." >".$row['category']."</a> </div></td> </tr> </table></td> </tr> </table> "; // End of template of tutorial } // End of grabbing data exit(); // Stopping anything below from interfearing with this sectiom } // End of Displaying an actual tutorial //Displaying tutorials in a cateogry. if ($category == $request_cat) { //Grabbing information from the database. $result = mysql_query("SELECT * from $mysql_table where category = '$category' ORDER BY ID DESC"); while($row = mysql_fetch_array($result)) { //Template for the tutorials in a category. echo " <table width='400' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='100' align='center' valign='middle'><div align='center'> <a href='tutorials.php?category=".$row['category']."&id=".$row['id']."'> <img src='".$row['avatar']."' alt='".$row['title']."' title='".$row['title']."' width='90' height='60' border='0'></a> </div></td> <td width='300'> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td> <div align='center'><strong>".$row['title']."</strong></div></td> </tr> <tr> <td> <div align='left'>Description: ".$row['description']."</div></td> </tr> <tr> <td> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td><div align='left'>Added: ".$row['date']."</div></td> <td><div align='left'>Category: <a href='tutorials.php?category=".$row['category']." >".$row['category']."</a></div></td> </tr> </table></td> </tr> <tr> <td><table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='175'><div align='left'>Author: <a href='mailto:".$row['email']."'>".$row['author']."</a></div></td> <td width='100'><div align='left'>Views: ".$row['views']."</div></td> </tr> </table></td> </tr> </table></td> </tr> </table><br> "; // End of Template for the tutorials in a category. } // End of grabbing information from database. } // End of Displaying tutorials in a cateogry. // Main Tutorial page. This is where all your categories will be listed. if (!$category) { //This makes a list of all the cateogries that are in the database! No need to make the links yourself! $result = mysql_query("SELECT DISTINCT category from $mysql_table "); while($row = mysql_fetch_array($result)) { // Showing all the categories echo " <a href='tutorials.php?category=".$row['category']."' >".$row['category']."</a><br> "; // End of showing all the categories } // End of grabbing unique categories in database }// End of main tutorial page ?> I found this tutorial here: http://www.pixel-designz.net/tutorials/view/4/Advanced_Tutorial_CMS_Script_v1/1/
  14. It didn't even cross my mind... Thanks! Now it works! Hey, one more thing... Could I make it arrange data by date of entry? If you could give me that code, I would be more than happy...
  15. OK, this is what it shows... <table width="400" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td><strong>View Guestbook | <a href="guestbook.php">Sign Guestbook</a> </strong></td> </tr> </table> <br> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td>ID</td> <td>:</td> <td><? echo $rows['id']; ?></td> </tr> <tr> <td width="117">Name</td> <td width="14">:</td> <td width="357"><? echo $rows['name']; ?></td> </tr> <tr> <td>Email</td> <td>:</td> <td><? echo $rows['email']; ?></td> </tr> <tr> <td valign="top">Comment</td> <td valign="top">:</td> <td><? echo $rows['comment']; ?></td> </tr> <tr> <td valign="top">Date</td> <td valign="top">:</td> <td><? echo $rows['datetime']; ?></td> </tr> </table></td> </tr> </table> <BR> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td>ID</td> <td>:</td> <td><? echo $rows['id']; ?></td> </tr> <tr> <td width="117">Name</td> <td width="14">:</td> <td width="357"><? echo $rows['name']; ?></td> </tr> <tr> <td>Email</td> <td>:</td> <td><? echo $rows['email']; ?></td> </tr> <tr> <td valign="top">Comment</td> <td valign="top">:</td> <td><? echo $rows['comment']; ?></td> </tr> <tr> <td valign="top">Date</td> <td valign="top">:</td> <td><? echo $rows['datetime']; ?></td> </tr> </table></td> </tr> </table> <BR>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.