Jump to content

Recommended Posts

Well, where do you want to start? It's pretty much just getting the data, storing it in the database and displaying it on the page. Think about all the places you need to display it and structure the database in a good way so querying it isn't a pain. I don't use Facebook a lot, so I probably don't know all the places where wall posts are displayed.

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1040362
Share on other sites

Facebooks wall feature, is basically like comments. Except you can comment on the comments...

I don't get what you mean?

What i mean is i can get it so that users can write comments but when i go away from the page the comments dont save for later viewing by other users.

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1041563
Share on other sites

What i mean is i can get it so that users can write comments but when i go away from the page the comments dont save for later viewing by other users.

 

You need to use a persistent storage mechanism like a database or flat files of some sort. How else do you expect the data to persist?

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1041565
Share on other sites

Here is the code i have made for the comment feature it says am getting a pares error where I have

</body></html>

i have changed the name of the database, user and password for posting here.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

  <head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    <meta name="author" content="">
    <title></title>
  <link rel="stylesheet" type="text/css" href="css1.css" />
  </head>
<body>
<?php

// calling session_start() the function which starts our authentication session
session_start();

// connecting to mysql server

// Connects to your Database
mysql_connect("localhost", "r", "fff") or die(mysql_error());
mysql_select_db("ut") or die(mysql_error());


