SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast Superteddy's Avatar
    Join Date
    May 2005
    Location
    Trondheim
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    view.php with url

    i have a view.php file that opens a new page from a query.

    the url then becomes something like /view.php?=id1 well almost like that i think.

    my problem is when im trying to get make a query for that spesific id. what i mean is that if im calling id 1 i want to get the name from that id. and if i call id 2 i want that name.

    anyone know where i can find some info on this ?

    cheers,

  2. #2
    SitePoint Enthusiast linkstraffic's Avatar
    Join Date
    Oct 2005
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean, if you have view.php?id=1 then you wanna retrieve the number 1 ?
    you can get it from the variable stored inside $_GET['id']

  3. #3
    SitePoint Enthusiast Superteddy's Avatar
    Join Date
    May 2005
    Location
    Trondheim
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well let me see if i cant clear this up a bit ( since im online again now )

    PHP Code:
    This is view.php

    <?
      
    include("include/header.php");  
    ?>

    <div id="primary" class="single-post">
            <div class="inside">
                
                <div class="primary">
                    <h1><? include("include/raidname.php"); ?></h1>
                    
                </div>
                <hr class="hide" />
                <div class="secondary">
                    <h2>Detailed Raid Information</h2>
                    <div class="featured">
                        <dl>
                            <dt>Date:</dt>
                            <dd>$date</dd>
                        </dl>
                        <dl>
                            <dt>Time:</dt>
                            <dd>$time</dd>
                        </dl>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    <?
    include("include/sidebar.php");
    include(
    "include/footer.php");
    ?>
    PHP Code:
    This is the /include/raidname.php 

    <?
    $query 
    "SELECT raidID, raidName from raid";
    $result mysql_query$query );
    if (!
    $result)
    {die (
    "Could not query the database: <br />"mysql_error());}
    while (
    $row mysql_fetch_array($result)){
    $Name $row["raidName"];
    $id $row["raidID"];
    echo 
    $Name";
    }
    ?>
    i cant get functions to work so im using includes for the stuff i need, yes i know its a mess but i really the only way i know i can get it to work..

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2006
    Location
    Closer than you think
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is view.php

    PHP Code:


    <?

    $id 
    $_GET['id'];

    $query "SELECT raidName FROM raid WHERE raidID = $id";
    $result mysql_query$query );
    $row mysql_query_row($result);
    $Name $row[0];

      include(
    "include/header.php");  
    ?>

    <div id="primary" class="single-post">
            <div class="inside">
                
                <div class="primary">
                    <h1><? echo $Name?></h1>
                    
                </div>
                <hr class="hide" />
                <div class="secondary">
                    <h2>Detailed Raid Information</h2>
                    <div class="featured">
                        <dl>
                            <dt>Date:</dt>
                            <dd>$date</dd>
                        </dl>
                        <dl>
                            <dt>Time:</dt>
                            <dd>$time</dd>
                        </dl>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    <?
    include("include/sidebar.php");
    include(
    "include/footer.php");
    ?>
    Make sure it's /view.php?id=1 not /view.php?=id1

  5. #5
    SitePoint Enthusiast Superteddy's Avatar
    Join Date
    May 2005
    Location
    Trondheim
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hm that didnt work


    Fatal error: Call to undefined function mysql_query_row() in C:\Programfiler\xampp\htdocs\loottool\view.php on line 8

    PHP Code:
    <?
      
    include("include/header.php");  

    $id $_GET['id'];

    $query "SELECT raidName FROM raid WHERE raidID = 1";
    $result mysql_query$query );
    $row mysql_query_row($result);
    $Name $row[0];


    ?>

    <div id="primary" class="single-post">
            <div class="inside">
                
                <div class="primary">
                    <h1><? echo $Name?></h1>
                    
                </div>
                <hr class="hide" />
                <div class="secondary">
                    <h2>Detailed Raid Information</h2>
                    <div class="featured">
                        <dl>
                            <dt>Date:</dt>
                            <dd>$date</dd>
                        </dl>
                        <dl>
                            <dt>Time:</dt>
                            <dd>$time</dd>
                        </dl>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    <?
    include("include/sidebar.php");
    include(
    "include/footer.php");
    ?>

  6. #6
    SitePoint Zealot
    Join Date
    Jul 2006
    Location
    Closer than you think
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here a typo

    PHP Code:
    <?
      
    include("include/header.php");  

    $id $_GET['id'];

    $query "SELECT raidName FROM raid WHERE raidID = 1";
    $result mysql_query$query );
    $row mysql_fetch_row($result);
    $Name $row[0];


    ?>

    <div id="primary" class="single-post">
            <div class="inside">
                
                <div class="primary">
                    <h1><? echo $Name?></h1>
                    
                </div>
                <hr class="hide" />
                <div class="secondary">
                    <h2>Detailed Raid Information</h2>
                    <div class="featured">
                        <dl>
                            <dt>Date:</dt>
                            <dd>$date</dd>
                        </dl>
                        <dl>
                            <dt>Time:</dt>
                            <dd>$time</dd>
                        </dl>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    <?
    include("include/sidebar.php");
    include(
    "include/footer.php");
    ?>

  7. #7
    SitePoint Enthusiast Superteddy's Avatar
    Join Date
    May 2005
    Location
    Trondheim
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hm.. this helps to narrow it down to one of the raidName's but it dosnt change when i go to another page..

  8. #8
    Made with a Mac! philm's Avatar
    Join Date
    Sep 2001
    Location
    Portsmouth, UK
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The query is set to retrieve raidID 1 is why. The query needs to change back to '$id' to pull the correct value from the URL...

  9. #9
    SitePoint Zealot
    Join Date
    Jul 2006
    Location
    Closer than you think
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $query "SELECT raidName FROM raid WHERE raidID = $id"


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
  •