SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member Cas's Avatar
    Join Date
    Jun 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What are the popular methods to add content?

    What are the popular methods to add
    content on the fly? Being new to all this
    and having gone through and
    enjoyed Kevin Yanks excellent
    tutorial I am definitely hooked,
    and am starting to come up
    with my own ideas.

    I just want some opinion and
    maybe a little advice

    I've got 3 tables handling content:
    pages, page_catergories and page_lookup, (sound familiar).

    My index page has already got tables
    laid out and I wanted to fill them so
    I used this. The $id changes to suit what content I want where.

    PHP Code:
     $id 3;

     
     
    // Find the text category that belongs in the page area ($id) 
     
    $result mysql_query("SELECT * FROM 
     page_lookup WHERE CID = \"
    $id\""); 
     
    if (!
    $result) {
    echo(
    "<P>Error performing query: " .
     
    mysql_error() . "</P>");
     exit();
     }
      
    $row mysql_fetch_array($result) ; 
         
    $pid $row["PID"];

    //select the corasponding text from the pages table

    $result mysql_query("SELECT * FROM pages WHERE ID = \"$pid\"");
    if (!
    $result) {
    echo(
    "<P>Error performing query: " .
     
    mysql_error() . "</P>");
     exit();
     }
        
    $arow mysql_fetch_array($result) ;
            
    $text $arow["PageText"];
            
    $date $arow["PageDate"];
            echo 
    "<p>$text</p>";
            echo 
    "<p>$date</p>";
    ?> 
    I've figured out for myself that this is
    perhaps not the best way to do it as
    I am restricted to the number of tables
    and it makes for a pretty static page.
    Ok for an index though.
    I was wondering what was the normal
    system for adding content on the fly.

    I have adapted the K.Y. tutorial for
    the content management system
    side of things too. Unfortunately it
    does not work like I expected.
    No errors, it just runs and runs
    and runs..with no output

    PHP Code:
    <?php
    <TABLE BORDER=1>
    <
    TR>
    <
    TH>Text</TH><TH>Date page Crated</TH>
    <
    TH>Section Name</TH>
    <
    TH>Section Description</TH>
    </
    TR>



    //Grab data from the pages table 
    //with pre formulated Select statement  
    //rom Kevin Yank tutorial
    $pages mysql_query($select $from $where);
       
    //Grab data from the content 
    //catogory table
    $conts mysql_query(SELECT NameDescription FROM page_catergories); 

    array1 mysql_fetch_array($pages);
    array2 musql_fetch_array($conts);

    while (
    $merged array_merge(array1array2)); {

    //Line up data so page text and  date and page Name
     //Descripton are in rows
    //Description could inclued url to the page content or an 
    //image of the page/page area.      

      
    echo("<TR>\n");
      
    $id $cont["ID"];
      
    $pagetext $merge["PageText"];
      
    $pagedate $merge["PageDate"];
      
    $sectname $merge["Name"];
      
    $sectdesc $merge["Description"];
          echo(
    "<TD>$pagetext</TD>\n");
        echo(
    "<TD>$pagedate</TD>\n");
          echo(
    "<TD>$secname</TD>\n");
        echo(
    "<TD>$sectdesc</TD>\n");


    echo(
    "<TD>[<A HREF='editcont.php?id=$id'>Edit</A>|".
    "<A HREF='deletecont.php?id=$id'>Delete</A>]</TD>\n");
    echo(
    "</TR>\n");
    }
    ?>
    I'm not sure if anyone can tell from
    this what I am trying to do.
    I'm just trying to combine two
    tables to give a single output in one table.
    This way anyone wanting to select
    and edit any particular content,
    they will know exactly
    what part of the site they are editing.
    I could, perhaps even include
    images of the area they
    are about to update edit.
    (Pie in the sky I hear you say.)


    I'm also not sure if this post is too long.
    Any comments would be greatly
    apriciated, as would some tips
    on any good books/articles
    accociated with the above topics.
    Thanks in advance
    Cas.



    Last edited by Cas; Jul 18, 2001 at 11:11.
    "Tell me and I will forget , show me and I'll learn.
    Involve me and I will remember. " Confucius.

  2. #2
    code addict Abstraction's Avatar
    Join Date
    Apr 2001
    Location
    Des Moines, IA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look into the INNER JOIN function.

    Here's an example of the syntax taken from DevGuru.


    SELECT Employee.Username
    FROM Employee INNER JOIN Project
    ON Employee.EmployeeID = Project.EmployeeID
    WHERE Employee.City = 'Boston'
    AND Project.ProjectName = 'Hardwork';


    Hope this helps.

  3. #3
    SitePoint Member Cas's Avatar
    Join Date
    Jun 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had a play with the code you suggested, however it seems that it requires two alike fields from the two tables. Also if my above code was to work, the way it is, there is no guarantee that the two tables will align exactly as they are supposed to when converted to a HTML table.
    The pages table is going to be updated constantly whereas the catagory table is pretty mutch static. I need to find a way of linking the text from the pages table with text from the content catergory.
    (I'm still working on it)
    Cheers
    Cas.
    "Tell me and I will forget , show me and I'll learn.
    Involve me and I will remember. " Confucius.


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
  •