Help-news updater

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • .::KoLe::.

    Help-news updater

    I will that with form send data to database, and then that data read from
    database.
    Example:
    Name: Kole
    Subject: Help
    Text: I need help, please help me!
    Than i press send and this data go to my database. And then I need read this
    data on my page that newest data go up(first)!
    Thank you all!

    --
    ..:: KoLe ::.
    izbri¹i "MAKNI" u mailu


  • Perttu Pulkkinen

    #2
    Re: Help-news updater

    > I will that with form send data to database, and then that data read from[color=blue]
    > database.
    > Example:
    > Name: Kole
    > Subject: Help
    > Text: I need help, please help me!
    > Than i press send and this data go to my database. And then I need read[/color]
    this[color=blue]
    > data on my page that newest data go up(first)!
    > Thank you all![/color]

    I think that first you should dig php manual in mysqlfunctions and some
    mysql guide. Although you can do this kind of simple thing without database
    too, using simple text files. But with database it is something like this
    but I DONT HAVE TIME to try and debug this!

    - first you need to create database with sql query :
    create database messages ( msg_id int(10) auto_increment, name char 100,
    subject char(150), text text);
    - then you need to create script that adds messages to database:
    - $conn = mysql_connect(. .......) or die("oh no");
    - $name = mysql_real_esca pe_str($_POST['name']);
    - $subject = mysql_real_esca pe_str($_POST['subject']);
    - $text = mysql_real_esca pe_str($_POST['text']);
    - $query = mysql_query("IN SERT INTO messages VALUES
    ('$name','$subj ect','$text')") or die("oh no");
    - then you need to create script that reads messages from database:
    - $query = mysql_query("SE LECT * FROM messages") or die("oh no");
    - while($row = mysql_fetch_obj ect($query)) { echo $row->name etc etc...}






    Comment

    • Perttu Pulkkinen

      #3
      Re: Help-news updater

      OKAY, litte more correct version (not 100%)

      - first you need to create database with sql query :
      create database messages ( msg_id int(10) auto_increment, name char 100,
      subject char(150), text text, time timestamp);
      - then you need to create script that adds messages to database:
      - $conn = mysql_connect(. .......) or die("oh no");
      - $name = mysql_real_esca pe_str($_POST['name']);
      - $subject = mysql_real_esca pe_str($_POST['subject']);
      - $text = mysql_real_esca pe_str($_POST['text']);
      - $query = mysql_query("IN SERT INTO messages VALUES
      (NULL, '$name','$subje ct','$text')") or die("oh no");
      - then you need to create script that reads messages from database:
      - $query = mysql_query("SE LECT * FROM messages ORDER BY time desc") or
      die("oh no");
      - while($row = mysql_fetch_obj ect($query)) { echo $row->name etc etc...}


      Comment

      • Perttu Pulkkinen

        #4
        Re: Help-news updater

        Even more correct version (not 100% :-)

        - first you need to create database 'msg_dbase' with sql query :
        CREATE DATABASE msg_dbase;

        - THEN you need to create table 'messages' with sql query:
        CREATE TABLE messages ( msg_id int(10) auto_increment, name char 100,
        subject char(150), text text, time timestamp);

        - then you need to create script that adds messages to database:

        $conn = mysql_connect($ host, $username, $password) or die("oh no");
        mysql_select_db ('msg_dbase', $conn) or die("oh no");
        $name = mysql_real_esca pe_string($_POS T['name']);
        $subject = mysql_real_esca pe_string($_POS T['subject']);
        $text = mysql_real_esca pe_string($_POS T['text']);
        $query = mysql_query("IN SERT INTO messages VALUES
        (NULL, '$name','$subje ct','$text')") or die("oh no");

        - then you need to create script that reads messages from database:

        $conn = mysql_connect($ host, $username, $password) or die("oh no");
        mysql_select_db ('msg_dbase', $conn) or die("oh no");
        $query = mysql_query("SE LECT * FROM messages ORDER BY time desc") or
        die("oh no");
        while($row = mysql_fetch_obj ect($query))
        {
        echo "<h2>".html_spe cial_chars($row->subject)."</h2>";
        echo "<h3>Writte n by ".html_special_ chars($row->name)."</h3>";
        echo "<p>".html_spec ial_chars($row->text)."</p>";
        }



        Comment

        Working...