Create post loop for html based site

Discussion in 'PHP' started by Philip C. Ngo, Aug 2, 2014.

  1. #1
    I googeled about loop but couldn't find out any code to create loop for my first page like WordPress my template has some php code log in-register -search and some other stuff ,
    Now I really want to now which class in php is Appropriate to create loop in html based template?

    should I use database for it?
     
    Philip C. Ngo, Aug 2, 2014 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,553
    Best Answers:
    123
    Trophy Points:
    665
    #2
    WordPress' loop is specific to that operating system. In this day and age I'd question why anyone starts a site without some sort of cms driving it.

    and yes, you'll need a database for your site, regardless of the approach. Your host will provide one free. What goes in it is up to you.
     
    sarahk, Aug 2, 2014 IP
  3. Philip C. Ngo

    Philip C. Ngo Member

    Messages:
    85
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #3
    What I'll want to make is :
    using TinyMCE to edit content daily and make a post ,all my post sorted in first page with page navigation similar to Current cms's Wordpress-Joomla-Drupal .
    my client doesn't want to use any cms's so :
    How to make loop for content without using cms just with php snippets?
     
    Philip C. Ngo, Aug 2, 2014 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,553
    Best Answers:
    123
    Trophy Points:
    665
    #4
    I think you need to dig deeper and find out what the objection is. Are they concerned it will be hard to use etc? Expensive?

    They need to realise that a custom built site is like reinventing the wheel and not cost effective - and they need to know that you might be the right guy for a CMS job but not for a coding-from-scratch job.

    Personally, any client who won't take basic technical advice is likely to be a nightmare on everything else.
     
    sarahk, Aug 2, 2014 IP
  5. Philip C. Ngo

    Philip C. Ngo Member

    Messages:
    85
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #5
    Do You think make a loop with php is harder than Bicker with Consumer.
    there isn't any solution to me?
    Oh I started a hopeless task I don't think so, just need to php expert helps with max 30 line :if else if while end if
     
    Philip C. Ngo, Aug 2, 2014 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,553
    Best Answers:
    123
    Trophy Points:
    665
    #6
    Not bicker, give professional advice.
    You don't have to take every job that comes your way.

    if the problem is really how to use tinymce then check their website for other implementation examples.

    a worthy alternative is ckeditor
     
    sarahk, Aug 2, 2014 IP
  7. Philip C. Ngo

    Philip C. Ngo Member

    Messages:
    85
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #7
    I worked with text editors for 3 years but php was painful to me
     
    Philip C. Ngo, Aug 2, 2014 IP
  8. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #8
    If you don't know how to code a simple cms in your chosen web programming language why the hell are you selling your services to a customer?
    The approach is gonna be riddled with security holes, bad coding and potential problems.
    Most, if not all, of these would be negated if using something like WordPress or similar.
     
    PoPSiCLe, Aug 3, 2014 IP
    sarahk likes this.
  9. Philip C. Ngo

    Philip C. Ngo Member

    Messages:
    85
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #9
    I'm not supposed to know everything , I can create WordPress theme and code editing .but the common problem is customer want's things which are challenge with border of your knowledge and it doesn't matter, We should learn solve their problems & Demands.We don't speak about My abilities......
    How to make ...loop in a Section Just this, any videos or links and Tutorials can be worthy and Helpful
     
    Philip C. Ngo, Aug 3, 2014 IP
  10. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #10
    a loop goes something like this:
    
    $stmt = $dbh->prepare("SELECT * FROM cms_content WHERE <criteria goes here>");
    if ($stmt->execute()) {
      while ($row = $stmt->fetch()) {
        $heading = $row['heading'];
        $article = $row['article'];
        echo '<h3>'.$heading.'</h3>
                     <article>'.$article.'</article>';
       }
    } else {
       //error-catching goes here
    }
    
    Code (markup):
    And that is basically it. Now, if that is beyond your comprehension, I still think you should do some reading up on PHP, because this is basic (really, really, REALLY basic stuff). I suggest codeacademy.com - they have a ver simple PHP-tutorial, which will give you some starting-points
     
    PoPSiCLe, Aug 3, 2014 IP
  11. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,553
    Best Answers:
    123
    Trophy Points:
    665
    #11
    Don't try to make a loop - it's an odd thing that only wordpress does. You are unlikely to find a tutorial on how to do it.

    I've implemented text editors in sites I've needed to put a backend onto and they're dead simple if you follow the examples.

    Edit: I've just seen @PoPSiCLe's response and he may be on the right track. I may have got distracted by the whole loop thing, when really it's just a while.

    However if you are editing a single page you should really be selecting just the one record - no while needed.
     
    sarahk, Aug 3, 2014 IP
  12. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #12
    I was under the impression he wanted a way to fetch the posts written in the editor, not edit the actual posts, but I might be mistaken.
     
    PoPSiCLe, Aug 3, 2014 IP