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 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Location
    Mesa, Arizona
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    HTTP links from SQL varchar data

    Okay, so I am working on this new website to manage some things for an online game I play. I am brand new to PHP and I am having issues trying to make a link out of some SQL data.

    Basically, I have the first part of the link would be something like this: http://test.com/memberID=

    Then there is a form where people would enter their member ID in. And I want to take that entry and add it to the end of this text and make a link out of it.

    Hopefully that is descriptive enough. The data is being stored as an integer (not sure if this makes and difference). I also need to do this with some data that is stored as a varchar.

    Thanks for the help in advanced

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,492
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Do you need the ability for anyone to put ANY member ID in the URL?
    Or, do you need the ability to remember only the ID for the person using the game?

    Why don't use you PHP SESSIONS to remember who is using the game (the user ID)?
    Then you won't have to deal with the URL variable at all. It would be invisible to
    the user, and wouldn't show up on any browser URL history.

  • #3
    New to the CF scene
    Join Date
    Nov 2009
    Location
    Mesa, Arizona
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well, I just used memberID as an example. The game itself has an ID that goes at the end of the URL to display information about the persons account. And what I am creating isn't actually part of the game on the same domain. It is going to be a content management system for us to track certain things. So some how I need a way of taking some user inputted string and number and adding it to the end of a link in order to complete the link.

    Does that make sense?

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,492
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    So you are having trouble creating the URL with the variable,
    or trouble reading the URL with the variable?

    It's just too odd ...

    I think we're going to get stuck on not being able to see your code.
    You might have to hire someone to go into your files and figure it out.
    There's so much information we don't know about your scripts and website.

    =========

    Do you have a form where the user enters the ID that will be appended?
    Or do they enter the ID using their browser address bar?

    Can we see that?

    Can ANYONE enter it? Do they have to be logged in? (seems like it might be a security issue?)

    Is the resulting URL with the variable supposed to automatically display another page (a PHP redirect)?

    Are you going to be able to show us your website and files, or do we need to use some special psychic powers?



    .
    Last edited by mlseim; 11-03-2009 at 02:18 AM.

  • #5
    New to the CF scene
    Join Date
    Nov 2009
    Location
    Mesa, Arizona
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I can show you the files I am talking about. But I must warn you that they are prolly coded horribly wrong.

    And basically, someone enters in an ID number into a form. That form stores it in the database. Then on a different page I am querying that whole table and display all of it based on a certain answer. Then I need to take the ID that was entered, and appended it to the end of a link to finish making the link.

    PHP Code:
    echo "<p style=\"text-indent:20px;\">Below is a list of all people in the database that are currently in a trade circle.</p>\n";
    $result1 mysql_query("SELECT * FROM trades WHERE status='Yes'");

    echo 
    "<table>
    <tr>
    <th>Ruler Name</th>
    <th>Resource One</th>
    <th>Resource Two</th>
    <th>Alliance</th>
    </tr>"
    ;

    while(
    $row mysql_fetch_array($result1))
      {
      echo 
    "<tr>";
      echo 
    "<td><a href=\"http://www.cybernations.net/nation_drill_display.asp?Nation_ID=\"" $row['nationid'] . ">" $row['rname'] . "</a></td>\n";
      echo 
    "<td><img src=\"images/\"" $row['r1'] . " /></td>";
      echo 
    "<td><img src=\"images/\"" $row['r2'] . " /></td>";
      echo 
    "<td>" $row['aa'] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>";

    echo 
    "<p style=\"text-indent:20px;\">Below is a list of all people in the database that are currently trying to setup a trade circle.</p>\n";
    $result2 mysql_query("SELECT * FROM trades WHERE status='In Progress'");

    echo 
    "<table>
    <tr>
    <th>Ruler Name</th>
    <th>Resource One</th>
    <th>Resource Two</th>
    <th>Alliance</th>
    </tr>"
    ;

    while(
    $row mysql_fetch_array($result2))
      {
      echo 
    "<tr>";
      echo 
    "<td><a href=\"http://www.cybernations.net/nation_drill_display.asp?Nation_ID=\"" $row['nationid'] . ">" $row['rname'] . "</a></td>\n";
      echo 
    "<td><img src=\"images/\"" $row['r1'] . " /></td>";
      echo 
    "<td><img src=\"images/\"" $row['r2'] . " /></td>";
      echo 
    "<td>" $row['aa'] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>";

    echo 
    "<p style=\"text-indent:20px;\">Below is a list of all people in the database that are currently in a <b>NOT</b> in a trade circle.</p>\n";
    $result3 mysql_query("SELECT * FROM trades WHERE status='No'");

    echo 
    "<table>
    <tr>
    <th>Ruler Name</th>
    <th>Resource One</th>
    <th>Resource Two</th>
    <th>Alliance</th>
    </tr>"
    ;

    while(
    $row mysql_fetch_array($result3))
      {
      echo 
    "<tr>";
      echo 
    "<td><a href=\"http://www.cybernations.net/nation_drill_display.asp?Nation_ID=\"" $row['nationid'] . ">" $row['rname'] . "</a></td>\n";
      echo 
    "<td><img src=\"images/\"" $row['r1'] . " /></td>";
      echo 
    "<td><img src=\"images/\"" $row['r2'] . " /></td>";
      echo 
    "<td>" $row['aa'] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>"

    That's what I got and that is what I am talking about. If you need to see the database structure let me know. Also, please critique it and point out anything and everything you see wrong. So that I can learn and correct these issues elsewhere in my project.

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,492
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Is this the line that doesn't work?

    echo "<td><a href=\"http://www.cybernations.net/nation_drill_display.asp?Nation_ID=\"" . $row['nationid'] . ">" . $row['rname'] . "</a></td>\n";

    Try this:

    echo "<td><a href='http://www.cybernations.net/nation_drill_display.asp?Nation_ID={$row['nationid']}'>{$row['rname']}</a></td>\n";

  • Users who have thanked mlseim for this post:

    azace (11-05-2009)

  • #7
    New to the CF scene
    Join Date
    Nov 2009
    Location
    Mesa, Arizona
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Worked perfectly. Thanks alot

  • #8
    New to the CF scene
    Join Date
    Nov 2009
    Location
    Mesa, Arizona
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Now I was wondering, is there anyway to put a link next to each of those data tables that code displays where they can click it and then go to a new page to edit that information?

  • #9
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,492
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    What is an example link you would use for editing?

  • #10
    New to the CF scene
    Join Date
    Nov 2009
    Location
    Mesa, Arizona
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Like say I wanted to take that data and then click on an image and take me to a page called updatetrade.php

    So like I display all the data in tables like I already do, and next to each row of data is the image that I would click to edit it. Then when I click it, it takes me to updatetrade.php and fills the form with the data that is already there, then I just update it.

  • #11
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,492
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Is this what you call a table?
    http://www.cybernations.net/nation_d...tion_ID=141164

    And it would have a little icon, like the (i) icon you now have?
    Maybe the icon would be (e) for edit?

    I'm having a hard time envisioning it.

    If your image was called "edit.png", you would have something like this:

    <a href='http://www.cybernations.net/updatetrade.php?ID={$row['nationid']}'><img src='edit.png' border='0' alt='Update' title='Update' /></a>

    You would somehow have to have an ID so it knows what to update?

    This is just too hard to answer on this forum ...
    You should hire someone to program it for you.

  • #12
    New to the CF scene
    Join Date
    Nov 2009
    Location
    Mesa, Arizona
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry, I can't afford to hire someone to do any of it. I'm broke. I will figure it out. Thanks for your help.


  •  

    Posting Permissions

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