This is a discussion on "[SOLVED] Basic database to call information" within the PHP Forum section. This forum, and the thread "[SOLVED] Basic database to call information are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] Basic database to call information
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
[SOLVED] Basic database to call information
Hello,
First post here I have built quite a few websites but I just cant work out this: I would like to have a box where a user enters a number, e.g.. UK2008-10 and clicks search. Once search is pressed set information is then returned and displayed.(from a db which has not yet been built, any ideas what to use?) Example: [UK2008-10 ] [Search] Returned Data: Name Address 'Static' Text Can anyone shed some light on this? I normally use HTML or CMS's to build websites but Im a quick learner. Regards, Piers ps: sorry if this question if too basic |
|
|
|
#2
|
||||
|
||||
|
Re: Basic database to call information
moving to php forum
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
|
|
#3
|
|||
|
|||
|
Re: Basic database to call information
sorry, didnt mean to post in the wrong section
|
|
#4
|
||||
|
||||
|
Re: Basic database to call information
no problem, most dynamic data if being called from the database is a php issue, - but not all, sometimes it can be asp etc
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
|
|
#5
|
|||
|
|||
|
Re: Basic database to call information
ok, i have created a database using phpMyAdmin. I have created 1 table called 'userid' with 3 fields. These are called; fldID(primary), fldName and fldAddress.
I have setup a search box. I search from table 'userid' for field 'fldID' to check if its there, if so then it returns the fldID information. What im stuck on now is how to just search for the fldID but return fldName and fldAddress info too - is this possible? Example: [UK2008J ] [SEARCH] Next page: User ID: UK2008 ----------------- What i would like to have is: [UK2008J ] [SEARCH] Next page: User ID: UK2008 User Name: Adam Smith Address: Street, Town, County ------------------- Would it make more sense to have 3 tables? One for name, one for user id and one for address? Any help with this is appreciated! |
|
#6
|
|||
|
|||
|
Re: Basic database to call information
I think that this is what you are looking for
replace $host with your db host, $username with your database username and $password with your database password also $database with your database name.
|
|
#7
|
|||
|
|||
|
Re: Basic database to call information
THANK YOU!
Im just trying to set that up now Regards, P. |
|
#8
|
|||
|
|||
|
Re: Basic database to call information
I seem to have got a bit stuck with this.
|
|
#9
|
|||
|
|||
|
Re: Basic database to call information
In what way?
|
|
#10
|
|||
|
|||
|
Re: Basic database to call information
I have been using this php:
|
|
#11
|
|||
|
|||
|
i got it to work here:
http://www.myfreeportfolio.net/test/search.php there is only one entry though, the user id is 28627 here is the code:
and the form:
|
|
#12
|
|||
|
|||
|
Re: Basic database to call information
Thank you!
If i wanted to make a couple of changes, for example, search for 1 user id and instead of just the name, it brings the name, address, status (verified or expired) and expire date, what would i add? I have played around with what you created but with no luck. For example: ------------------------- Information for User ID: [fldID] Member Name: [fldName] Address: [fldAddress] Expires: [fldStatus] Member Status: [fldStatus] --------------------------- Also I did try and make it so only exact user id's entered would work. With the current code if you just enter '28' instead of '28627' the info is still fetched. Hope that makes some sense, Regards, Piers |
|
#13
|
|||
|
|||
|
Re: Basic database to call information
that makes perfect sense, but right now i have a report to type by midnight so i shall have the solution for you by tommorow.
|
|
#14
|
|||
|
|||
|
Re: Basic database to call information
Bronic - Thank you so very much. I look forward to seeing it
Good luck with the report. Regards, Piers |
|
#15
|
|||
|
|||
|
this is very simple, your code now is set up great and this is just a tweak. here its updated: http://www.myfreeportfolio.net/test/search.php there are two entries: 28627 and 987 all you needed to do was replace:
to get all of the field you need to replace:
|