Help Looking Up Users. - I need some help with looking up users.

free web hosting
Free Web Hosting > Computers & Tech > Programming > Programming General > SQL (Structured Query Language)

Help Looking Up Users. - I need some help with looking up users.

sparkx
OK so can anyone show me a file that will connect to an sql server with an user inputed quary? So here is an example of what I want to do:
You go to a page to find information about James, you would type in example.php?user=James and the page would find all the data about James (all the tables), then display it as an echo. I already have my users set as unique variables so only one person's information would be echoed. The page name and "user" variable doesn't matter.
Do you understand me? I am having trouble explaining it. If someone could show me a code that does this, that would be great and I would add onto your reputation.
Thank you very much,
Sparkx

Reply

WeaponX
Hi sparkx, I think I know what you are referring to. You want it to print out all the user DATABASE related information right? I'm not very strong in the SQL area yet, but found a PHP file with the code that might be of some help if you are some what knowledgeable on SQL:

http://forum.mamboserver.com/archive/index.php/t-33885.html

This script looks through the database and filters out the specified prefix. You should be able to modify it so it will filter by the database username James and display all the tables in a webpage.

Reply

Arbitrary
Hmmm...well, in order to do that, you'd have to use the HTML "GET" variable in your forms. So it'd look something like this:

CODE
<form action="example.php" method="get">


Then, you'd have one of your form fields called "user" and then in example.php you'd get the name (in this case James) from that form field called "user". You can then use that name in your SQL query to get the information based on the name and print that information out.

That way, if you ever access the url example.php?user=James, it'll always use the name in its SQL query to get and print information about James because the ?user=James refers to the GET form field "user" which is filled in by the url to be "James".

Sorry if that wasn't too clear. Perhaps a Google of HTML get method would help plenty. :-)

Reply

pyost
As for the PHP part of the code, you need to retrieve the data from the database. Here's how it would roughly look:

CODE
$user = $_GET['user'];
$query = "SELECT * FROM `table` WHERE `user` = '$user'";

$result = mysql_query($query);
$row = mysql_fetch_array($result);


Of course, there would have to be some validation because of security, but it would end up looking like this. First we get the username, set up the query, and then run it. Then, we move all the data to an array ($row). In order to use it, you will ned $row['column'], where column is the column name in the database.

Reply

sparkx
Thank you all very much for the help. The codes look like they will probably work. I will try them this weekend when I get the time. I am still learning SQL (in odd ways) just like I always do I learn the hard stuff first and need the more detailed instructions later. I was also trying to learn some C++ last weekend also. Who said you can't learn two languages at a time.
Thanks again,
Sparkx
I will add onto your reputation once I try out the scripts so don't worry, I didn't forget.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : users users

  1. MySQL For EasyPHP Users - Does anyone use this program? (4)
  2. A Simple Query For Those That Know - I have users that want to do the below: (2)
    I Make ported mods for the PHP-Nuke and this means first of all I need to change the prefixes to al
    the tables that are in the phpbb database, because Nuke uses the prefix of nuke (of course) but
    there are nuances such as the users table in nuke is just nuke_users Let me start again, all phpbb
    or phpbb2 tables as created by the install unless changed by the user in the config.php file are
    phpbb_forum this or phpbb_users that but nuke has other tables in its database structure the data in
    those table by whatever name remains the same nuke_users has exactly the same str...



Looking for users, users,

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for users, users,
advertisement




Help Looking Up Users. - I need some help with looking up users.



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE