So I have been able to post the comment in the page I am creating and that comment is also saved in the comment table in the database with the id of the picture but when i am in the first picture and I comment the comments are posted saved in the database with the id 1 and then i go to the second the comments are also posted and saved in the tabel comment with the id of the picture 2. But my problem is that when i go to the second picture i can also see the comments of the first picture. So in all of my pictures I can see comments of pictures with other id. How can i manage to solve this problem. Please suggest me sth
I'll describe a little bit my database
name of database is art
picture tabel I have named piktur(id_piktur,Titulli,Pershkrimi,Piktur_url) rsGallery is picture recordset
the comment tabel I have named komente(id_koment,id_piktur,Tekst)rsKomente is comment recordset
Tekst is the column where the comment is save
I'm using the session variable so i can get the id of the picture from the picture table and insert it in id picture column of the comment tabel
this is the piece of code i guess i should make some conditions but i have tried sth myself but I have not managed to solve my problem. The pictures in my page are organised with paging and repeat region only showing 1 picture at a time. the comment are also repeat region showing all the comments at a time.
<p>
<?php while ($row_rsKomente = mysql_fetch_assoc($rsKomente)) { ?>
<?php
$id_piktur=$row_rsGallery['Id_piktur']; $_SESSION['id_piktur']=$id_piktur;
echo $row_rsKomente['Tekst']."<br/>" ;?>
<?php } ?>
</p>
my entire code is shown below if you don't think this code is enough for solving the problem gallery.php. Oh and I've been using DreamWeaver. Thank you in advance! :)
<?php require_once('Connections/art.php'); ?>
<?php session_start() ?>
<?php
if (!function_exists("GetSQLValueString")) {//this is some code i don't shown in here because it has nothing to do with the problem i want to solve}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1") &&(isset($_SESSION['id_piktur'])) ) {
$insertSQL = sprintf("INSERT INTO komente (Tekst,id_piktur) VALUES (%s,'".$_SESSION['id_piktur']."')", GetSQLValueString($_POST['tekst'], "text"));
mysql_select_db($database_art, $art);
$Result1 = mysql_query($insertSQL, $art) or die(mysql_error());
}
$maxRows_rsGallery = 1;
$pageNum_rsGallery = 0;
if (isset($_GET['pageNum_rsGallery'])) {
$pageNum_rsGallery = $_GET['pageNum_rsGallery'];
}
$startRow_rsGallery = $pageNum_rsGallery * $maxRows_rsGallery;
mysql_select_db($database_art, $art);
$query_rsGallery = "SELECT Pershkrim, Piktur_url, Rankim,id_piktur FROM piktur";
$query_limit_rsGallery = sprintf("%s LIMIT %d, %d", $query_rsGallery, $startRow_rsGallery, $maxRows_rsGallery);
$rsGallery = mysql_query($query_limit_rsGallery, $art) or die(mysql_error());
$row_rsGallery = mysql_fetch_assoc($rsGallery);
if (isset($_GET['totalRows_rsGallery'])) {
$totalRows_rsGallery = $_GET['totalRows_rsGallery'];
} else {
$all_rsGallery = mysql_query($query_rsGallery);
$totalRows_rsGallery = mysql_num_rows($all_rsGallery);
}
$totalPages_rsGallery = ceil($totalRows_rsGallery/$maxRows_rsGallery)-1;
$maxRows_rsKomente = 10; $pageNum_rsKomente = 0; if (isset($_GET['pageNum_rsKomente'])) { $pageNum_rsKomente = $_GET['pageNum_rsKomente']; } $startRow_rsKomente = $pageNum_rsKomente * $maxRows_rsKomente;
mysql_select_db($database_art, $art); $query_rsKomente = "SELECT Tekst,id_piktur FROM komente"; $query_limit_rsKomente = sprintf("%s LIMIT %d, %d", $query_rsKomente, $startRow_rsKomente, $maxRows_rsKomente); $rsKomente = mysql_query($query_limit_rsKomente, $art) or die(mysql_error()); $row_rsKomente = mysql_fetch_assoc($rsKomente); if (isset($_GET['totalRows_rsKomente'])) { $totalRows_rsKomente = $_GET['totalRows_rsKomente']; } else { $all_rsKomente = mysql_query($query_rsKomente); $totalRows_rsKomente = mysql_num_rows($all_rsKomente); } $totalPages_rsKomente = ceil($totalRows_rsKomente/$maxRows_rsKomente)-1;
$queryString_rsGallery = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rsGallery") == false &&
stristr($param, "totalRows_rsGallery") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rsGallery = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rsGallery = sprintf("&totalRows_rsGallery=%d%s", $totalRows_rsGallery, $queryString_rsGallery);
$queryString_rsKomente = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rsKomente") == false &&
stristr($param, "totalRows_rsKomente") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rsKomente = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rsKomente = sprintf("&totalRows_rsKomente=%d%s", $totalRows_rsKomente, $queryString_rsKomente);
?>
<!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>Paintings</title>
<link href="style_gallery.css" rel="stylesheet" type="text/css" />
</head>
<body>
</div>
<div id="logo_wrapper">
<!-- For the example logo, we used a font called "Ink Burrow", which is free from the major font sites. -->
<div id="logo"><img src="_images/logo.png" width="600" height="79" align="right" /></div>
</div>
<div id="main_container">
<div id="menu_container">
<div id="menu">
<ul id="base_menu" >
<li><a href="index.php">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="gallery.php">Gallery</a></li>
<ul class="sub_menu">
<li><a href="#" title="Charcoal" >Charcoal </a></li>
<li><a href="#" title="Oil paintings" >Oil paintings</a></li>
<li><a href="#" title="Sketches" >Sketches </a></li>
<li><a href="#" title="Our latest podcast" >Video Podcast</a></li>
</ul>
<li><a href="#">Contact </a></li>
<li><a href="#">Events</a></li>
<li><a href="login.php">Log in</a></li>
</ul>
</div>
</div>
<div id="mainArticle">
<h1>Painting Gallery</h1>
<p>Welcome !</p>
<p>
<?php do{ ?>
<?php $id_piktur=$row_rsGallery['id_piktur']; $_SESSION['id_piktur']=$id_piktur; echo $row_rsKomente['Tekst']."<br/>" ; ?> <?php } while ($row_rsKomente = mysql_fetch_assoc($rsKomente)); ?> </p>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<p>
<label for="comment">Comment : </label>
</p>
<p>
<textarea name="tekst" id="tekst" cols="45" rows="5">