// defining getShouts() which is our function that gets all of our shouts
function getcomments()
{

echo '<div align="center">
	<table width="150" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td>
';	

$query = mysql_query("SELECT * FROM comments ORDER BY commentid DESC LIMIT 10") or die(mysql_error());
while ($row = mysql_fetch_array($query) )
{

	$name = stripslashes($row['Name']);
	$comment = stripslashes($row['comment']);



echo '<br><br>';

echo '
		</td>
	  </tr>
	  <tr>
		<td height="10"> </td>
		<form name="comment" method="post" action="comment.php">
		  <div align="center">
			<input name="name" type="text" id="name" value="Name" size="25" maxlength="10"><br>
			<input name="message" type="text" id="message" value="Message" size="25"><br>
			<input name="comment" type="submit" id="comment" value="comment!">
		  </div>
		</form>
		</td>
	  </tr>
	  </table>
	  </div>
	';	

} // function getcomments


// our processing if control statement
if ( isset ( $_POST['comment'] ) )
{

$name = addslashes($_POST['name']);
$message =  $_POST['message'];

if ( ( isset($name) ) && ( isset($message) ) )
{



	mysql_query("INSERT INTO comment (Name,  message) VALUES ( '$name', '$message' )") or die(mysql_error());
	$_SESSION['has_posted'] = 'yes';
	header("Location: comment.php");

	// if required fields aren't empty, process into database

} else {

	echo '<script>alert("Some fields were not filled out!");</script>';
	header("Location: comment.php");

	// if required fields were left empty, show an error dialog

}

}
getcomments();
</body></html>
?>

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1041693
Share on other sites

Here is my new code first one comment.php is just page with a form and the second page comments2.php is were the php code that is ment to display the the review but it does not just shows a blank page.

comments.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

  <head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    <meta name="author" content="">
    <title></title>
  <link rel="stylesheet" type="text/css" href="css1.css" />
  </head>
<body>


<form action="comments2.php" method="post">
<tr><td>Username:</td><td>
<input type="text" name="name" maxlength="60">
</td></tr><br />
<tr><td>jjj:</td><td>
<input type="text" name="jjj" maxlength="60">
</td></tr><br />
<tr><td>Review:</td><td><br />
<TEXTAREA NAME="review" COLS=40 ROWS=15></TEXTAREA>
<tr><th colspan=2><input type="submit" name="submit" value="SUBMIT"></th></tr> </table>
</form>

</body></html>

names of certain things have been changed to post on here.

 

Heres is the code for comments2 the names of certain things have been changed so i can post on here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

  <head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    <meta name="author" content="">
    <title></title>
  <link rel="stylesheet" type="text/css" href="css1.css" />
  </head>
<body>
<?php
// Connects to your Database
mysql_connect("localhost", "gggg", "g") or die(mysql_error());
mysql_select_db("cd") or die(mysql_error());


// now we insert it into the database
$insert = "INSERT INTO comments (name, ffffff, jjjjj)
VALUES ('".$_POST['name']."', '".$_POST['fffff']."','".$_POST['jjjjj']."')";
$add_member = mysql_query($insert);

$query = mysql_query("SELECT * FROM comments ORDER BY commentid DESC LIMIT 15") or die(mysql_error());
($row = mysql_fetch_array($query) )
   




?>
</body></html>

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1041870
Share on other sites

I suggest reading up on PHP 101 before attempting to code a feature similar to Facebook wall. If you don't even know how to print content to the page with PHP, you really shouldn't be writing this.

well i did not think having a comment box would be so hard. all i wanted it to do was to able the user to leave comments for others to see like they have on many sites.

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1042030
Share on other sites

Here is the new code only problem is it wont display the comment it just saves it to the database. Please tell me what am doing wrong. name of database name has been changed.

   <?php


// Otherwise we connect to our Database
mysql_connect("localhost", "t", "g") or die(mysql_error());
mysql_select_db("hhh") or die(mysql_error());



// check if POST data has been entered (meaning a comment was entered)

if (isset ($_POST['submit'])) {
    $comment = mysql_escape_string (trim ($_POST['comment']));
    
    // enter the comment to the database
    $sql = mysql_query ("INSERT INTO comments (id,comments) VALUES ('0','".$comment."')");

    echo 'Your comment has been entered successfully!';
} else {
    // POST data wasnt entered, so display the comments and comment form

    // view comments from database
    $sql = mysql_query ("SELECT * FROM comments");
    while ($row = mysql_fetch_array ($sql)) {
        echo $row['comments'].'<br />';
    }

    // display comment form
    echo '<br /><br />
    <form action="commentsnew.php" method="post">
    Comments:<br />
    <textarea name="comment" cols="40" rows="7"></textarea>
<input type="submit" name="submit" value="SUBMIT">
    </form>';
}

?> 

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1042101
Share on other sites

I have the code sort of working but i just need it to display the user name as well as the comment. can someone show me how to get the username as well please.

<html>

  <head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    <meta name="author" content="">
    <title></title>
  <link rel="stylesheet" type="text/css" href="css1.css" />
  </head>
<body>
<?php

   // Otherwise we connect to our Database
mysql_connect("localhost", "y", "j") or die(mysql_error());
mysql_select_db("h") or die(mysql_error());



// check if POST data has been entered (meaning a comment was entered)

if (isset ($_POST['submit'])) {
    $comment = mysql_escape_string (trim ($_POST['comment']));
//This makes sure they did not leave any fields blank
if (!$_POST['username']  | !$_POST['comment'] ) {
die('You did not complete all of the required fields');
}


    // enter the comment to the database
    $sql = mysql_query ("INSERT INTO comments (id,comments) VALUES ('0','".$comment."')");

    echo 'Your comment has been entered successfully!';
} else {
    // POST data wasnt entered, so display the comments and comment form

    // view comments from database
    $sql = mysql_query ("SELECT * FROM comments");
    while ($row = mysql_fetch_array ($sql)) {
        echo $row['comments'].'<br />';
    }

   
}

?>


    
    <form name= comments action="commentsnew.php" method="post">
    Comments:<br />
<tr><td>Username:</td><td>
    <input type="text" name="username" maxlength="60">
     </td></tr><br />
    <textarea name="comment" cols="40" rows="7"></textarea>
<input type="submit" name="submit" value="SUBMIT">
    </form>
<a href=members.php>Click Here to go to the members page</a>
</body></html>

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1042133
Share on other sites

Then we have a dilemma.

 

$sql = mysql_query ("INSERT INTO comments (id,comments) VALUES ('0','".$comment."')");

^ You never insert the username so ... where is it?

This is what i got now but it just gives a parse error on that line

$sql = mysql_query ("INSERT INTO comments (id,comments,username) VALUES ('0','".$comment."', '".$username."')");

Link to comment
https://forums.phpfreaks.com/topic/198269-the-wall-feature/#findComment-1042171
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.