appending information

  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 20th, 2004, 2:26 am

morning all,

I'm writing a PHP/MySQL call logging system, for IT requests
I'm doing it so that I, as the administrator, can update with comments of my own. However, I'd like to be able to retain all previous comments I may have added, along with a timestamp for each comment.

My question is, can I do this inside of 1 field, effectively needing to append the data to previous entries?

Tommy :?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 20th, 2004, 2:26 am

  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post July 20th, 2004, 2:49 am

1 field inside the db?

get your field data your usual way, then do:
$old_data .= $new_data;

and write your new $old_data field back to the DB. You might want some form of separator in there, so $old_data .= '|'.$newdata; or some such
http://www.disabo.com
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 20th, 2004, 2:54 am

1 field inside the database, yes
ideally, I would like end of 1 entry, then say a couple of CR's and then a timestamp, and other CR and then my new entry. look something like this

4/6/2004 - 13:00
user looked clueless

4/6/2004 - 13:05
user confirmed as management - cluelessness confirmed :D

is that any clearer? sorry if not
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post July 20th, 2004, 3:01 am

it's still pretty much the same thing, just do:
PHP Code: [ Select ]
 
$thetime = date("m/d/y H:i", time());
 
$old_data .= "\n\n$thetime\n$comment";
  1.  
  2. $thetime = date("m/d/y H:i", time());
  3.  
  4. $old_data .= "\n\n$thetime\n$comment";
http://www.disabo.com
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 20th, 2004, 3:04 am

thats great, its pretty much what I thought
I wasnt sure tho about whether or not I could use the \n inside the query string, but from what you're saying, its ok

Am I right in thinking that \n is treated as a new line if the query is inside double quotes?? otherwise inside ' - it is accepted as a literal character?
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post July 20th, 2004, 3:07 am

absolutely
http://www.disabo.com
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 20th, 2004, 3:10 am

excellent, some of this is starting to sink in at last!! :lol:

cheers for your help on this
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 21st, 2004, 5:45 am

I'm having trouble getting this to work, the MySQL database is displaying it in 1 line.

My code is like this

Code: [ Select ]
$newdata = "\n\n$sesstime\n$updateresponse";
                            
$requpdate = "UPDATE problems SET requestResponse='$newdata' WHERE callReference='$callReference'";

$updateresult = mysql_query( $requpdate );
  1. $newdata = "\n\n$sesstime\n$updateresponse";
  2.                             
  3. $requpdate = "UPDATE problems SET requestResponse='$newdata' WHERE callReference='$callReference'";
  4. $updateresult = mysql_query( $requpdate );


Although I'm including the \n - isnt this just for display purposes, MySQL cannot store the line breaks can it?
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post July 21st, 2004, 2:19 pm

is the type for that field set to "Text" as is should be, or varchar like most default to?
http://www.disabo.com
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 21st, 2004, 2:30 pm

it is actually set to BLOB, isnt that the same as TEXT?
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post July 21st, 2004, 2:33 pm

BLOB is Binary
http://www.disabo.com
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 21st, 2004, 2:36 pm

so if I change it to text, it should be ok??

when/what should I use binary for?
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post July 21st, 2004, 2:41 pm

use binary for storing images, apps, anything not flat text
http://www.disabo.com
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 21st, 2004, 2:56 pm

so a TEXT field will definitely recognise the line breaks?

sounds good, but how do I attach a file to it, and more to the point, retrieve it?
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post July 21st, 2004, 3:10 pm

attach a file to which? you don't have to attach a file for what you want.

as to retrieving the data, you shouldn't need to change anything, just do a
SELECT whatever FROM wherever. That is, of course, unless the retrieval scripts does a binmode on the field to read it - in which case you'll probably want to change that.

this may seem a bit of a delayed question, but is there a specific reason you're not using separate rows for your entries? Doing so would allow you to say, pull up all comments made by such and such user, pull up all comments on such and such date, pull all comments that include the word "pattern" and so on.

*edit*
I guess all I'm saying in the above is that if all you want to do is write a little data every now and then, you could just drop your comments into a file on the HD and read that instead of using the database, as the latter is kind of like using an AH-64 to kill a mosquito
http://www.disabo.com
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 21st, 2004, 3:10 pm

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 269 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.