WD1812 Posted April 18, 2010 Share Posted April 18, 2010 Hi, The following code creates a page on which site visitors can enter comments. Once the comments are posted, they can then be viewed by any other site visitor. I want to make each new comment Title linkable to a detail page, on which would appear all of the information that was included for that specific title. I have been at this for weeks now, and still a struggling newbie. Could someone please show me the code I need to enter and/or the modifications I need to make? *** I didn't include the code for the Table, so as to save space.*** Thank you! <?php require_once('Connections/feedback_db.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $currentPage = $_SERVER["PHP_SELF"]; $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO feedback (title, contents, author_name, author_email) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['contents'], "text"), GetSQLValueString($_POST['author_name'], "text"), GetSQLValueString($_POST['author_email'], "text")); mysql_select_db($database_feedback_db, $feedback_db); $Result1 = mysql_query($insertSQL, $feedback_db) or die(mysql_error()); $insertGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } $maxRows_GetFeedback = 10; $pageNum_GetFeedback = 0; if (isset($_GET['pageNum_GetFeedback'])) { $pageNum_GetFeedback = $_GET['pageNum_GetFeedback']; } $startRow_GetFeedback = $pageNum_GetFeedback * $maxRows_GetFeedback; $colname_GetFeedback = "pending"; if (isset($_GET['status'])) { $colname_GetFeedback = $_GET['status']; } mysql_select_db($database_feedback_db, $feedback_db); $query_GetFeedback = sprintf("SELECT * FROM feedback WHERE status = %s ORDER BY created_at DESC", GetSQLValueString($colname_GetFeedback, "text")); $query_limit_GetFeedback = sprintf("%s LIMIT %d, %d", $query_GetFeedback, $startRow_GetFeedback, $maxRows_GetFeedback); $GetFeedback = mysql_query($query_limit_GetFeedback, $feedback_db) or die(mysql_error()); $row_GetFeedback = mysql_fetch_assoc($GetFeedback); if (isset($_GET['totalRows_GetFeedback'])) { $totalRows_GetFeedback = $_GET['totalRows_GetFeedback']; } else { $all_GetFeedback = mysql_query($query_GetFeedback); $totalRows_GetFeedback = mysql_num_rows($all_GetFeedback); } $totalPages_GetFeedback = ceil($totalRows_GetFeedback/$maxRows_GetFeedback)-1; $queryString_GetFeedback = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_GetFeedback") == false && stristr($param, "totalRows_GetFeedback") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_GetFeedback = "&" . htmlentities(implode("&", $newParams)); } } $queryString_GetFeedback = sprintf("&totalRows_GetFeedback=%d%s", $totalRows_GetFeedback, $queryString_GetFeedback); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Feedback and Ideas</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>Feedback and ideas </h1> <p> </p> <div id="items"> <h2>Received feedback</h2> <p><a href="index.php?status=pending">pending</a> <a href="index.php?status=planned">planned</a><a href="index.php?status=declined">declined</a></p> <ol> <?php do { ?> <li><strong><?php echo $row_GetFeedback['title']; ?></strong><br /> <?php echo $row_GetFeedback['contents']; ?><br /> by <?php echo $row_GetFeedback['author_name']; ?>, at <?php echo $row_GetFeedback['created_at']; ?></li> <?php } while ($row_GetFeedback = mysql_fetch_assoc($GetFeedback)); ?> </ol> <p><a href="<?php printf("%s?pageNum_GetFeedback=%d%s", $currentPage, max(0, $pageNum_GetFeedback - 1), $queryString_GetFeedback); ?>">Previous </a>Showing <?php echo ($startRow_GetFeedback + 1) ?>...<?php echo min($startRow_GetFeedback + $maxRows_GetFeedback, $totalRows_GetFeedback) ?> out of <?php echo $totalRows_GetFeedback ?> <a href="<?php printf("%s?pageNum_GetFeedback=%d%s", $currentPage, min($totalPages_GetFeedback, $pageNum_GetFeedback + 1), $queryString_GetFeedback); ?>">Next</a></p> </div> <div id="create"> <h2>Add your feedback</h2> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <input type="hidden" name="MM_insert" value="form1" /> </form> </div> <p> </p> <p> </p> </body> </html> <?php mysql_free_result($GetFeedback); ?> Link to comment https://forums.phpfreaks.com/topic/198938-would-appreciate-help-making-new-title-linkable-to-a-detail-page/ Share on other sites More sharing options...
TeddyKiller Posted April 18, 2010 Share Posted April 18, 2010 "would appear all of the information that was included for that specific title." What does this mean exactly..? Also.. CODE TAGS!! I can't read all that. >.< Link to comment https://forums.phpfreaks.com/topic/198938-would-appreciate-help-making-new-title-linkable-to-a-detail-page/#findComment-1044233 Share on other sites More sharing options...
-Karl- Posted April 18, 2010 Share Posted April 18, 2010 Use PHP tags and I'll take a look. EDIT: Wouldn't it be as simple as (assuming the comments have a unique ID in the database.) <li><strong><a href="./index.php?detail=<?php echo $row_GetFeedback['id]; ?>><?php echo $row_GetFeedback['title']; ?>"><?php echo $row_GetFeedback['title']; ?></a></strong><br /> Then if (isset($_GET['detail'])) { //echo detail } Link to comment https://forums.phpfreaks.com/topic/198938-would-appreciate-help-making-new-title-linkable-to-a-detail-page/#findComment-1044249 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.