search partner displaying posts

//function for displaying posts
function get_posts(){

global $con;
 $per_page=5;
if (isset($_GET['page'])){

$page = $_GET['page'];
}
else{$page=1;}

$start_from = ($page-1) * $per_page;

$get_posts = "select * from posts ORDER by 1 DEC LIMIT $start_from, $per_page";

$run_posts = mysqli_query($con,get_posts);

while ($row_posts=mysqli_fetch_array($run_posts)){

$post_id = $row_posts['post_id'];
$post_title = $row_posts['post_title'];
$post_date = $row_posts['post_date'];
$user_id = $row_posts['user_id'];
$content = $row_posts['post_content'];

//getting the user who has posted the thread
$user = "select * from users where user_id='$user_id' AND posts='yes'";

$run_user = mysqli_query($con,$user);
$row_user = mysqli_fetch_array($run_user);
$user_name = $row_user['user_name'];
$user_image = $row_user['user_image'];

//now displaying all at once

echo"<div id='posts'>
<p><img src='user/user_images/$user_image' width='50' height='50'</p>
<h3><a href='user_profile.php?u_id=$user_id'>$user_name</a></h3>
<h3>$post_title</h3>
<p>$post_date</p>
<p>$content</p>
<a href='single.php?post_id=$post_id' style='float:right;'><button>See Replies or Reply to This </button></div><br/>

";


}

include ("pagination.php");
}


?>

search partner insert posts

<?php
$con = mysqli_connect("localhost","root"," ","social_media") or die ("Connection was not established");
?>

//function for inserting posts
function insertPost(){


if (isset($_POST['sub'])){

global $con;
global $user_id;
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
$topic= addslashes$_POST['topic'];

if ($content==' ' OR $title==' ' ){

echo "<h2>Please enter topic description </h2>";
exit();
}
else {
$insert = "insert into posts(user_id,topic_id,post_title,post_content,post_date) value ('$user_id','$topic', '$title', '$content', NOW())";

$run = mysqli_query($con,$insert);

if($run){
$update = "update users set posts = 'yes' where user_id='$user_id'"
$run_update = mysqli_query($con,$update);
}



}

}




}
//function for displaying posts
function get_posts(){

global $con;

$per_page=5;
if (isset($_GET['page'])){
$page = $_GET['page'];

}

}



search partner insert posts

<?php
$con = mysqli_connect("localhost","root"," ","social_media") or die ("Connection was not established");
?>

//function for inserting posts
function insertPost(){


if (isset($_POST['sub'])){

global $con;
global $user_id;
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
$topic= $_POST['topic'];

if ($content==''){

echo "<h2>Please enter topic description </h2>";
exit();
}
else {
$insert = "insert into posts(user_id,topic_id,post_title,post_content,post_date) value ('$user_id','$topic', '$title', '$content', NOW())";

$run = mysqli_query($con,$insert);

if($run){
$update = "update users set posts = 'yes' where user_id='$user_id'"
$run_update = mysqli_query($con,$update);
}



}

}




}
//function for displaying posts
function get_posts(){

global $con;

$per_page=5;
if (isset($_GET['page'])){
$page = $_GET['page'];

}

}



search partner insert posts

<?php
$con = mysqli_connect("localhost","root"," ","social_media") or die ("Connection was not established");
?>

//function for inserting posts
function insertPost(){


if (isset($_POST['sub'])){

global $con;
global $user_id;
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
$topic= $_POST['topic'];

if ($content==''){

echo "<h2>Please enter topic description </h2>";
exit();
}
else {
$insert = "insert into posts(user_id,topic_id,post_title,post_content,post_date) value ('$user_id','$topic', '$title', '$content', NOW())";

$run = mysqli_query($con,$insert);

if($run){
$update = "update users set posts = 'yes' where user_id='$user_id'"
$run_update = mysqli_query($con,$update);
}



}

}




}
//function for displaying posts
function get_posts(){

global $con;

$per_page=5;
if (isset($_GET['page'])){
$page = $_GET['page'];

}

}