Jump to content

Any one help getting past posts to show...


runnerjp

Recommended Posts

Hey guys,

 

im having issues with showing current posts when i visit the page again on a facebbok like wall post script.

 

it shows posts that im currently making fine but as soon as i go to refresh the page the posts disapear.

 

i have added all the codes below in a file so u have all the script.

 

[attachment deleted by admin]

Link to comment
Share on other sites

Though i would add the main 4 bits of code here.

 

Facebook_Wall_Script.PHP

<!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=iso-8859-1" />
<title>9lessons Applicatio Demo</title>
<link href="frame.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
  <script type="text/javascript" src="jquery.oembed.js"></script>

<script type="text/javascript">


$(function() {

$(".comment_button").click(function() {

var element = $(this);
   
    var boxval = $("#content").val();

    var dataString = 'content='+ boxval;

if(boxval=='')
{
alert("Please Enter Some Text");

}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="ajax.gif" align="absmiddle"> <span class="loading">Loading Update...</span>');
$.ajax({
	type: "POST",
  url: "update_ajax.php",
   data: dataString,
  cache: false,
  success: function(html){

  $("ol#update").prepend(html);
  $("ol#update li:first").slideDown("slow");
  
   document.getElementById('content').value='';
   $('#content').value='';
   $('#content').focus();
  $("#flash").hide();
  
    
$("#expand_url").oembed(boxval);

  }
});
}
return false;
});


// delete undate
$('.delete_update').live("click",function() 
{
var ID = $(this).attr("id");
var dataString = 'msg_id='+ ID;

if(confirm("Sure you want to delete this update? There is NO undo!"))
{
$.ajax({
	type: "POST",
  url: "delete_update.php",
   data: dataString,
  cache: false,
  success: function(html){

$(".bar"+ID).slideUp();

  }
});

}
return false;
});


//comment slide
$('.comment').live("click",function() 
{

var ID = $(this).attr("id");
$(".fullbox"+ID).show();
$("#c"+ID).slideToggle(300);

return false;
});


//commment Submint

$('.comment_submit').live("click",function() 
{

var ID = $(this).attr("id");

var comment_content = $("#textarea"+ID).val();

    var dataString = 'comment_content='+ comment_content + '&msg_id=' + ID;

if(comment_content=='')
{
alert("Please Enter Comment Text");

}
else
{

   
   	$.ajax({
	type: "POST",
  url: "comment_ajax.php",
   data: dataString,
  cache: false,
  success: function(html){
  

  $("#commentload"+ID).append(html);
    document.getElementById("textarea"+ID).value='';
   
   $("#textarea"+ID).focus();
  
  }
});


}

return false;
});

//comment delete
$('.cdelete_update').live("click",function() 
{
var ID = $(this).attr("id");

var dataString = 'com_id='+ ID;

if(confirm("Sure you want to delete this update? There is NO undo!"))
{
$.ajax({
	type: "POST",
  url: "delete_comment.php",
   data: dataString,
  cache: false,
  success: function(html){

$("#comment"+ID).slideUp();

  }
});
}
return false;
});




return false;

});


</script>


