Jump to content

Lumana

New Members
  • Posts

    8
  • Joined

  • Last visited

Lumana's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for your reply sir, I have already checked the network Tab and its showing "update_count.php" can not found, though i placed the file in the same folder. But when i am doing like below its working : <?php $con=mysqli_connect('localhost','root','','youtube'); $sql="SELECT * FROM articles where alias='$it-is-fine'"; $res=mysqli_query($con,$sql); $row=mysqli_fetch_assoc($res); ?> But when I am doing like below, its not working : The URL not found they are showing is not the correct URL, Maybe because I am using htaccess, I am trying to solve the URL probelm, if you have any idea about that , pls share with me. Thanks sir <?php $con=mysqli_connect('localhost','root','','youtube'); $alias=$_GET['alias']; $sql="SELECT * FROM articles where alias='$alias'"; $res=mysqli_query($con,$sql); $row=mysqli_fetch_assoc($res); ?>
  2. I have tried this code below to solve my problem , but in front end number is increasing buy in Mysql the numbers are not increasing <?php $con=mysqli_connect('localhost','root','','youtube'); $alias=$_GET['alias']; $sql="SELECT * FROM articles where alias='$alias'"; $res=mysqli_query($con,$sql); $row=mysqli_fetch_assoc($res); ?> <!DOCTYPE html> <html lang="en"> <head> <title>Like Dislike</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js" integrity="sha256-Lsk+CDPOzTapLoAzWW0G/WeQeViS3FMzywpzPZV8SXk=" crossorigin="anonymous"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> </head> <body> <div class="container"> <div class="row main_box"> <div class="col-md-6 title"> <h3><?php echo $row['title']; ?></h3> </div> <div class="col-md-3"> <a href="javascript:void(0)" class="btn btn-info"> <span class="glyphicon glyphicon-thumbs-up" onclick="like_update('<?php echo $row['id']; ?>')">Like (<span id="like_loop_<?php echo $row['id']; ?>"><?php echo $row['like_count']; ?></span>)</span> </a> </div> <div class="col-md-3"> <a href="javascript:void(0)" class="btn btn-info"> <span class="glyphicon glyphicon-thumbs-down" onclick="dislike_update('<?php echo $row['id']; ?>')">Dislike (<span id="dislike_loop_<?php echo $row['id']; ?>"><?php echo $row['dislike_count']; ?></span>)</span> </a> </div> </div> <script> function like_update(id) { var cur_count=jQuery('#like_loop_'+id).html(); cur_count++; jQuery('#like_loop_'+id).html(cur_count); jQuery.ajax({ url:'update_count.php', type:'post', data:'type=like&id='+id, success:function(result){ } }); } function dislike_update(id) { var cur_count=jQuery('#dislike_loop_'+id).html(); cur_count++; jQuery('#dislike_loop_'+id).html(cur_count); jQuery.ajax({ url:'update_count.php', type:'post', data:'type=dislike&id='+id, success:function(result){ } }); } </script> </div> </body> </html> update_count.php <?php $con=mysqli_connect('localhost','root','','youtube'); $type=$_POST['type']; $id=$_POST['id']; if ($type=='like') { $sql="UPDATE articles SET like_count=like_count+1 WHERE id=$id"; } else { $sql="UPDATE articles SET dislike_count=dislike_count+1 WHERE id=$id"; } $res_count=mysqli_query($con,$sql); ?> Please help me my seniors here... Thanks in advance
  3. I am trying to fetch timestamp data from mysql but its not working, can anyone please help me out of this. Thanks in Advance At first I tried like this but not working: <?php include 'database.php'; $sql=mysqli_query($con,"SELECT * FROM article where alias='how-to-do-math-equation'"); $row=mysqli_fetch_assoc($sql); echo $row['update_time']; ?> then i tried like this but also not working: <?php include 'database.php'; $sql=mysqli_query($con,"SELECT * FROM marathons where alias='standard-chartered-marathon-KL'"); $row=mysqli_fetch_assoc($sql); $posted_at = ($row['update_time']); echo $posted_at; ?> I want to echo timestamp data like this : 2022-11-28 14:28:58
  4. Thank you so much sir... your code is working well and easily understandable also.
  5. Thank you so much sir... your code is working well and easily understandable also.
  6. Thank you so much sir. your last line open my brain to think , though other people already gave me solution but you really teach me very nicely. My whole life study in business studies, thats the reason i am very much weak in programming. Anyway thank you so much sir.
  7. I tried this and come out like this, I think my problem is solved though its not very precise way, It can be write in more better way. <!DOCTYPE html> <html> <body> <?php for ($x = 0; $x <= 42; $x++) { if($x == "5" || $x == "10" || $x == "15" || $x == "20" || $x == "25" || $x == "30" || $x == "35" || $x == "40" || $x == "45") { echo "<b>I love you</b> <br>"; } echo "The number is: $x <br>"; } ?> </body> </html>
  8. suppose i want to loop number like this (1.2.3.4.5.....100), but after every 5 number i want to echo another word and after that continue to the first loop: example: 1.2.3.4.5.W.6.7.8.9.10.W.11.12.13.14.15W.... can anyone help me about this. Thanks in advance
×
×
  • 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.