Jump to content
Larry Ullman's Book Forums

rocky66

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by rocky66

  1. Hi Larry. I'm following knowledge is power example and I almost finished. I would like to add a possibility to rate content displayed in page.php .You describbed rating process in " EffortlessECommerce Chapter 05 Bonus pages, page 5" available to download from your website. I've created drop-down box in page.php to rate content dispalyed in page.php .I want to insert from session user_id, page_id and rating value from drop-down box. $q = INSERT INTO page_ratings (user_id, page_id, rating) VALUES ($_SESSION['user_id'], $_POST['id'] , $_POST['rating']); $r = mysqli_query($dbc, $q); I'm using dreamweaver cs6 and its only showing me that there is error in query, when I try to debug it, it doesn't display error in div content like before... I've started to learn php from your books and I still have a lot to learn. If you could look at the page 5 in " EffortlessECommerce Chapter 05 Bonus pages " you will know what I'm trying to accomplish. Up to this point everything went smoothly and I didn't have major problems with "Knowledge is Power' example. I'm a novice so its difficult for me to solve this alone.... thank you
  2. Firstly.. This book is by far the best PHP e-commerce book I found on Amazon, period ! Thank you Larry for this great opportunity to learn from you. Your ideas are truly unique and so helpful for my project. I'm trying to rate my content according to your bonus material from chapter 5 "Rating Content". I would like to rate my content displayed in page.php using drop-down box like u suggested but unfortunately I'm lost after many attempts. I tried to add query from bonus material to insert values from drop-down box but, I couldn't succeeded.Can anyone please help me solve this problem. Thanks this is query from Chapter 5 Bonus Pages, page 4: INSERT INTO page_ratings (user_id, page_id, rating) VALUES ($_SESSION['user_id'], $_POST['id'] , $_POST['rating']) code for page.php : ?php // This page displays a specific page of HTML content. // This script is created in Chapter 5. // Require the configuration before any PHP code as the configuration controls error reporting: require ('./includes/config.inc.php'); // The config file also starts the session. // Require the database connection: require(MYSQL); // Validate the category ID: if (isset($_GET['id']) && filter_var($_GET['id'], FILTER_VALIDATE_INT, array('min_range' => 1))) { // Get the page info: $q = 'SELECT title, description, content FROM pages WHERE id=' . $_GET['id']; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) != 1) { // Problem! $page_title = 'Error!'; include ('./includes/header.html'); echo '<p class="error">This page has been accessed in error.</p>'; include ('./includes/footer.html'); exit(); } // Fetch the page info: $row = mysqli_fetch_array($r, MYSQLI_ASSOC); $page_title = $row['title']; include ('includes/header.html'); echo "<h3>$page_title</h3>"; // Display the content if the user's account is current: if (isset($_SESSION['user_not_expired'])) { // Bonus material! Referenced in Chapter 5. // Create add to favorites and remove from favorites links: // See if this is favorite: $q = 'SELECT user_id FROM favorite_pages WHERE user_id=' . $_SESSION['user_id'] . ' AND page_id=' . $_GET['id']; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) == 1) { echo '<p> This is a favorite! To remove from list press thumb down<a href="remove_from_favorites.php?id=' . $_GET['id'] . '"><img src="images/thumbdown.jpg" border="0" width="48" height="48" align="middle" /></a></p>'; } else { echo '<p>Make this a favorite! <a href="add_to_favorites.php?id=' . $_GET['id'] . '"><img src="images/thumbup.jpg" border="0" width="48" height="48" align="middle" /></a>'; } // Show the page content: echo "<div>{$row['content']}</div>"; // Bonus material referenced in chapter 5 // Rate Content // Bonus material! Referenced in Chapter 5. // Record this visit to the history table: $q = "INSERT INTO history (user_id, type, page_id) VALUES ({$_SESSION['user_id']}, 'page', {$_GET['id']}) AND "; $r = mysqli_query($dbc, $q); } elseif (isset($_SESSION['user_id'])) { // Logged in but not current. echo '<p class="error">Thank you for your interest in this content, but your account is no longer current. Please <a href="renew.php">renew your account</a> in order to view this page in its entirety</p>'; echo "<div>{$row['description']}</div>"; } else { // Not logged in. echo '<p class="error">Thank you for your interest in this content. You must be a logged in as a registered user to view this page in its entirety.</p>'; echo "<div>{$row['description']}</div>"; } } else { // No valid ID. $page_title = 'Error!'; include ('includes/header.html'); echo '<p class="error">This page has been accessed in error.</p>'; } // End of primary IF. ?> <label>Rating</label> <select id="rating" name="rating"> <option value="rating" selected="selected">-- Rate This tutorial--</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> <?php include ('./includes/footer.html'); ?>
×
×
  • Create New...