OZONE Asylum
Forums
Server-Side Scripting - Oh my!
MySQL Help please
This page's ID:
32661
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Hi all! I'm working on a project to make my life easier at my job. I've recently been given the task of managing work that comes in from other offices and after seeing the way this has been done in the past, I've decided to make a database app to store all of this information. I've got my tables set up and forms to input new data and others to view the data, but it's been a long time since I've done any coding and I'm having some trouble getting a couple things figured out. I've got a few tables: refmds - list of referring doctors refsources - list of locations referring doctors work at insurance - list of insurances (medicare, bcbs, etc...) hhcmds - list of our doctors studies - list of studies sent from other offices for our doctors to read Now, in studies, I have columns that hold the primary key of items in other tables - ordering (stores uid for refmds), reading (stores uid for hhcmds), location (stores uid for refsources) and insurance (stores uid for insurance) This is all working as expected, but I'd like to be able to retrieve data from other fields of the related tables and show it in my results, for example: instead of showing 2 under "Reading" I'd like to see lname associated with that row in the other table, which in this case would be "Matthews" [code] mysql_select_db("hhc", $connection); $SQL = mysql_query("SELECT * FROM studies WHERE lname LIKE '$lname%' AND fname LIKE '$fname%' ORDER BY lname"); echo "<table><tr><th>First Name</th><th>Last Name</th><th>Date of Birth</th> <th>Ordering</th><th>Reading</th><th>Date of Service</th><th>Actions</th></tr>\n"; while($row = mysql_fetch_array($SQL)) { ?> <tr> <td><? echo $row['fname'] ?></td> <td><? echo $row['lname'] ?></td> <td><? echo $row['ptdob'] ?></td> <td><? echo $row['ordering'] ?></td> <td><? echo $row['reading'] ?></td> <td><? echo $row['dos'] ?></td> <td> <a href="edit.php?uid=<? echo $row['uid'] ?>"><img src="img/edit.png"></a> <a href="delete.php?uid=<? echo $row['uid'] ?>"><img src="img/delete.png"></a> </td> </tr> <? } mysql_close($connection); echo "</table>\n"; [/code] I'm not sure what the best way to go about doing this would be, as I will eventually need to reference all of the other tables when it comes time to write the billing script and building the invoices. I've thought about making another loop inside the one that processes the output of the first, but I know there's gotta be a simpler way. I'd like to have as little code as possible doing the work, just to leave as little room for error as I possibly can. any help you guys could give would be greatly appreciated. edit: hopefully to make the code fit on the page better [sigrotate] Of all the things I've lost, I miss my mind the most (Ozzy Osbourne)| Some people say I'm a dreamer, but I'm not the only one (John Lennon)| Life is too short, so love the one you got (Bradley Nowell)| I focus on the pain; The only thing that's real (Trent Reznor)| I know the pieces fit, 'cause I watched them fall away (Maynard J. Keenan)| Take your time, hurry up; the choice is yours just don't be late (Kurt Cobain)| You could stand me up at the gates of hell, but I won't back down (Tom Petty)| Do you serve a purpose or purposely serve (Corey Taylor)| You know I'd like to keep my cheeks dry today, so stay with me and I'll have it made (Shannon Hoon) [/sigrotate] [small](Edited by [url=http://www.ozoneasylum.com/user/4616]I X I[/url] on 07-29-2012 17:17)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »
Maximum Security
OZONE
DHTML/Javascript
Server-Side Scripting - Oh my!
CSS - DOM - XHTML - XML - XSL - XSLT
Stupid Basic HTML
Visual Therapy
Photoshop
Photoshop Pong, Anyone?
***WARNING*** BIG SIG APPROACHING
Photography
3D Modelling & Rendering
Multimedia/Animation
Print Graphics
Holding Pens
Philosophy and other Silliness
Outpatient Counseling
Site reviews!
Mad Scientists' Laboratory
Getting to know the Grail