|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Comments
i have a news script i created, however i want to add comments... on top of that i have another problem...i want only ppl who are logged in to post comments...and it takes the name of the person as the poster...any suggestions?
|
|
#2
|
|||
|
|||
|
You could integrate it with some forum software... like Invision Power Board www.invisionboard.com
|
|
#3
|
|||
|
|||
|
What you would need to do is store their username either in a cookie or in a SESSION when they login, and then use the value that's stored as the username for the comments...
There's a nice article on here titled PHP Authentication 101, from Havard Lindset. I suggest checking it out, as it's a really easy read! Hope that sheds some light...
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#4
|
|||
|
|||
|
many thanks...ive already solved it =]
|
|
#5
|
|||
|
|||
|
whats the command to display date not just time...like...Tuesday January o1 instead of 02-02-01...with mysql ive looked at the mysql site but cant find it...any suggestions
|
|
#6
|
|||
|
|||
|
Are you wanting to format the date using MySQL or PHP? I believe MySQL's function is DATE_FORMAT:
Code:
DATE_FORMAT(date_field, '%W, %M %e, %Y'); HTH! |
|
#7
|
|||
|
|||
|
put that in mysql or when im selecting my rows from the table?
|
|
#8
|
|||
|
|||
|
When you're selecting from your tables...
|
|
#9
|
|||
|
|||
|
let me give it a try
|
|
#10
|
|||
|
|||
|
hmm i think im placing it wrong....can u explain just a bit more of where to put it =]
|
|
#11
|
|||
|
|||
|
Sure, it goes directly in your SQL statement:
PHP Code:
HTH! |
|
#12
|
|||
|
|||
|
PHP Code:
comes out blank ... maybe because i already formated it in mysql...did the 0000-00-00 00:00:00 thing =[...anyway to do it with sql? |
|
#13
|
|||
|
|||
|
Hmmm... That's weird... What if you try enclosing your date field in single quotes:
Code:
$query = "SELECT id,title, news, name, country, grade, DATE_FORMAT('date', '%W, %M %e, %Y') FROM news ORDER BY id DESC LIMIT 10";
Here's the link to the MySQL manual: http://www.mysql.com/doc/en/Date_an..._functions.html |
|
#14
|
||||
|
||||
|
You shouldn't need to enclose the field name in quotes. I think the issue is just that you've got an invalid date. I inserted "0000-00-00 00:00:00" and NOW() into a date field and selected date_format(field,'%W %M %e %Y') from the table. For the 0000-00-00 entry, it returned null. The other returned correctly. So make sure you've got a valid date and try the code again.
|
|
#15
|
|||
|
|||
|
i made another date field in the db ....
CREATE TABLE news ( id INT (11) not null AUTO_INCREMENT, title VARCHAR (50), news TEXT , name VARCHAR (50) , country VARCHAR (50) , grade VARCHAR (50) , date DATE , PRIMARY KEY (id) ); in the date i have 2003-09-19 in my sql i have same as above and i still cannot get it to display it doesnt display anything now =[ |
|
#16
|
||||
|
||||
|
Weird. Works like a charm for me:
Code:
mysql> select * from news; +----+-------+------+------+---------+-------+------------+ | id | title | news | name | country | grade | date | +----+-------+------+------+---------+-------+------------+ | 1 | NULL | NULL | NULL | NULL | NULL | 2003-09-19 | +----+-------+------+------+---------+-------+------------+ 1 row in set (0.00 sec) mysql> SELECT id,title, news, name, country, grade, DATE_FORMAT(date, '%W, %M %e, %Y') FROM news ORDER BY id DESC LIMIT 10; +----+-------+------+------+---------+-------+------------------------------------+ | id | title | news | name | country | grade | DATE_FORMAT(date, '%W, %M %e, %Y') | +----+-------+------+------+---------+-------+------------------------------------+ | 1 | NULL | NULL | NULL | NULL | NULL | Friday, September 19, 2003 | +----+-------+------+------+---------+-------+------------------------------------+ 1 row in set (0.00 sec) What os/mysql version are you running? Maybe there's something weird with the date_format() command on mysql for Windows or something? |
|
#17
|
|||
|
|||
|
just incase you want to see my script here it is
http://bruski.hell-yeah.net/news.phps PHP version 4.3.3 MySQL version 4.0.15-standard Last edited by Bruski : September 19th, 2003 at 08:11 AM. |