Jump to content

[SOLVED] data from database lag


bluebyyou

Recommended Posts

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

try this please.

if ($_GET['show'] == 1){$query = "SELECT * FROM `piccomment` WHERE `picid` = '$pictureid' ORDER BY `commentdatetime` DESC ";}
if ($_GET['show'] != 1)  {$query = "SELECT * FROM `piccomment` WHERE `picid` = '$pictureid' ORDER BY `commentdatetime` DESC LIMIT 7 ";}
query_db($query);

Link to comment
Share on other sites

I take that back it works for every post after the first. The first post on a pic still doesnt show.

 

edit: I continued to try on other photos, and it is back to not showing the latest post at all.

 

 

I know this can work, Im sure theres a more elegant solution especially using ajax or something, but I think what I have is close to working, or should I be going about this a different way?

Link to comment
Share on other sites

U can use but depend on your mysql version.

Order by is the way to put the latest one on top but here u r using version 4.1.22 so may be still the mysql team did not fix it for version 4.1.22, But later versions works fine for order by.

Link to comment
Share on other sites

 

are you posting the pic to another file.php or the same file.php

Im not sure what you are asking redarrow?

 

U can use but depend on your mysql version.

Order by is the way to put the latest one on top but here u r using version 4.1.22 so may be still the mysql team did not fix it for version 4.1.22, But later versions works fine for order by.

Unfortuneately I have no control over my verson

Link to comment
Share on other sites

Here is the comment insert form

 

<?php
include("db_connect.php");

$striptext = stripslashes(strip_tags($_POST['text'])); 
$finaltext = mysql_real_escape_string($striptext); 
$now = date("Y-m-d H:i:s");
$query = "INSERT INTO piccomment (picid,posterid,commentdatetime,postername,comment) 
	  VALUES ('$_POST[picid]','$_SESSION[user]','$now','$_POST[postername]','$finaltext')";
query_db($query);
$getid = $_POST['picid'];

header("location:pic.php?id=$getid");

?>

 

 

Link to comment
Share on other sites

try this ok.

<?php

$picid=addslashes($_POST['picid']);
$users=addslashes($_SESSION['user']);
$users=addslashes($_POST['user']);
$postername=addslashes($_POST['postername']);

$striptext = stripslashes(strip_tags($_POST['text'])); 
$finaltext = mysql_real_escape_string($striptext); 
$now = date("Y-m-d H:i:s");
$query = "INSERT INTO piccomment (picid,posterid,commentdatetime,postername,comment) 
	  VALUES ('$picid','$user','$now','$postername','$finaltext')";
query_db($query);
$getid = $_POST['picid'];

header("location:pic.php?id=$getid");

?>

Link to comment
Share on other sites

updated version

 

<?php

$picid=$_POST['picid'];
$users=$_SESSION['user'];
$users=$_POST['user'];
$postername=$_POST['postername'];
$striptext = stripslashes(strip_tags($_POST['text'])); 
$finaltext = mysql_real_escape_string($striptext); 
$now = date("Y-m-d H:i:s");

if(isset($_POST['submitcomment'])){
$query = "INSERT INTO piccomment (picid,posterid,commentdatetime,postername,comment) 
	  VALUES ('$picid','$user','$now','$postername','$finaltext')";
query_db($query);
}

$getid = $_POST['picid'];

header("location:pic.php?id=$getid");

?>

Link to comment
Share on other sites

Here are my columns and data types

 

picindex                  int

picid                        int

posterid                    int

commentdatetime    datetime

postername            varchar

comment                text

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.