Jump to content

shan2batman

Members
  • Posts

    90
  • Joined

  • Last visited

shan2batman's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

1

Community Answers

  1. ok then do this $query="select name, plan_id from table_name where condition='condition_name' order by id"; then execute the query with mysqli or pdo and create a loop and type the necessary html code like this <table> foreach($fetched_data as $content) { $result .=" <tr><td>".$content['name']."</td></tr> <tr><td>".$content['plan_id']."</td></tr> "; } echo $result; the above code will print it in table format, you can change it to any format and place it in your php page by either requiring or including the file or just run the loop in the same page. to place the $result in the desired place at any page you have to create a separate php file and loop in it and then call it in the desired place like require 'path to filename/filename.php'; or include 'path to filename/filename.php'; hope this helps forgive my english it isn't my mother tongue.
  2. no need to complicate things, use wildcard in your query like "select * from table_name where condition='codition name' order by id"
  3. no need to complicate things, use wildcard in your query like "select * from table_name where condition='codition name' order by id"
  4. i'm trying to make a notification tab work but do not seem to get it right. The dropdown is working fine but the ajax call to newfriends.php is not working right, when viewed with firebug there are no results to be seen in the dropdown.Quite confusing. (note the dropdown menu is located in header and can only be displayed if the session is initialised) here is the ajax used in jquery: function load_notifications(view=''){ $.ajax({ url: "notification/new_friends.php", method: "POST", data:{view:"view"}, dataType:"json", success: function(data){ $(".dropdown-menu").html(data.notification); if(data.unseen_notification>0){ $(".badge1").html(data.unseen_notification); } } }); //$(".dynamic-notification").load("notification/pm_n.php"); // $(".dynamic-notification-f").load("notification/new_friends.php"); }; load_notifications(); $(document).on("click",".count_friend", function(){ load_notifications('yes'); }); //loads every 2 seconds for chat setInterval(function(){load_notifications();},2000); here is the new_friends.php content: <?php include '../includes/dbconfig.inc.php'; if (isset($_POST['view'])) { if($_POST['view'] !=''){ $update="update friends set count='1' where friend_one=:session and count='0'"; $stmt=$conn->prepare($update); $stmt->bindValue(":session", $_SESSION['uname']); $stmt->execute(); } $sql123="select id from friends where friend_two=:sess_uname and count='0'"; $stmt123=$conn->prepare($sql123); $stmt123->bindValue(":sess_uname", $_SESSION['uname']); $stmt123->execute(); $request_count=$stmt123->fetchColumn(); //$count_friend=$stmt123->rowCount(); /*$sql_f_count="select *from user where user_id=:session_id and activated='1' limit 1"; $stmt_f_count=$conn->prepare($sql_f_count); $stmt_f_count->bindValue(":session_id", $_SESSION['id']); $stmt_f_count->execute(); $user_details=$stmt_f_count->fetchAll(); $friend_badge=$user_details[0]['friend_count_badge'];*/ require "notification/friend_request_notification.php"; // $new_friends="<span class='dropdown'><a href='#' data-placement='bottom' class='btn dropdown-toggle' data-toggle='dropdown' title='Friend Requests' data-html='true'><span class='count_friend' style=' height:33px; width:30px;'><span class='badge1 label label-pill'>".$count."</span><img src='img/logo/group-button-white.png' style='height:25px; width:27px;' alt='new_friends_alert'></span></a><ul class='dropdown-menu'></ul></span>"; //if($request_count[0]>0){ //$new_friends="<a href='#' data-placement='bottom' class='btn' data-trigger='focus' title='Friend Requests' data-toggle='popover' data-html='true' data-content='".$friend_requests."'><span class='count_friend' style=' height:33px; width:30px;'><img src='img/logo/group-button-white.png' style='height:25px; width:27px;' alt='new_friends_alert'></span><span class='badge'>".$friend_badge."</span></a>"; /*}else{ $new_friends="<a href='all_notifications.php'><img src='img/logo/group-button-black.png' style='height:25px; width:27px;' alt='new_friends_alert'></a>"; }*/ //echo $new_friends; //} $data=array( 'notification'=>$friend_requests, 'unseen_notification' =>$request_count[0][0] ); and the code for friend requests output: <?php //error_reporting(0); require_once 'includes/dbconfig.inc.php'; $sql = "select * from friends where friend_two=:session and accepted='0' order by friends_date_made asc"; $stmt = $conn->prepare($sql); $stmt->bindparam(":session", $_SESSION['uname']); $stmt->execute(); $numrows = $stmt->fetchAll(PDO::FETCH_ASSOC); $friend_requests=""; if ($numrows < 1) { $friend_requests = "You do not have any friend requests"; echo "$friend_requests"; exit(); } else { foreach ($numrows as $i=>$row1 ) { $reqid = $row1['friend_id']; $user1 = $row1['friend_one']; $datemade = $row1['friends_date_made']; $datemade1 = strftime("%B %d, %y", strtotime($datemade)); $sql = "SELECT * FROM user WHERE uname=:user1 LIMIT 1"; $stmt = $conn->prepare($sql); $stmt->bindparam(":user1", $user1); $stmt->execute(); $thumbrow = $stmt->fetchAll(PDO::FETCH_ASSOC); $user1avatar = $thumbrow[$i]['avatar']; $user1id=$thumbrow[$i]['user_id']; if ($user1avatar =="") { $user1pic = '<img src="img/avatardefault.png" height="50" style="float:left;" width="50" alt="'.$user1.'" class="user_pic">'; } else { $user1pic = '<img src="../user/user/'.$user1id.'/'.$user1avatar.'" height="50" style="float:left;" width="50" alt="'.$user1.'" class="user_pic">'; } $friend_requests .= '<li><div id="'.$reqid.'" float="right" class="friendrequests"> <a href="home.php?u='.$user1.'">'. $user1pic .'</a> <div class="user_info '.$reqid.'" id="'.$reqid.'"><small>' . $datemade1 . '</small> <a href="home.php?u='.$user1.'">'.$user1.'</a> is requesting your friendship<br /><br /> <button id="'.$reqid.'" name="'.$_SESSION['uname'].'" sess="'.$_SESSION['id'].'" class="accept_btn btn btn-warning">Accept</button><span class="show-spinner"></span> or <button id="'.$reqid.'" name="'.$_SESSION['uname'].'" sess="'.$_SESSION['id'].'" class="reject_btn btn btn-warning">Reject</button> </div> </div><hr></li>'; } }
  5. Hi guys, Recently i developed a new social network called www.myexpresspad.com. Please join and give me feedback on how your experience was with it. please also take a few moments to answer the poll which would do a lot of help for me and if you feel it needs improvement please leave a reply of your remarks on the social network. Plus i would also appreciate anyone who gives me tips on marketing it. Regards, Gowri Shanker.D
  6. My problem is that everytime when a user uploads photos through my app in openshift it gets lost.When i try to update the code through git,I couldn't find a solution on the net.So I came here for experts advice. i would also appreciate if anyone can point me to an article that does it for php app in openshift. The problem is simple my user uploaded files are stored in /user/{$_SESSION['id']} folder that is located in repo folder. through research i found that it should be stored in app-root/data folder. If so how can i store user uploaded photos directly there and access it for the user who wants to view it in browser directly like www.testing-pad4u.rhcloud.com/home.php?u={$_SESSION['name']}. i have no clue on how to do it please help me or point me in the right direction as i'm a total noob to Linux.
  7. @mac_gyver after looking in to the source i found a fatal error from a user function that was not yet written. You saved my time boss.
  8. here is the full code. The problem is that the $data_fetch is able to pull all the desired results when i try to var_dump it. But, the variable $row_d is only pulling the first row from the DB. How may i solve it. Please forgive me for not giving adequately specific. @jacques1 <?php include 'includes/header.php'; if (isset($_SESSION['uname'])){ $tag= htmlentities($_GET['tag']); $sql3="select * from user where uname like '%$tag%' and activated='1'"; $stmt_t=$conn->prepare($sql3); $stmt_t->execute(); $tag_fetch=$stmt_t->fetchAll(PDO::FETCH_ASSOC); $sql1="select * from group_posts"; $stmt_t=$conn->prepare($sql1); $stmt_t->execute(); $data_fetch=$stmt_t->fetchAll(); function hashtags($dat, $tag) { $regex="/#+([a-zA-z0-9._-]+)/"; foreach($dat as $d){ $dat1= preg_match($tag, $d); print_r($dat1); } return $dat1; } ?> <div class="container-fluid"> <br><div class="row"> </div><br> <div class="row"> <div class="col-sm-2"> <?php include_once 'notification/friend_list.php'; ?> <?php include 'groups/group_list.php';?> </div> <div class="col-lg-8"> <table class="main_page"> <td class="div-col-left1"><div class="overflow"><h3>Users</h3> <?php foreach ($tag_fetch as $row_s) { $id_s=$row_s['user_id']; $fname_s=$row_s['fname']; $lname_s=$row_s['lname']; $uname_s=$row_s['uname']; $email_s=$row_s['email']; $phone_s=$row_s['phone']; $photo_s=$row_s['avatar']; $city_s=$row_s['city']; if($photo_s !=""){ echo '<div class="" align="left">'; echo '<a href="home.php?u='.$uname_s.'" target="_blank"><img width="130" height="130" src="user/'.$id_s.'/'.$photo_s.'">'.$fname_s.' '.$lname_s.'('.$uname_s.')</a><br>City:- '.$city_s.'<hr>'; echo '</div>'; } else { echo '<div class="" align="left">'; echo '<a href="home.php?u='.$uname_s.'" target="_blank"><img width="130" height="130" src="img/avatardefault.png">'.$fname_s.' '.$lname_s.'('.$uname_s.')</a><br><hr>'; echo '</div><br>'; } } echo "</div></td><td class='div-col-right1 '><div class='overflow'><h3>Groups</h3>"; foreach ($data_fetch as $row_d) { $postid=$row_d['gp_id']; $post_auth=$row_d['author_gp']; $post_type=$row_d['type']; $post_title= html_entity_decode($row_d['title']); $post_data= html_entity_decode($row_d['data']); $data1= array($post_data); // $data1= taggingsys($data0); $post_date=$row_d['pdate']; $post_avatar=$row_d['avatar']; $post_uid=$row_d['user_id']; if ($post_avatar != ""){ $g_pic='user/'.$post_uid.'/'.$post_avatar; } else { $g_pic='img/avatardefault.png'; } $user_image="<img src='{$g_pic}' alt='{$post_auth}' title='{$post_auth}' width='30' height='30'>"; $vote_up_count=$project->voteGroupCheck($postid, $_SESSION['id']); /*foreach ($data1 as $d) { $d1= explode(" ", $d); if(strpos("$d1", "#$tag") !=FALSE){ echo "hurray"; } } */ if($vote_up_count[0][0]>0){ $vote_like=TRUE; } else { $vote_like=FALSE; } if($vote_up_count[0][1]>0){ $vote_dislike=TRUE; } else { $vote_dislike=FALSE; } include 'ratings/vote_count_g.php'; if ( $vote_like==TRUE && $vote_dislike==FALSE) { $like='<a type="liked" class="btn liked status_like_'.$postid.' liked" attr="'.$postid.'">Liked</a>('.$num_likes[0].')'; $unlike='<a type="unlike" class="btn status_unlike_'.$postid.' unlike" attr="'.$postid.'">Dislike</a>('.$num_unlikes[0].')'; } elseif ($vote_dislike==TRUE && $vote_like==FALSE) { $like='<a type="like" class="btn status_like_'.$postid.' like" attr="'.$postid.'">Like</a>('.$num_likes[0].')'; $unlike='<a type="disliked" class="btn disliked status_unlike_'.$postid.'" attr="'.$postid.'">Disliked</a>('.$num_unlikes[0].')'; } else { $like='<a type="like" class="btn status_like_'.$postid.' like" attr="'.$postid.'">Like</a>('.$num_likes[0].')'; $unlike='<a type="unlike" class="btn status_unlike_'.$postid.' unlike" attr="'.$postid.'">Dislike</a>('.$num_unlikes[0].')'; } #build threads. echo $edit."<div id='PB_".$postid."' value='".$postid."' class='jumbotron'><span id='spinner".$postid."'></span>" . "<legend>{$post_title}" . "<span class='pull-right'>" . "<div class='dropdown'>" . "<button type='button' class='btn btn-danger dropdown-toggle' data-toggle='dropdown' >" . "<span class='glyphicon glyphicon-edit'></span></button>" . "<ul class='dropdown-menu'>" .$edit_btn ." ". $statusdeletebutton ."</ul></div></span><br></legend>" . "<legend>{$post_data}<br><span class='spinner_g_u{$postid}'></span>{$like} | {$unlike} <br>Posted by:{$user_image} {$post_auth}-- {$post_date}<hr><br></legend> <h4><a id='{$postid}' class='btn collap-btn'>Comments</a></h4><div class='collapse scroll-comments' id='toggle{$postid}'>"; #get replies and user image using inner loop $num_rows1=$project->groupcount_replies($postid); $fetch1=$project->group_replies($postid); if ($num_rows1>0) { foreach ($fetch1 as $row1) { $reply_id=$row1['gp_id']; $reply_pid=$row1['pid']; $reply_auth=$row1['author_gp']; $reply_data=$row1['data']; $data11= hashtags($reply_data); $data12= taggingsys($data11); $reply_date=$row1['pdate']; $reply_avatar=$row1['avatar']; $reply_uid=$row1['user_id']; if ($reply_avatar != ""){ $r_pic='user/'.$reply_uid.'/'.$reply_avatar; } else { $r_pic='img/avatardefault.png'; } /* include 'ratings/vote_count_g4comments.php'; $like_r='<a type="like" class="btn status_liker_'.$reply_id.' like_r" attr="'.$reply_id.'">Like</a>('.$num_likes_r[0].')'; $unlike_r='<a type="unlike" class="btn status_unliker_'.$reply_id.' unlike_r" attr="'.$reply_id.'">Dislike</a>('.$num_unlikes_r[0].')'; */ $vote_up_count=$project->voteGroupReplyCheck($_SESSION['id'],$reply_id); if($vote_up_count[0][0]>0){ $vote_like=TRUE; } else { $vote_like=FALSE; } if($vote_up_count[0][1]>0){ $vote_dislike=TRUE; } else { $vote_dislike=FALSE; } include 'ratings/vote_count_g4comments.php'; if ( $vote_like==TRUE && $vote_dislike==FALSE) { $like_r='<a type="liked" class="btn status_liker_'.$reply_id.' liked_r" attr="'.$reply_id.'">Liked</a>('.$num_likes_r[0].')'; $unlike_r='<a type="unlike" class="btn status_unliker_'.$reply_id.' unlike_r" attr="'.$reply_id.'">Dislike</a>('.$num_unlikes_r[0].')'; } elseif ($vote_dislike==TRUE && $vote_like==FALSE) { $like_r='<a type="like" class="btn status_liker_'.$reply_id.' like_r" attr="'.$reply_id.'">Like</a>('.$num_likes_r[0].')'; $unlike_r='<a type="unliked" class="btn disliked_r status_unliker_'.$reply_id.'" attr="'.$reply_id.'">Disliked</a>('.$num_unlikes_r[0].')'; } else { $like_r='<a type="like" class="btn status_liker_'.$reply_id.' like_r" attr="'.$reply_id.'">Like</a>('.$num_likes_r[0].')'; $unlike_r='<a type="unlike" class="btn status_unliker_'.$reply_id.' unlike_r" attr="'.$reply_id.'">Dislike</a>('.$num_unlikes_r[0].')'; } $reply_img="<img src='{$r_pic}' alt='{$reply_auth}' title='{$reply_auth}' width='15' height='15'>"; #build replies echo "<div id='reply_body'>" . "<small>Posted by:{$reply_img} {$reply_auth}-- {$reply_date}</small><br>" . "<legend>{$data12}<br><span class='spinner_g_r{$reply_id}'></span>{$like_r} | {$unlike_r} </legend></div>"; } } echo '<br>' . '<textarea id="reply_textarea_'.$postid.'" class="group_reply1 input-custom2" placeholder="comment\'s"></textarea>' . '<br><span class="group_reply"></span><button action="post_reply" id="'.$postid.'" attr="'.$postid.'" type="b" class="btn btn-warning pull-right btn-sm reply_btn reply">Reply</button><br></div></div>'; } } echo '</div></td>'; ?> </div> <div class="col-sm-2" style="float: right;"> <?php include 'notification/friend_suggestion.php';?> </div> </div> </div>
  9. no, for simplicity's sake i kept the code small. the problem is it isn't fetching the results from $row_d, but i was able to print the $data_fetch results finely.@jacques1
  10. Hi, guys i'm trying to fetch all results from DB through a foreach loop. But it is not working as intended, as it brings only the first record and not the others. here is my code:- $sql1="select * from group_posts"; $stmt_t=$conn->prepare($sql1); $stmt_t->execute(); $data_fetch=$stmt_t->fetchAll(); foreach ($data_fetch as $row_d) { $postid=$row_d['gp_id']; $post_auth=$row_d['author_gp']; $post_type=$row_d['type']; $post_title= html_entity_decode($row_d['title']); $post_data= html_entity_decode($row_d['data']); $data1= array($post_data); // $data1= taggingsys($data0); $post_date=$row_d['pdate']; $post_avatar=$row_d['avatar']; $post_uid=$row_d['user_id']; if ($post_avatar != ""){ $g_pic='user/'.$post_uid.'/'.$post_avatar; } else { $g_pic='img/avatardefault.png'; } $user_image="<img src='{$g_pic}' alt='{$post_auth}' title='{$post_auth}' width='30' height='30'>"; $vote_up_count=$project->voteGroupCheck($postid, $_SESSION['id']); }
  11. hi, i'm trying to verify whether someone has like a post or not here and it is not giving the expected output but a empty array.Any help would be great. Thanks in advance. //fetch user_id from update table in db and inject it to the feed query. $totalUpdates=$project->totalUpdates1($id,$load); $total_sess_count=$project->totalupdatescount($id); foreach ($totalUpdates as $j=>$row1) { $updateid=$row1['update_id']; $account_name=$row1['account_name']; $u_id=$row1['user_id_u']; $author=$row1['author']; $post_date=$row1['time']; $title= stripslashes($row1['title']); $data= stripslashes($row1['update_body']); $data1= hashtags($data); //$data1= taggingsys($data0); $pic=$project->viewByUname($author); $uid=$pic['user_id']; $datemade = strftime("%B %d", strtotime($post_date)); $avatar=$pic['avatar']; if ($avatar!=""){ $feed_pic='user/'.$uid.'/'.$avatar; } else { $feed_pic='img/avatardefault.png'; } //logic to check if someone has liked or not. $liked_check="select voted_id from voted_u where user_id_v=:sess_id and vote_4_update_id=:updateid "; $stmt_liked=$conn->prepare($liked_check); $stmt_liked->bindValue(":sess_id", $_SESSION['id']); $stmt_liked->bindValue(":updateid",$updateid); $like_check=$stmt_liked->fetchAll(); if ($like_check>0) { $uname_liked=TRUE; }
  12. up votedown votefavorite I've been scraching my head for hours over this problem. I'm basically trying to fetch values from a loop inside a function to pass it to another foreach loop to get the desired results. And it is not working as I intend to. please, point me in the right direction. Here is the code: function ff($s) { $project=""; foreach ($s as $i=> $r ){ $r["friend_one"] == $_SESSION['uname'] ? $friends[]= $r["friend_two"] : $friends[] = $r["friend_one"]; $friend=$friends[$i]; $totalids=$project->totalids($_SESSION['uname'],$friend); } return $totalids; } $totalid= ff($f); print_r($totalid); foreach ($totalid as $v){ $id=$v['user_id']; //other logic to get desired result }
  13. Guys recently i finished a infinite scroll to one of my projects using jquery, php and mysql. After creating that i face the problem of tinymce editor not binding to the dynamically generated textarea. What should i do? here is the code for tinymce editor: tinymce.init({ menubar:false, forced_root_block : "", selector: "textarea#wall_edit_1", entities : '160,nbsp,162,cent,8364,euro,163,pound', theme: "modern", resize: false, height: 200, plugins: [ " autolink link image preview hr anchor pagebreak spellchecker", "searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking", "save table contextmenu directionality emoticons paste textcolor" ], content_css: "css/content.css", toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l ink image | print preview media fullpage | emoticons", style_formats: [ {title: 'Bold text', inline: 'b'}, // {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}}, {title: 'Header', block: 'h1'}, {title: 'Example 1', inline: 'span', classes: 'example1'}, {title: 'Example 2', inline: 'span', classes: 'example2'}, {title: 'Table styles'}, {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'} ] }); here is the php code that dynamically generates the textarea while using the infinite scroll feature in jquery: if ($author==$_SESSION['uname'] || $account_name==$_SESSION['uname']) { $statusdeletebutton='<li>' . '<a type="'.$updateid.'" class="btn delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_status_btn" title="Delete this status and its replies">Remove</a></li>'; $edit_btn='<li>' . '<a attr="'.$updateid.'" type="'.$updateid.'" class="btn edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'; $statusui_edit="<div type='".$updateid."' class='hidden_edit_4_session session_editor".$updateid." jumbotron'>" . "<a type='".$updateid."' class='btn pull-right close_edit' title='Close without editing'>Close X</a>" . "<input type='text' class='form-control title_s_edit title_s_".$updateid."' name='status_title' value='".html_entity_decode($title)."' placeholder='Title' >" . "<span> </span>" . "<textarea id='wall_edit_1' type='".$updateid."' rows='5' cols='50' class='session_edit text_value_".$updateid."' wrap='hard' placeholder='whats up ".$session_uname."'> ".html_entity_decode($data1)."</textarea><br>" . "<button style='float:right;' value='".$updateid."' type='a' class='btn btn-warning btn btn-large btn-lg post-s-edit'>Update</button></div>" ; }else{ $statusdeletebutton=""; $edit_btn="<li class='posted'>You are not the owner of this Post</li>"; $statusui_edit=""; } echo $statusui_edit.''. $hidden_text.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.' jumbotron">' . '<h3 class="pull-left title">' . '<div id="'.$updateid.'" class="title_s_2copy posted" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>' . '<span class="pull-right">' . '<div class="dropdown">' . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" >' . '<span class="glyphicon glyphicon-edit"></span></button>' . '<ul class="dropdown-menu">' .$edit_btn .' '. $statusdeletebutton .'</ul></div></span><br><hr>' . '<legend><span style="font-size: 13.5px;" class=" data_s_2copy" type="'.$updateid.'" >' . html_entity_decode($data1).'</span></legend><b class="posted"><small>Posted by:- <a href="home.php?u='.$author.'"><img src="'.$feed_pic.'" height="20px" width="20px"> '.$author. '</a> '.$datemade.'</small></b>' . '<br><legend>'.$like.' | '.$unlike. ' | '.$share_button.'<h4><a id="'.$updateid.'" class="btn collap-btn">Comments</a></h4></legend>';
×
×
  • 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.