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
https://forums.phpfreaks.com/topic/223510-comments/
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
https://forums.phpfreaks.com/topic/223510-comments/#findComment-1155334
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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