PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    php mysql gurus

    Share
    avatar
    intothefantasy

    Number of posts : 37
    Registration date : 2009-04-11

    php mysql gurus

    Post  intothefantasy on Mon Apr 13, 2009 3:39 pm

    i have create a simple news code...to show news..but the problem is i am showing all the news in database...this news program i would like to integrade with this login scritp...i need some help in showing only the 1st 5 latest news from db...

    Code:

    include("config.php");

           
            $result = mysql_query("SELECT * FROM news ORDER BY newsid DESC",$connect);

            while($myrow = mysql_fetch_array($result))
                {
               
                //begin of loop
                  //now print the results:
                  echo "<b>Title: ";
                  echo $myrow['title'];
                  echo "</b><br>On: <i>";
                  echo $myrow['dtime'];
                  echo "</i><hr align=left width=160>";
                  echo $myrow['text1'];
                  // Now print the options to (Read,Edit & Delete the news)
                  echo "<br><a href=\"read_more.php?newsid=$myrow[newsid]\">Read More...</a>
                    || <a href=\"edit_news.php?newsid=$myrow[newsid]\">Edit</a>
                    || <a href=\"delete_news.php?newsid=$myrow[newsid]\">Delete</a><br><hr>";
                   
                }
               
    ?>

    how do u show only the 1st 5 latest news from the db?
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: php mysql gurus

    Post  Linchpin311 on Mon Apr 13, 2009 4:47 pm

    try changing $result = mysql_query("SELECT * FROM news ORDER BY newsid DESC",$connect); to $result = mysql_query("SELECT * FROM news ORDER BY newsid DESC LIMIT 0,5",$connect);


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    intothefantasy

    Number of posts : 37
    Registration date : 2009-04-11

    Re: php mysql gurus

    Post  intothefantasy on Mon Apr 13, 2009 7:54 pm

    hmm seems it work...if i wanna replace the 0.5 with a var...how to put it?

    $result = mysql_query("SELECT * FROM news ORDER BY newsid DESC LIMIT '$abc'",$connect);


    like this?
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: php mysql gurus

    Post  Linchpin311 on Tue Apr 14, 2009 12:02 am

    well the first number means which record to start at (0 will start at the first record) and the second number tells mysql how many records to return. i dont know your plans but in the past i have put both in variables... and yes, just how you had it except dont put any quotes around the values of the limit. if you put quotes, it wont work.


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.

    Sponsored content

    Re: php mysql gurus

    Post  Sponsored content


      Current date/time is Sun Oct 22, 2017 4:55 pm