SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I'm now going ahead and creating my own CMS But, can I have a little help with creating a message from MySQL to get me started?

    How would I go about making a single php page that allows a message to be typed in, and then displayed on my main page? And, for the message to be editable, and the old message displayed in the text area?

    I just need a little bit of help to kick start me

    Gungey

  2. #2
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow... that little bit of code could be up to 1100 lines long! Each time you decide to do something like this it gets involved. Very few true content managament systems are really simple and short. They may be "simple" to people like freddydoesphp and TWT Commish, but to those of us who have been at it for less than a month....

    If you haven't already read Kevins tutorial read it!

    If you have, you should already have a prety good idea so..

    PHP Code:
    <?php
    $table 
    "yourtable";

    if(isset(
    $add)){

    echo(
    "<form action=\"$PHP_SELF\">
    <input type=\"hidden\" name=\"id\">
    <input type=\"text\" name=\"name\"><br>
    <input type=\"text\" name=\"zip\"><br>
    <input type=\"text\" name=\"city\"><br>
    <input type=\"submit\" name=\"submit\" value=\"Add\">"
    );

    }

    if(
    $submit == "Add"){

    $sql "INSERT INTO $table SET name = '$name', city = '$city', zip = '$zip'";

    if(!
    mysql_query($sql)){
    echo(
    "Database error");
    exit();

    } else {

    echo(
    "Entry Has Been Added");
    }
    }

    if(isset(
    $edit)){

    $sql "SELECT * FROM $table WHERE ID = '$id'";
    $result mysql_query($sql);

    while(
    $row mysql_fetch_array($result)){
    $id $row['id'];
    $name $row['name'];
    $zip $row['zip'];
    $city $row['city'];

    echo(
    "<form action=\"$PHP_SELF\">
    <input type=\"hidden\" value=\"
    $id\" name=\"id\">
    <input type=\"text\" value=\"
    $name\" name=\"name\"><br>
    <input type=\"text\" value=\"
    $zip\" name=\"zip\"><br>
    <input type=\"text\" value=\"
    $city\" name=\"city\"><br>
    <input type=\"submit\" name=\"submit\" value=\"Edit\">"
    );
    }
    }

    if(
    $submit == "Edit"){

    $sql "UPDATE $table SET name = '$name', city = '$city', zip = '$zipWHERE id '$id'";

    if(!mysql_query(
    $sql)){
    echo("
    Database error");
    exit();

    } else {

    echo("
    Entry Has Been Updated");
    }
    }

    $sql = "SELECT FROM $table";
    $result = mysql_query($sql);

    if(!result){
    echo("
    Problem with database");
    exit();

    } else {

    while(
    $row = mysql_fetch_array*$result)){

    echo("
    <a href=\"$PHP_SELF?edit=1&id=$id\">Edit</a> <a href=\"$PHP_SELF?delete=1&id=$id\">Delete</a><br> $name<br>$zip<br>$city<hr><p>");
    }

    }
    Ok.. I think I came pretty close on that one... and it's pretty short... but you get the idea... it should help you .

    God Bless
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Here's the tutorial of mine that exbabylon refers to:

    Building a Database-Driven Web Site using PHP and MySQL
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  4. #4
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys! That has been a big help


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
  •