Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Location
    In my house...
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I use $_GET to put a variable in the URL?

    Hi, I'm trying to make a preview/view page for my layout database using frames, php, and mysql. How can I make it so that the URL will be http://www.mysite.net/view.php?id=#, while the id # corresponds to the id of the layout/database row? This is what I have so far, without any $_GET variables or whatever.

    PHP Code:
    <?php

    $hostname
    ='localhost';
    $user='hello';
    $pass'world';
    $dbase='yay';

    $connection mysql_connect("$hostname" "$user" "$pass") or die ("Can't connect to MySQL");
    $db mysql_select_db($dbase $connection) or die ("Can't select database.");

    $q "select * from newlayout";
    $resultmysql_query($q$connection) or die
    (
    "Could not execute query : $q." mysql_error());

    while (
    $row=mysql_fetch_array($result))
    {
        
    $id=$row["id"];
        
    $title=$row["title"];
        
    $icon=$row["icon"];
        
    $layoutid=$row["layoutid"];
        
    $dateadded=$row["dateadded"];
        
    $series=$row["series"];
        
    $layouttype=$row["layouttype"];
        
    $email=$row["email"];
        
    $name=$row["name"];
        
    $indexurl=$row["indexurl"];
        
    $downloadurl=$row["downloadurl"];
    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
        <title>View Layout <?php echo "$layoutid"?> / <?php echo "$id"?> - <?php echo "$title"?> by <?php echo "$name"?></title>
        <link rel="stylesheet" href="http://www.mysite.net/style.css" type="text/css">
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <frameset rows="40,*"  frameborder="0" > 
      <frame name="topFrame" scrolling="no" noresize src="http://www.mysite.net/viewtop.php" >
      <frame name="mainFrame" src="<?php echo "$indexurl"?>"> 
    </frameset>
    <noframes></noframes>

    </html>
    <?php
    #end of while

    ?>
    $layoutid is a manual variable I made for the IDs... ignore it for now. So can anyone help?

  • #2
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Which url do you want to append the id to?

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this...

    <link rel="stylesheet" href="http://www.mysite.net/style.css?id=<?php echo $id ?>" type="text/css">

  • #4
    New Coder
    Join Date
    Feb 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a problem like his. It's for my comic script. How the hell will adding a style sheet solve anything?

  • #5
    New to the CF scene
    Join Date
    Aug 2006
    Location
    In my house...
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why a stylesheet? o.o

    URL... to append to? What does that mean? I want it so that when you go to view.php?id=# it will show the all the info I want that goes with the ID. The ID is the primary key, so it only needs the ID, correct?

  • #6
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In that case then you will want to do something like this.

    PHP Code:

    $q 
    "select * from newlayout where id='" $_GET['id'] . "'";
    $resultmysql_query($q$connection) or die
    (
    "Could not execute query : $q." mysql_error());

    while (
    $row=mysql_fetch_array($result))
    {
    etc
    Just use the ID from the get variable to define your query.

  • #7
    New to the CF scene
    Join Date
    Aug 2006
    Location
    In my house...
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ^_^ Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •