PHP Help

Soldato
Joined
11 Apr 2003
Posts
4,216
Location
Notts
Hi all, I have my website, and rather than using a pre made thing like wordpress I have made my own site. However I have hit a wall, I want the following to happen, but do not know how/have not been able to implement it:

* On main page, display a preview of XX words for a database entry.
* Supply a link so it goes, text...*Click for full article* which once clicked, loads the full entry from the database.
* Also have a comment box which appear on loading the full entry, and load the comments for the specific article.

Currently I just have my page, with full articles on.

If someone could help me create what I want. I would be very thank full :)

Thanks,
Jcb33!
 
Haven't you posted this before?

1) substr()
2) Link to a different page which draws the database content based on id, page slug etc.
3) Have a comments table, and pull the comments based on the post id, set up as a remote key

No offense but it doesn't seem as if you're cut out to making a fully-fledged CMS, in regard to the basic logic and knowledge required for the above three points. Perhaps code some smaller scripts and build foundation logic, relying on a pre-made CMS for the time being?
 
No offense but it doesn't seem as if you're cut out to making a fully-fledged CMS, in regard to the basic logic and knowledge required for the above three points. Perhaps code some smaller scripts and build foundation logic, relying on a pre-made CMS for the time being?

whilst I can see where you're coming from, that does come off a little harsh - i mean, everyone has to start somewhere, and it's pretty odd to get the logic of some things when you're just starting out - I had a really tough time trying to figure some stuff out, and I still do every now and again - at least he's not asking people to do stuff for him!

with regard to the original query - as psyreen said, you'll be needing substr to display the preview text from your article. If you've used html in it, you may want to strip_tags() so that html tags don't count towards the string you're cutting up - also, if you didn't do it on the way in to the database (which would probably be better), use htmlentities so you don't get any encoding anomalies/validation errors.

for your link, just generate a normal link to something like article.php, where you will grab information out of the database about an article with a particular id, which is specified in the query string of the url.

and to display the article and comments on the same page, assuming that each comment is associated with an article in the database (ie, your comments table has an article_id (or similar) column), look up MySQL joins - you'll probably be specifically needing LEFT or NATURAL joins - this information ca be found on the mysql dev website
 
Back
Top Bottom