Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

commentation script questions.

Status
Not open for further replies.

mailerman

Technical User
Jan 2, 2007
29
SE
i found a comment script that would work, but it want my pages in id insteed. bellow is how i currenlt have it to show my images.

Code:
<?
$MYSQL_HOST = 'test';
$MYSQL_USER = 'test';
$MYSQL_PASSWORD = 'test';
$MYSQL_DATABASE = 'test';

mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
mysql_select_db($MYSQL_DATABASE);

$res = mysql_query('SELECT *,unix_timestamp(tstamp) as utstamp FROM img
    ORDER BY tstamp DESC LIMIT 6');

echo "<table cellspacing=\"3\" cellpadding=\"1\" border=\"2\"><tr>";

while ($row = mysql_fetch_assoc($res)) {

    echo "<td>";
    $row['message'] = substr($row['message'],strpos($row['message'],' '));

    if ( file_exists('img/' . $row['id'] . '.jpeg') ) {
        $row['picture'] = 'img/' . $row['id'] . '.jpeg';
    } else $row['picture'] = '';

    if ( $row['picture'] != '' ) {
        echo '<a href="show.php?id=' . $row['id'] . '">';
        echo '<img width="125" src="' . $row['picture'] . '"></a>';
    }
    
    echo "</td>";
}
    echo "</tr></table>";
?>

"show.php" shows the picture clicked in a new window with the ID name of the picture in the database, the comment script however as shown bellow

Code:
<?php
$page_id = "6"; // for example
include("comments/comments_show.php");
include("comments/comments_form.php");
?>

i need to manually change the number for each page to make a diffrent comment form / comments appear, so i wonder, is it possible to maybe make the code for the comment check the ID of the picture and if the id of the picture in show.php is for example 36 it makes the page ID 36 and shows the correct comment form? or in some way make it automated?

 
If I understand right, you want to have the comment box relate only to a certain "picture". I used a java script solution to do something similar. to do this on each "article" I have you click the add comment image
Code:
onclick="toggle_vis('15');" //15 = id number
And then my function looks like this...
Code:
function toggle_add(id) {

	var cment = "add_comment_" + id;

	var Comment = document.getElementById(cment);

	if(Comment.style.display == 'none')	

		Comment.style.display = 'block';

	else

		Comment.style.display = 'none';

}

to see it in action look at NB Im not a designer, justa coder ;)
 
Forgot to add...
on php side it looks like this....

Code:
echo '<dd class="note_comment_count"><img src="/images/comment.gif" alt="Add Comment"';    //<------- IMG ADD Comment
	echo "onclick=\"toggle_add('$ID');\"> Add A Comment</dd>";
	echo "</dl></div>";
 
hey there, i noticed i forgot to add someting so i think i made you missunderstand me.

when people press a picture shown by my PHP code, show.php opens that picture in a new window, now what i need in that new window under that picture is my commentbox, and as i need to change the commentscript ID manually i need a script of some sort that if a user press a picture with for example ID 56 the script changes the "$page_id = "6";" in the comment script automaticly to 56 so that the correct comment form / comments are shown.

hope i made it a little clearer and sorry for missing out saying this! :)
 
Does your HTML look like this?
Code:
<a href> <img> </a>

If so what if you do this?
Code:
<a href="link.htm"> <input type="hidden" name="ID" value="6"> <img> </a>
then you cna process the ID with a POST["ID"] ....

or even better.... if you are using an <a href> to open the new window you can do this...
Code:
<a href=link.html?ID=6>
You can set the id value in the page by your current php script then use a GET["ID"] on the next page.
 
this is how the code in show.php looks like

Code:
<img src="data/<?=$_GET['id']?>.jpeg">

if the link ID fro from the database is 56 it checks /data/ foler for image 56 and displays it.
 
well then you can:
Code:
$page_id = $_GET['id'];
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top