SephirGaine Posted August 1, 2006 Share Posted August 1, 2006 Hey ya'll. Not sure if anyone's going to remember this (doubt it), but I've got a work-order request form working on my website, and I've got a drop-down box that recalls data from a row named 'Name' from a database and returns all the entries into the drop-down. Now here's where I'm having trouble.When they submit the form I'd like to recall all the information on a technician that's within the database (only 3 rows per tech), depending on what Name they choose on that dropdown box. I've got two problems here. One, how do I assign a variable to the dropdown option? Is it as simply as giving the <option> tag a name?My second question is more of a statement. I have very little experience with recalling and displaying data from a database. My first instinct would be to just use the echo statement, which may or may not work. But here's my biggest problem, how would I recall the data on the specific tech that they chose? Just to expand/clarify, I have three rows per technician: Name, Email, and Phone. Every entry within 'Name' is displayed as an option in the form. Depending on which option they choose, I want the next page to display all three rows of data for that technician.Hope I don't sound too confused -- because I am. Kinda tough to explain what I'm looking for. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 1, 2006 Share Posted August 1, 2006 The answer to the first question is "Yes, it's that simple".The answer to the second is ... I can't see how what you want is possible unless there is an obvious relationship between a technician's name, phone, email. Why don't you have name, phone, email all in the same 'row' (database record)? The order of rows in a MySQL database has no relevance to relationships between rows and data contained in them. Quote Link to comment Share on other sites More sharing options...
jcbarr Posted August 1, 2006 Share Posted August 1, 2006 Each tech should have their own row, and then you just select the data from the fields in the same row with the name that they selected and ech othat to the page. Quote Link to comment Share on other sites More sharing options...
SephirGaine Posted August 1, 2006 Author Share Posted August 1, 2006 Sorry, that's what I meant. They each have their own row, and with entries named 'Name', 'Email', and 'Phone'. Unfortunately I wasn't sure what the name for it REALLY was.But, after looking through some of my own previous code, as well as a few other threads here I was able to piece together some PHP and it seems to work just fine. This is what I came up with..[code]<?php $query = "SELECT * FROM `Techs` where name='$Tech'"; $result = mysql_query($query) or die(mysql_error()); while ($text = mysql_Fetch_assoc($result)) { echo ''.$text['Name'].'<br> '.$text['Phone'].'<br> '.$text['Email'].''; }?>[/code]If anything looks horrendous, lemme know.. but it seems to work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.