...

View Full Version : HTTP links from SQL varchar data



azace
11-02-2009, 06:32 AM
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

mlseim
11-02-2009, 01:28 PM
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.

azace
11-02-2009, 03:22 PM
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?

mlseim
11-03-2009, 03:13 AM
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?



.

azace
11-03-2009, 08:53 PM
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.


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.

mlseim
11-03-2009, 11:46 PM
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";

azace
11-05-2009, 05:55 PM
Worked perfectly. Thanks alot

azace
11-05-2009, 05:56 PM
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?

mlseim
11-05-2009, 07:01 PM
What is an example link you would use for editing?

azace
11-06-2009, 12:00 AM
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.

mlseim
11-06-2009, 01:07 AM
Is this what you call a table?
http://www.cybernations.net/nation_drill_display_guest.asp?Nation_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.

azace
11-06-2009, 01:10 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum