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

    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    32
    Rep Power
    15
    Hello,

    I'm having problems creating urls when taking info from a mySQL table.

    For example a table with user_id, name, email and description. Then you've set up a template there this information will be displayed.

    You have this information in the database:
    user_id: 1
    name: myname
    email: myname@myemail.com
    description: information about me

    Now in this template it should create an URL for this info that looks something like: www.myhost.com/page.php3?id=1

    when they click on this link, another page will popup by using a second template with the name, email, description etc.


    Does anyone know how to write this?
    I appreciate all your help, haven't found any good tutorials for this kind of thing.

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

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    it can be done very easily..

    First you dispaly all the user_ids..
    when somebody clicks on that id show the details of that id..

    it should be:

    allids.php3
    <?
    $con=mysql_connect('localhost','yourusername','yourpassword');
    //connect database
    mysql_select_db("Yourdatabasename",$con);
    //select database
    $result=mysql_query("SELECT * FROM tablename",$con);
    //issue query..

    if (mysql_num_rows($result)>0){

    echo "All the IDS";
    do{
    echo "<a href="showpopup.php?id=".rows["user_id"]."" target="_blank">".rows["user_id"]."</a>n";
    //print all the ids

    }while($rows=mysql_fetch_array($result));
    }else{
    echo "No Result";
    exit;
    }
    ?>
    In your showpopup.php just write the following..

    <?
    $con=mysql_connect('localhost','yourusername','yourpassword');
    mysql_select_db("Yourdatabasename",$con);

    $result=mysql_query("SELECT * FROM tablename where user_id='$id'",$con);

    if (mysql_num_rows($result)==1){
    //show him only that record..

    echo "UserID :<a href="show popup.php?id=".rows["user_id"]."">".rows["user_id"]."</a>n";
    echo "Name : ".rows["name"];
    echo "Email : ".rows["email"];
    echo "Description: ".rows["description"];
    }else{
    echo "No Result";
    exit;
    }
    ?>


    just modify the above example as per your requirment..



    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. Check MySQL Version thru PHP
    By wolftrap1 in forum PHP Development
    Replies: 2
    Last Post: February 11th, 2004, 08:51 PM
  2. Replies: 5
    Last Post: February 11th, 2004, 02:18 AM
  3. Replies: 0
    Last Post: February 10th, 2004, 11:44 PM
  4. Replies: 0
    Last Post: January 30th, 2004, 01:22 PM
  5. PHP 5 (MYSQL vs. SQLite)
    By ignition in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 12:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo