SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict SniperUK's Avatar
    Join Date
    Jul 2000
    Location
    UK
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is it possible to turn a script like index.php?id=main
    into a database? so i could add my id'd through a form!
    and then all i need to do is link to it.

    I mean how could i avoide puting alot of includes like this into a simple code?
    <?
    if ($id == "Main") { include("news.php3"); }
    if ($id == "ScreenSavers") { include("screensavers.php3"); }
    if ($id == "WallPapers") { include("wallpapers.php3"); }
    if ($id == "Skins") { include("winampskins.php3"); }
    ?>


    I got this reply but i hope u can help me out more!

    Simply replace all your includes with one MySQL Query:

    Create a table called 'pages' with fields:
    ID - varchar(20)
    PageTitle - varchar(50)
    Content - blob

    You can also add datemodified, editor, etc if you want to get fancy.

    Then, in your index.php:



    code:--------------------------------------------------------------------------------<?
    /* mysql connect stuff here, select db... */
    $result = mysql_query("SELECT * FROM pages WHERE ID = '$id'") or die(mysql_error());
    $title = mysql_result($result,0,"PageTitle");
    $content = mysql_result($result,0,"Content");

    /* here i output everything, echo $title; etc */
    ?>

    u post a sample script which i am sure
    i can work with! either the code or the link to a zip file would be great! Thanks I hope u can help


    Thanks Alot

  2. #2
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    District of Columbia
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not too familiar with PHP, but it seems to me that what you are asking has been answered. All that does is based on the id passed in the URL the sql statement queries the DB, then the results are output on a page. I hope I understood your question corretly, if not, please let me know what I missed!

    Julie

  3. #3
    SitePoint Addict SniperUK's Avatar
    Join Date
    Jul 2000
    Location
    UK
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was after for someone who know's php to do me example which i could work with.

  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Luqman,

    The code is basically written in the answer you quoted above. If you still need help, it's because you are not trying to learn on your own.

    I like to think that I'm a helpful person, but I'd expect to be paid to write your code for you.

    Check out my article: http://www.webmasterbase.com/article.php?aid=228&pid=0. It'll teach you everything you need to know and much more!
    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

  5. #5
    SitePoint Addict SniperUK's Avatar
    Join Date
    Jul 2000
    Location
    UK
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am likely to learn more with example's...


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
  •