Need This

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    code to create table
    Code:
    CREATE TABLE announcement (
    `id` int(4) auto_increament,
    `text` varchar(500) NOT NULL,
    `date` date,
    PRIMARY KEY(id)
    );
    then to add announcement, you can make form and post it to
    Code:
    <?php
    $text=$_POST['text'];
    $date=date("Y-m-d");
    mysql_query("INSERT INTO announcement SET tex='".$text."' ,date='".$date."' ");
    ?>
    and to show announcements

    Code:
    <?php
    $ann=mysql_query("SELECT text,date FROM announcement ORDER BY date desc,id desc");
    while($k=mysql_fetch_array($ann))
    {
    $text=$k[0];
    $date=$k[1];
    echo "<div style=\"border:2px solid #ff0000;\">";
    echo "$date<br />$text";
    echo "</div>";
    }
    ?>
    Follow me @ksg91 | My Blog: http://ksg91.com | Nokia Blog: http://NokiaTips.in

    Comment


      #17
      It works but the problem im haveing is it shows the whole text I only wana show a short descryption if you click on it you can read more.
      BakGat
      Code:
      class Counter {
      public:
        void Count();
        int  ReadDisplay();
      private:
        int  CurrentCount;
      };








      Back up my hard drive? How do I put it in reverse?
      My Community
      BakGat
      sigpic

      Comment


        #18
        then put like these to show all announcement with shrot descrition assuming that read_ann.php is page for showing specific full annoucment

        PHP Code:
        <?php
        $ann
        =mysql_query("SELECT id,text,date FROM announcement ORDER BY date desc,id desc");
        while(
        $k=mysql_fetch_array($ann))
        {
        $id=$k[0]
        $text=substr($k[1],0,50)."...";
        $date=$k[2];
        echo 
        "<div style=\"border:2px solid #ff0000;\">";
        echo 
        "$date<br />$text<br /><a href=\"read_ann.php?id=$id\">Read More</a>";
        echo 
        "</div>";
        }
        ?>
        and code for read.ann.php will be like this

        PHP Code:
        $id=$_GET['id'];
        $k=mysql_fetch_array(mysql_query("SELECT text,date FROM announcement WHERE id=$id"));
        $text=$k[0];
        $date=$k[1];
        echo 
        "<div style=\"border:2px solid #ff0000;\">";
        echo 
        "$date<br />$text<br />";
        echo 
        "</div>"
        Last edited by ksg91; 19.03.10, 14:16.
        Follow me @ksg91 | My Blog: http://ksg91.com | Nokia Blog: http://NokiaTips.in

        Comment

        Working...
        X