16,015,900 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Mike CJ (Top 48 by date)
Mike CJ
6-Sep-18 13:31pm
View
I want create counter like google "About 121,000,000 results (0.68 sec)" the one in brackets. I do not know just what to do, whether in Js or immediately in php
Mike CJ
22-Jun-17 7:12am
View
But there is no general. How to work around the blockade and defend against such attacks.
Mike CJ
21-Jun-17 18:56pm
View
I was more specific about PDO
Mike CJ
16-Jun-17 9:42am
View
Okay I found an error. I made a mistake in spelling
instead method I wrote methond... But thanks anyway for the help.
Mike CJ
15-Jun-17 15:12pm
View
I don't know. I'm learning JavaScript with youtube :https://www.youtube.com/watch?v=GrycH6F-ksY
Mike CJ
15-Jun-17 14:49pm
View
I tried with your code and nothink. Look this: https://ibb.co/iiDAck
Mike CJ
15-Jun-17 14:34pm
View
Can you tell me how to do that?
Mike CJ
15-May-17 12:13pm
View
This is very difficult, but fine now I have to learn it.
Mike CJ
15-May-17 10:59am
View
Okay. So how I can add other variable ?
I have now this code:
$(document).ready(function(){
$('#button').on("click",function(){
var postid = $(this).attr('id');
$.ajax({
url:'comment_post.php',
type: 'post',
data:{'postid': postid
}
});
Mike CJ
30-Apr-17 14:46pm
View
I updated my question.
Mike CJ
13-Apr-17 18:32pm
View
Now: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
Mike CJ
13-Apr-17 17:27pm
View
This is an integer whether I need to remove extra quotes?
Mike CJ
11-Apr-17 10:55am
View
Okay you can delete this solution if you want. Later I create now.
Mike CJ
11-Apr-17 10:46am
View
I don't know how I do it this is my upload script:
https://gist.github.com/CODEMIKECJ/6efa2ac3560331799562459f56a8a8a2
Mike CJ
11-Apr-17 5:39am
View
My schema database table news is the
Id | username | likes | iduser | image | title
$query="SELECT * FROM news
This query is in the home.php
Comment table
Id | idpost | Iduser | content_comment | name_user
Mike CJ
11-Apr-17 4:34am
View
Yes, but I would like to get the corresponding post id ie when I add a comment it gets the corresponding id. You know what I mean?
Mike CJ
10-Apr-17 17:42pm
View
The query does not send the corresponding id
$article['id']; <-- I want to send this id. Btw. My system news consists of foreach
This my select script in the home.php
<?php
try
{
$user = 'root';
$pass = '';
$PDO = new PDO('mysql:host=localhost;dbname=mike', $user, $pass);
$PDO->exec("set names utf8");
$stmt = $PDO->prepare("SELECT nick_user,comment FROM comments WHERE idpost=".$article['id']." ");
$stmt->execute();
$stmt = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($stmt as $row)
{
echo $row['nick_user'].": ".".$row['comment']."";
}
}
catch(PDOException $e)
{
echo "Error: " .$e;
}
?>
//showing posts form table news
[...]
$articles = $articles->fetchAll(PDO::FETCH_ASSOC);
foreach($articles as $article)
{
$article['id']; // this is the post id
}
and form to send comment to the script comment.php
<button id="o_sl"
class=""name="o_sl"">SEND
<?php
$idpost = $article['id'];
$_SESSION['zmienna_r'] = $idpost; ?>
Mike CJ
10-Apr-17 12:52pm
View
Alway is Uncaught Error: Call to undefined function sqlsrv_next_result()
Mike CJ
10-Apr-17 12:33pm
View
If that does not work this way
<?php
session_start();
try
{
$user = 'root';
$pass = '';
$PDO = new PDO('mysql:host=localhost;dbname=mike', $user, $pass);
$PDO->exec("set names utf8");
$stmt = $PDO->prepare("SELECT * FROM news ");
$stmt->execute();
if (isset($_POST['o_sl']) && strlen($_POST['yourtextarea']) > 0 )
{
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$queryINS = "INSERT INTO `comments` (`idpost`,`iduser`, `comment`, `nick_user`) VALUES (:idpost, :iduser, :comment, :nick_user) ";
$stmt = $PDO->prepare($queryINS);
$stmt->bindValue(':idpost', $_SESSION['zmienna_r'] );
$stmt->bindValue(':iduser', $_SESSION['id']);
$stmt->bindValue(':comment', $_POST['yourtextarea']);
$stmt->bindValue(':nick_user', $_SESSION['user']);
$stmt->execute();
$id = $PDO->lastInsertId();
sqlsrv_next_result($stmt);
sqlsrv_fetch($stmt);
$id= sqlsrv_get_field($stmt,0);
}
catch(PDOException $e)
{
echo "Error: " .$e->getMessage();
}
?>
Mike CJ
10-Apr-17 12:28pm
View
First or second ?
Mike CJ
10-Apr-17 12:24pm
View
Under what should I write it?
Mike CJ
10-Apr-17 12:15pm
View
Fatal error: Uncaught Error: Call to undefined function sqlsrv_next_result()
Mike CJ
10-Apr-17 11:59am
View
Doesn't working.
Mike CJ
5-Apr-17 8:25am
View
Okay. Working. Thanks for any help.
Mike CJ
3-Apr-17 12:12pm
View
Can I do so to change only the name without the file format?
Mike CJ
3-Apr-17 11:59am
View
How I can add format file with use GUID ?
Mike CJ
3-Apr-17 11:42am
View
I have question to you. How I can use this code
<?php
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
?>
Mike CJ
31-Mar-17 7:02am
View
Working. Thanks for the help
Mike CJ
31-Mar-17 1:53am
View
Myabe I can use sum() instead count (). I don't know.
Mike CJ
31-Mar-17 1:35am
View
The point is that he wants to draw the total number. So if the user has two posts and two users have given them like this. Then the total number is 4. So I wanted to use $ _SESSION ['id']. Would it be better to send uploads to the user id database?
Mike CJ
31-Mar-17 1:08am
View
I would like get all date for logged user.
Mike CJ
31-Mar-17 1:04am
View
It's working, but I would like get date for logged user
Mike CJ
20-Mar-17 18:26pm
View
I don't know... I tried with this code:
$(document).ready(function(){
$('.like').click(function(event){
var postid = $(this).attr('id');
$.ajax({
url:'index_post.php',
type: 'post',
async: false,
data:{
'liked': 1,
'postid': postid
}
});
event.preventDefault();
});
});
and I tried add onclick="return false;" to span. In a sense
Now I have no idea how to do it.
Mike CJ
20-Mar-17 13:51pm
View
In JS code:
success:function(){
}
Yes ?
Mike CJ
20-Mar-17 13:41pm
View
Yes. I want refresh two span 1st is "LIKE span" 2nd "UNLIKE span"
Secend code JS
$(document).ready(function(){
$('.unlike').click(function(){
var postid = $(this).attr('id');
$.ajax({
url:'index_unpost.php',
type: 'post',
async: false,
data:{
'unliked': 1,
'postid2': postid
}
});
});
});
Mike CJ
20-Mar-17 13:33pm
View
I'm trying to accomplish refresh only span. Okay if I removed "like function" how I can do it refresh only span? Maybe you know how do it. btw. Sorry for my bad English.
Mike CJ
20-Mar-17 12:26pm
View
So the line where the href I must add onclick="like(); return false;". Yes ?
Mike CJ
19-Mar-17 8:46am
View
Deleted
I think that the code does not work between scripts. My script doesn't show any errors.
Mike CJ
18-Mar-17 13:21pm
View
Yes. This was the last question. Code working. Thank you very much.
Mike CJ
18-Mar-17 13:05pm
View
Code working. But now if user clicked unlike button, number like in the table does not decrease why ?
Mike CJ
18-Mar-17 12:29pm
View
re-post Solution 2
Mike CJ
18-Mar-17 12:22pm
View
Deleted
index.php
<?php
$mysqli = new mysqli('localhost', 'root','');
$mysqli->select_db('like');
?>
<!DOCTYPE html>
<title>LIKE and UNLIKE
.content
{
width:50%;
margin:100px auto;
border:1px solid #cbcbcb;
}
.post
{
width:80%;
margin:10px auto;
border:1px solid #cbcbcb;
padding:10px;
}
<?php
$query = $mysqli->query("SELECT * FROM posts");
while($row = mysqli_fetch_array($query)) { ?>
<?php echo $row['text'] . " " . $row['likes']; ?>
<?php
$result = mysqli_query($mysqli,"SELECT * FROM likes WHERE userid='1' AND postid=".$row['id']."");
if(mysqli_num_rows($result) == 1) { ?>
unlike
<?php } else { ?>
like
<?php } ?>
<?php } ?>
$(document).ready(function(){
$('.like').click(function(){
var postid = $(this).attr('id');
$.ajax({
url:'index_post.php',
type: 'post',
async: false,
data:{
'liked': 1,
'postid': postid
},
success:function(){
}
});
});
});
$(document).ready(function(){
$('.unlike').click(function(){
var postid = $(this).attr('id');
$.ajax({
url:'index_unpost.php',
type: 'post',
async: false,
data:{
'unliked': 1,
'postid2': postid
},
success:function(){
}
});
});
});
index_post.php
<?php
$mysqli = new mysqli('localhost', 'root','');
$mysqli->select_db('like');
$postid = $_POST['postid'];
$result = mysqli_query($mysqli, "SELECT * FROM posts WHERE id=$postid");
while($row2 = $result->fetch_array())
{
$n = $row2['likes'];
mysqli_query($mysqli, "UPDATE posts SET likes=$n+1 WHERE id=$postid");
mysqli_query($mysqli, "INSERT INTO likes(userid, postid) VALUES(1,$postid)");
}
exit();
?>
index_unpost.php
<?php
$mysqli = new mysqli('localhost', 'root','');
$mysqli->select_db('like');
$postid = $_POST['postid2'];
$result = mysqli_query($mysqli, "SELECT * FROM `posts` WHERE id=$postid");
while($row3 = $result->fetch_array())
{
$n = $row3['likes'];
mysqli_query($mysqli, "UPDATE `posts` SET likes=$n-1 WHERE postid=$postid AND userid=1");
mysqli_query($mysqli, "DELETE FROM `likes` WHERE id='$postid' userid=1 ");
}
exit();
?>
Mike CJ
18-Mar-17 12:11pm
View
This reduced. I changed the code. but now there is no answer. that is, it increased the number'like' by 1, and when you click on the button it does not diminish and do not change the name to 'like'
Mike CJ
18-Mar-17 11:20am
View
Rows doesn't deleted. Maybe you know why table doesn't drop ?
Mike CJ
18-Mar-17 11:10am
View
I changed it and no change. The idea is that if the table is 0 likes, then the button changes to like.
Mike CJ
18-Mar-17 11:00am
View
Okay. But button does not change the like but is still unlike. Why?
Mike CJ
18-Mar-17 10:40am
View
I created index_unpost.php Javascript:
$(document).ready(function(){
$('.unlike').click(function(){
var postid = $(this).attr('id');
$.ajax({
url:'index_unpost.php',
type: 'post',
async: false,
data:{
'unliked': 1,
'postid2': postid
},
success:function(){
}
});
});
});
And code in the index_unpost.php
<?php
$mysqli = new mysqli('localhost', 'root','');
$mysqli->select_db('like');
$postid = $_POST['postid'];
$result = mysqli_query($mysqli, "SELECT * FROM posts WHERE id=$postid");
while($row3 = $result->fetch_array())
{
$n = $row3['likes'];
mysqli_query($mysqli, "DELETE FROM likes WHERE id=$postid userid=1");
mysqli_query($mysqli, "UPDATE posts SET likes=$n-1 WHERE id=$postid");
}
exit();
?>
If the user clicks the button like such as in the table is reduced by 1, but the "unlike" does not change to like. I don't know why.
Mike CJ
18-Mar-17 9:54am
View
Okay, working, Now I need something such as "if the user clicked on the button" unlike "change the button to" like "in this case is the link "href". How I can do it?
Show More