Results 1 to 2 of 2

Thread: Need PHP script help

  1. #1
    Join Date
    Aug 2017
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need PHP script help

    Hello, maybe anyone can help me? How to in this script set max 5 testimonials per page, only lasts testiomonials??

    PHP Code:
    <?php
    mysql_connect
    ('localhost''gultaisa_db''IJ0qAEZ8') or die("MySQL Error!<br>(".mysql_error().")<br>Could not proceed");
    mysql_select_db('gultaisa_db');

    $rowsPerPage 1//number of results you want to display 

    if(isset($_POST['submit'])){
      if(empty(
    $_POST['name']) || empty($_POST['comment'])) {
        die(
    "Forget to fill something in?");
      }
      
    $_POST['comment'] = addslashes($_POST['comment']);
      
    mysql_query("INSERT INTO `testimonials`
      (`name`,`text`,`norp`,`date`) VALUES ('"
    .$_POST['name']."', '".$_POST['comment']."', '".$_POST['norp']."', '".time()."')")or die("MySQL Error!<br>(".mysql_error().")<br>Could not proceed");
      
    header("Location: ".$_SERVER['PHP_SELF']);
    }

    $query mysql_query("SELECT * FROM `testimonials` ORDER BY `id`");
    $i 0;
    echo 
    "<h3>Atsiliepimai</h3><div style='width: 500px'>";
    while(
    $row mysql_fetch_assoc($query)){
      
    $i = ($i == 2) ? 1;
      
    $bg = ($i == 1) ? "background-color: lightgrey;" "background-color: #FFF;";
      echo 
    "
      <p style='"
    .$bg." margin: 0; padding: 5px 0 0 0; height: 100px; font-family: arial; border-bottom: 1px solid black'>
      &nbsp;&nbsp;&nbsp;&nbsp;<b>"
    .$row['name']." </b><br /><br />
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
    .$row['text']."
      </p>"
    ;
    }
    ?>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,372
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    I'm thinking:

    PHP Code:
    $query mysql_query("SELECT * FROM `testimonials` ORDER BY 'id' DESC LIMIT 5"); 
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •