Jump to content

Recalling specific data through PHP.. (SOLVED)


SephirGaine

Recommended Posts

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.
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.
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.