Jump to content

Comments


ananaz

Recommended Posts

Hello im trying to make a comment feature by having a link under my pictures kommentar.php?link=1

Then use the link=1 to see what comments that should be taken from the database. The comments have a linkid

like this

 

Linkid:      Text:

1              a comment on first picture

1              another comment on first picture

2              a comment on second picture

2              another comment on second picture

 

But i can't get my php to echo all the comments with the linkid of for example 1 without having to get them all separately.

 

This is my script:

 

<?php
ob_start();
$host="localhost";
$username="****";
$password="******";
$db_name="db"; 
$tbl_name="comment"; 

mysql_connect($host, $username, $password)or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$linkid=filter_input(INPUT_GET,'link');

$sql="SELECT * FROM $tbl_name WHERE linkid='$linkid'";
$result=mysql_query($sql);
$grejs=null;
while(mysql_fetch_row($result)){
$grejs.="$row[0]";
}
echo $grejs;
ob_end_flush();
?>

Link to comment
Share on other sites

<?php
$host="localhost";
$username="****";
$password="******";
$db_name="db"; 
$tbl_name="comment"; 

mysql_connect($host, $username, $password)or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");


$linkid=filter_input(INPUT_GET,'link');

$sql="SELECT * FROM $tbl_name WHERE linkid='$linkid'";
$result=mysql_query($sql);
$row = mysql_fetch_assoc($result);
$grejs=null;
do {
$grejs.="$row[0]";	
} while(mysql_fetch_row($result));

echo $grejs;
?>

 

Give that a try

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.