Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Displaying Info From 2 MySQL Tables
Old 02-01-2009, 01:19 PM Displaying Info From 2 MySQL Tables
Stream's Avatar
Average Talker

Posts: 23
Name: Matt
Location: UK
Trades: 0
Hey there, I'm still relitivley new to php & MySQL and I really could do with a little help.

I'm using a script on my site that amongst other things is a CRM script, it has a very basic support feature where a user fills in a form and the details are sent to an email address for me to view.

I wanted to 'upgrade' this feature into a basic ticket system. I've created tabels for the initial request and another table for any updates made to it by the user or staff.

Now the forms that make the initial request and updates work fine, they're submitting all the data correctly and I have a page set up to view the initial request but my problem is getting said page to display any and all updates as well as the original request.

This is the code that displays the original request

PHP Code:
elseif ($q == "ticket_view") {
include(
"header.html");
$url_id =  $_GET['t'];

$tickets mysql_db_query($db"SELECT * from table_tickets where id='$url_id' "$connection);
check_mysql($tickets);
while (
$row mysql_fetch_array($tickets)) {
$ticket_id $row["id"];
$ticket_date $row["date"];
$ticket_subject $row["subject"];
$ticket_domain $row["domain"];
$ticket_priority $row["priority"];
$ticket_contents $row["contents"];
$ticket_poster $row["name"];

$filename "ticket_view.html"
$handle fopen ($filename"r"); 
$contents fread ($handlefilesize ($filename));
$contents str_replace(XticketX$ticket_id$contents);
$contents str_replace(XdateX$ticket_date$contents);
$contents str_replace(XsubjectX$ticket_subject$contents);
$contents str_replace(XdomainX$ticket_domain$contents);
$contents str_replace(XpriorityX$ticket_priority$contents);
$contents str_replace(XmessageX$ticket_contents$contents);
$contents str_replace(XposterX$ticket_poster$contents);
$contents str_replace(Xupdate_posterX$update_poster$contents);
$contents str_replace(Xupdate_dateX$update_date$contents);
$contents str_replace(Xupdate_messageX$update_contents$contents);
print 
$contents;
fclose ($handle);
}
include(
"footer.html");

Like I said that works in as much as it displays the original request but what code would I have to add to that to get it display details from another database table?

The other table I wish to display results from is called table_ticket_replies and the fields are content, date, ticketid.

If anyone could offer help I'd really appreciate it.

--Matt
Stream is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-01-2009, 02:57 PM Re: Displaying Info From 2 MySQL Tables
Average Talker

Posts: 15
Trades: 0
Hi, this should help you http://www.w3schools.com/sql/sql_join_left.asp.

I hope that is not the actual code, $url_id is not sanitised.

George
GOPalmer is offline
Reply With Quote
View Public Profile
 
Old 02-01-2009, 03:04 PM Re: Displaying Info From 2 MySQL Tables
Stream's Avatar
Average Talker

Posts: 23
Name: Matt
Location: UK
Trades: 0
Thanks very much for that, I really appreciate it.

At the moment I'm just trying to piece things together to get it all working, I'll end up tweaking things a lot the time I'm done.

--Matt
Stream is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Displaying Info From 2 MySQL Tables
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.73629 seconds with 12 queries