#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    166
    Rep Power
    15
    An article publishing system I wish to develop has articles by category ("news", "faq", "opinion",) and each article then has a numeric id.

    I know how to do a simple "index.php?id=foo" -type query in PHP thus:

    1. URL is mysite.com/index.php?id=3
    2. PHP code is:
    $result = mysql_query("SELECT * FROM article WHERE id=$id",$db);
    3. The I format the results

    I am stuck with the PHP code and MySQL query for:

    mysite.com/index.php?category=name&id=foo

    (if that is how people would type it??)

    Code examples would be much appreciated.

    Thanks in advance,
    David
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    I am stuck with the PHP code and MySQL query for:

    mysite.com/index.php?category=name&id=foo

    (if that is how people would type it??)
    >>



    Yea,What you are doing correct now...(mysite.com/index.php?id=3).

    You have assaigned a id to category so it will fetch the record as per that id..


    <?

    $con=mysql_connect('localhost','username','password');
    //connection string

    mysql_select_db('dbname',$con);

    if(empty($id)){
    $id=1;
    //if the category is not selected then show first news(ie,default category).
    }

    $query="select * from tblname id=$id";

    $result=mysql_query($query,$con);
    //issue sql query

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

    //echo $row[0];
    //print the news...
    }
    ?>



    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    166
    Rep Power
    15
    Ok, thanks, except your example does not allow for the fact that someone may type:

    index.php?category=foo&id=3

    does it?

    Thanks David

    PS: Also, if someone types "FOO" rather than "foo", how do we allow for that (UPPER and lower case)

    Thank you

Similar Threads

  1. php/mysql Developer needed for online game
    By Lord Melo in forum Project Help Wanted
    Replies: 1
    Last Post: October 29th, 2003, 09:15 PM
  2. PHP/MySQL Application Design/Architecture Books
    By glambert in forum PHP Development
    Replies: 7
    Last Post: April 10th, 2003, 09:52 PM
  3. PHP/MySQL Issues... Please help.
    By misteraven in forum PHP Development
    Replies: 14
    Last Post: August 7th, 2002, 08:03 PM
  4. PHP/MySQL Backend
    By Cujo in forum PHP Development
    Replies: 4
    Last Post: May 15th, 2002, 08:00 PM
  5. Need Qualified PHP/MySQL Programmer
    By ITGL72 in forum PHP Development
    Replies: 0
    Last Post: February 18th, 2002, 11:47 AM

IMN logo majestic logo threadwatch logo seochat tools logo