<style type="text/css">
body
{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
.update_box
{
background-color:#D3E7F5; border-bottom:#ffffff solid 1px; padding-top:3px
}
a
{
text-decoration:none;
color:#d02b55;
}
a:hover
{
text-decoration:underline;
color:#d02b55;
}
*{margin:0;padding:0;}


ol.timeline
{list-style:none;font-size:1.2em;}ol.timeline li{ display:none;position:relative; }ol.timeline li:first-child{border-top:1px dashed #006699;}
.delete_button
{
float:right; margin-right:10px; width:20px; height:20px
}

.cdelete_button
{
float:right; margin-right:10px; width:20px; height:20px
}

.feed_link
{
font-style:inherit; font-family:Georgia; font-size:13px;padding:10px; float:left; width:350px
}
.comment
{
color:#0000CC; text-decoration:underline
}
.delete_update
{
font-weight:bold;

}
.cdelete_update
{
font-weight:bold;

}
.post_box
{
height:55px;border-bottom:1px dashed #006699;background-color:#F3F3F3;  width:499px;padding:.7em 0 .6em 0;line-height:1.1em;

}
#fullbox
{
margin-top:6px;margin-bottom:6px; display:none;
}
.comment_box
{
    display:none;margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px;  height:50px;

}
.comment_load
{
  margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:30px; font-size:12px; border-bottom:solid 1px #FFFFFF;

}
.text_area
{
width:290px;
font-size:12px;
height:30px;
}
#expand_box
{
margin-left:90px;
margin-top:5px;
margin-bottom:5px;
}
embed
{
	width:200px;
	height:150px;

}

</style>
</head>

<body>


<div align="center">
<table cellpadding="0" cellspacing="0" width="500px">
<tr>
<td>


<div align="left">
<form  method="post" name="form" action="">
<table cellpadding="0" cellspacing="0" width="500px">

<tr><td align="left"><div align="left">
<h3>What are you doing?</h3></div></td></tr>
<tr>
<td style="padding:4px; padding-left:10px;" class="update_box">
<textarea cols="30" rows="2" style="width:480px;font-size:14px; font-weight:bold" name="content" id="content" maxlength="145" ></textarea><br />
<input type="submit"  value="Update"  id="v" name="submit" class="comment_button"/>
</td>

</tr>

</table>
</form>

</div>
<div style="height:7px"></div>
<div id="flash" align="left"  ></div>



<ol  id="update" class="timeline">



</ol>

</td>
</tr>
</table>






</div>



</body>
</html>

 

 

 

 

 

 

 

 

comment_ajax.PHP

 

<?php
include("db.php");
if(isSet($_POST['comment_content']))

{
$id=time();// Demo Use
$comment=$_POST['comment_content'];
$msg_id=$_POST['msg_id'];

$sql=mysql_query("insert into comments(comment,msg_id_fk)values('$comment','$msg_id')");
$result=mysql_query("select * from comments order by com_id desc");
$row=mysql_fetch_array($result);
$id=$row['com_id'];
$comment=$row['comment'];

}


?>

<div class="comment_load" id="comment<?php echo $id; ?>">
<?php echo $comment;  ?>
<span class="cdelete_button"><a href="#" id="<?php echo $id; ?>" class="cdelete_update">X</a></span>
</div>

 

 

 

 

 

 

 

 

 

 

 

 

update_ajax.PHP

 

 <?php
include("../../settings.php");
include("tolink.php");


//if(isSet($_POST['content']))

$id=time();//Demo Use
$msg=$_POST['content'];
$sql=mysql_query("insert into messages2(message)values('$msg')")or die(mysql_error());
$result=mysql_query("select * from messages2 order by msg_id desc")or die(mysql_error());
$row=mysql_fetch_array($result);
$id=$row['msg_id'];
$msg=$row['message'];
$msg=toLink($msg);



?>




<li class="bar<?php echo $id; ?>">
<div align="left" class="post_box">
<span style="padding:10px"><?php echo $msg; ?> </span>
<span class="delete_button"><a href="#" id="<?php echo $id; ?>" class="delete_update">X</a></span>
<span class='feed_link'><a href="#" class="comment" id="<?php echo $id; ?>">comment</a></span>
</div>
<div id='expand_box'>
<div id='expand_url'></div>
</div>
<div id="fullbox" class="fullbox<?php echo $id; ?>">
<div id="commentload<?php echo $id; ?>" >

</div>
<div class="comment_box" id="c<?php echo $id; ?>">
<form method="post" action="" name="<?php echo $id; ?>">
<textarea class="text_area" name="comment_value" id="textarea<?php echo $id; ?>">
</textarea><br />
<input type="submit" value=" Comment " class="comment_submit" id="<?php echo $id; ?>"/>
</form>
</div>
</div>


</li>

 

 

jquery.oembed.JS

 

 

(function($) {
    $.fn.oembed = function(url, options, callback) {

        options = $.extend(true, $.fn.oembed.defaults, options);

        return this.each(function() {

            var container = $(this),
			resourceURL = (url != null) ? url : container.attr("href"),
			provider;

            if (!callback) callback = function(container, oembed) {			
			 $.fn.oembed.insertCode(container, options.embedMethod, oembed);
            };

            if (resourceURL != null) {
                provider = getOEmbedProvider(resourceURL);

                if (provider != null) {
                    provider.maxWidth = options.maxWidth;
                    provider.maxHeight = options.maxHeight;					
				provider.params = options[provider.name] || {};
                    provider.embedCode(container, resourceURL, callback);
                    return;
                }
            }

            callback(container, null);
        });
    };

    // Plugin defaults
    $.fn.oembed.defaults = {
        maxWidth: null,
        maxHeight: null,
	embedMethod: "replace" // "auto", "append", "fill"
    };

$.fn.oembed.insertCode = function(container, embedMethod, oembed) {
	switch(embedMethod)
	{
		case "auto":				
                if (container.attr("href") != null) {
				insertCode(container, "append", oembed);
			}
			else {
				insertCode(container, "replace", oembed);
			};
			break;
		case "replace":	
			container.replaceWith(oembed.code);
			break;
		case "fill":
			container.html(oembed.code);
			break;
		case "append":
                var oembedContainer = container.next();
			if (oembedContainer == null || !oembedContainer.hasClass("oembed-container")) {
				oembedContainer = container
					.after('<div class="oembed-container"></div>')
					.next(".oembed-container");
				if (oembed != null && oembed.provider_name != null)
				    oembedContainer.toggleClass("oembed-container-" + oembed.provider_name);		
			}
			oembedContainer.html(oembed.code);				
			break;			
	}
}	

    $.fn.oembed.getPhotoCode = function(url, data) {
    var alt = data.title ? data.title : '';
        alt += data.author_name ? ' - ' + data.author_name : '';
        alt += data.provider_name ? ' - ' +data.provider_name : '';
        var code = '<div><a href="' + url + '" target="_blank"><img src="' + data.url + '" alt="' + alt + '"/></a></div>';
        if (data.html)
            code += "<div>" + data.html + "</div>";
        return code;
    };

    $.fn.oembed.getVideoCode = function(url, data) {
        var code = data.html;
        return code;
    };

    $.fn.oembed.getRichCode = function(url, data) {
        var code = data.html;
        return code;
    };

    $.fn.oembed.getGenericCode = function(url, data) {
        var title = (data.title != null) ? data.title : url,
		code = '<a href="' + url + '">' + title + '</a>';
        if (data.html)
            code += "<div>" + data.html + "</div>";
        return code;
    };

    $.fn.oembed.isAvailable = function(url) {
        var provider = getOEmbedProvider(url);
        return (provider != null);
    };

    /* Private Methods */
    function getOEmbedProvider(url) {
        for (var i = 0; i < providers.length; i++) {
            if (providers[i].matches(url))
                return providers[i];
        }
        return null;
    }

    var providers = [
        new OEmbedProvider("fivemin", "5min.com"),
        new OEmbedProvider("amazon", "amazon.com"),
        new OEmbedProvider("flickr", "flickr", "http://flickr.com/services/oembed", "jsoncallback"),    
        new OEmbedProvider("googlevideo", "video.google."),
        new OEmbedProvider("hulu", "hulu.com"),
        new OEmbedProvider("imdb", "imdb.com"),
        new OEmbedProvider("metacafe", "metacafe.com"),
        new OEmbedProvider("qik", "qik.com"),
        new OEmbedProvider("revision3", "slideshare"),
        new OEmbedProvider("slideshare", "5min.com"),
        new OEmbedProvider("twitpic", "twitpic.com"),
        new OEmbedProvider("viddler", "viddler.com"),
        new OEmbedProvider("vimeo", "vimeo.com", "http://vimeo.com/api/oembed.json"),
        new OEmbedProvider("wikipedia", "wikipedia.org"),
        new OEmbedProvider("wordpress", "wordpress.com"),
        new OEmbedProvider("youtube", "youtube.com")
    ];

    function OEmbedProvider(name, urlPattern, oEmbedUrl, callbackparameter) {
        this.name = name;
        this.urlPattern = urlPattern;
        this.oEmbedUrl = (oEmbedUrl != null) ? oEmbedUrl : "http://oohembed.com/oohembed/";
        this.callbackparameter = (callbackparameter != null) ? callbackparameter : "callback";
        this.maxWidth = 200;
        this.maxHeight = 100;

        this.matches = function(externalUrl) {
            // TODO: Convert to Regex
            return externalUrl.indexOf(this.urlPattern) >= 0;
        };

        this.getRequestUrl = function(externalUrl) {

            var url = this.oEmbedUrl;

            if (url.indexOf("?") <= 0)
                url = url + "?";

		var qs = "";

		for (var i in this.params) {
                // We don't want them to jack everything up by changing the callback parameter
                if (i == this.callbackparameter)
                  continue;
                
			// allows the options to be set to null, don't send null values to the server as parameters
                if (this.params[i] != null)
                	qs += "&" + escape(i) + "=" + this.params[i];
            }			

            url += "format=json";

		if (this.maxWidth != null)
			url += "&maxwidth=" + this.maxWidth;

		if (this.maxHeight != null)
			url += "&maxheight=" + this.maxHeight;			

		url += "&url=" + escape(externalUrl) + 			
				qs + 
				"&" + this.callbackparameter + "=?";

            return url;
        }

        this.embedCode = function(container, externalUrl, callback) {

            var request = this.getRequestUrl(externalUrl);

            $.getJSON(request, function(data) {

                var oembed = $.extend(data);

                var code, type = data.type;

                switch (type) {
                    case "photo":
                        oembed.code = $.fn.oembed.getPhotoCode(externalUrl, data);
                        break;
                    case "video":
                        oembed.code = $.fn.oembed.getVideoCode(externalUrl, data);
                        break;
                    case "rich":
                        oembed.code = $.fn.oembed.getRichCode(externalUrl, data);
                        break;
                    default:
                        oembed.code = $.fn.oembed.getGenericCode(externalUrl, data);
                        break;
                }

                callback(container, oembed);
            });
        }
    }
})(jQuery);

 

 

I HOPE SOMEONE CAN HELP ME WITH THIS

Link to comment
Share on other sites

code update

 

<!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=iso-8859-1" />
<title>9lessons Applicatio Demo</title>
<link href="frame.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
  <script type="text/javascript" src="jquery.oembed.js"></script>

<script type="text/javascript">


$(function() {

$(".comment_button").click(function() {

var element = $(this);
   
    var boxval = $("#content").val();

    var dataString = 'content='+ boxval;

if(boxval=='')
{
alert("Please Enter Some Text");

}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="ajax.gif" align="absmiddle"> <span class="loading">Loading Update...</span>');
$.ajax({
	type: "POST",
  url: "update_ajax.php",
   data: dataString,
  cache: false,
  success: function(html){

  $("ol#update").prepend(html);
  $("ol#update li:first").slideDown("slow");
  
   document.getElementById('content').value='';
   $('#content').value='';
   $('#content').focus();
  $("#flash").hide();
  
    
$("#expand_url").oembed(boxval);

  }
});
}
return false;
});


// delete undate
$('.delete_update').live("click",function() 
{
var ID = $(this).attr("id");
var dataString = 'msg_id='+ ID;

if(confirm("Sure you want to delete this update? There is NO undo!"))
{
$.ajax({
	type: "POST",
  url: "delete_update.php",
   data: dataString,
  cache: false,
  success: function(html){

$(".bar"+ID).slideUp();

  }
});

}
return false;
});


//comment slide
$('.comment').live("click",function() 
{

var ID = $(this).attr("id");
$(".fullbox"+ID).show();
$("#c"+ID).slideToggle(300);

return false;
});


//commment Submint

$('.comment_submit').live("click",function() 
{

var ID = $(this).attr("id");

var comment_content = $("#textarea"+ID).val();

    var dataString = 'comment_content='+ comment_content + '&msg_id=' + ID;

if(comment_content=='')
{
alert("Please Enter Comment Text");

}
else
{

   
   	$.ajax({
	type: "POST",
  url: "comment_ajax.php",
   data: dataString,
  cache: false,
  success: function(html){
  

  $("#commentload"+ID).append(html);
    document.getElementById("textarea"+ID).value='';
   
   $("#textarea"+ID).focus();
  
  }
});


}

return false;
});

//comment delete
$('.cdelete_update').live("click",function() 
{
var ID = $(this).attr("id");

var dataString = 'com_id='+ ID;

if(confirm("Sure you want to delete this update? There is NO undo!"))
{
$.ajax({
	type: "POST",
  url: "delete_comment.php",
   data: dataString,
  cache: false,
  success: function(html){

$("#comment"+ID).slideUp();

  }
});
}
return false;
});




return false;

});


</script>


<style type="text/css">
body
{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
.update_box
{
background-color:#D3E7F5; border-bottom:#ffffff solid 1px; padding-top:3px
}
a
{
text-decoration:none;
color:#d02b55;
}
a:hover
{
text-decoration:underline;
color:#d02b55;
}
*{margin:0;padding:0;}


ol.timeline
{list-style:none;font-size:1.2em;}ol.timeline li{ display:none;position:relative; }ol.timeline li:first-child{border-top:1px dashed #006699;}
.delete_button
{
float:right; margin-right:10px; width:20px; height:20px
}

.cdelete_button
{
float:right; margin-right:10px; width:20px; height:20px
}

.feed_link
{
font-style:inherit; font-family:Georgia; font-size:13px;padding:10px; float:left; width:350px
}
.comment
{
color:#0000CC; text-decoration:underline
}
.delete_update
{
font-weight:bold;

}
.cdelete_update
{
font-weight:bold;

}
.post_box
{
height:55px;border-bottom:1px dashed #006699;background-color:#F3F3F3;  width:499px;padding:.7em 0 .6em 0;line-height:1.1em;

}
#fullbox
{
margin-top:6px;margin-bottom:6px; display:none;
}
.comment_box
{
    display:none;margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px;  height:50px;

}
.comment_load
{
  margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:30px; font-size:12px; border-bottom:solid 1px #FFFFFF;

}
.text_area
{
width:290px;
font-size:12px;
height:30px;
}
#expand_box
{
margin-left:90px;
margin-top:5px;
margin-bottom:5px;
}
embed
{
	width:200px;
	height:150px;

}

</style>
</head>

<body>
<?php include '../../settings.php'; ?>

<div align="center">
<table cellpadding="0" cellspacing="0" width="500px">
<tr>
<td>


<div align="left">
<form  method="post" name="form" action="">
<table cellpadding="0" cellspacing="0" width="500px">

<tr><td align="left"><div align="left">
<h3>What are you doing?</h3></div></td></tr>
<tr>
<td style="padding:4px; padding-left:10px;" class="update_box">
<textarea cols="30" rows="2" style="width:480px;font-size:14px; font-weight:bold" name="content" id="content" maxlength="145" ></textarea><br />
<input type="submit"  value="Update"  id="v" name="submit" class="comment_button"/>
</td>

</tr>

</table>
</form>




</div>
<div style="height:7px"></div>
<div id="flash" align="left"  ></div>

<?php
$query = "SELECT * FROM messages2";
    $sqlinbox = mysql_query($query);
    
    //Error thingy, ohh no! Dispaly the error and the query so we can diagnose the problem if there is one
    if(!$sqlinbox)
        {
        ?>
  <p><?php print '$query: '.$query.mysql_error();?></p>
        <?php
        }
else
{
echo 'yes it is';   
}


$sql=mysql_query("SELECT * FROM messages2 LIMIT 9")or die(mysql_error());
while($row=mysql_fetch_array($sql))
{
$msg=$row['msg'];
$mes_id=$row['mes_id'];
$up=$row['up'];
$down=$row['down'];
?>

<div class='box2' ><?php echo $msg; ?></div>
</div>

<?php } ?>
<ol  id="update" class="timeline"></ol>

</td>
</tr>
</table>






</div>



</body>
</html>

 

 

it echos yes it is but then no results!

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.