RE: SQL Syntax Question
Thank you for trying to help me. The output is wrong I get either Event 1 Event 2 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 Or Event 1 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 Event 2 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 But not what I need Event 1 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 Event 2 Details 1 for event 2 Details 2 for event 2 Details 3 for event 2 -Original Message- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 04, 2004 12:08 AM To: Karl-Heinz Schulz; [EMAIL PROTECTED] Subject: Re: SQL Syntax Question - Original Message - From: Karl-Heinz Schulz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, August 03, 2004 9:18 PM Subject: SQL Syntax Question I tried to get an answer on the PHP mailing list and I was told that this list would be quicker to get me a solution. I have two tables Event and Eventdetails (structures dump can be found at the end of the message). I want to display all events and the related information from the eventdetails table like Event 1 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 Event 2 Details 1 for event 2 Details 2 for event 2 Details 3 for event 2 Etc. I cannot figure it out. Here is my PHP code. -- -- ?php require(../admin/functions.php); include(../admin/header.inc.php); ? ? $event_query = mysql_query(select id, inserted, information, eventname, date, title from event order by inserted desc LIMIT 0 , 30); while($event = mysql_fetch_row($event_query)){ print(bspan style=\font-family: Arial, Helvetica, sans-serif;color:#003300;font-size:14px;\.html_decode($event[5])./span /bbr); print(span style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($event[4])./spanbr); print(span style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($event[2])./spanp); $eventdetail_query = mysql_query(select informations, titles, file_name from eventdetail, event where eventdetail.event =.$event[0]); //$eventdetail_query = mysql_query(select titles, informations, file_name from eventdetail, event where eventdetail.event = event.id); while($eventdetail = mysql_fetch_row($eventdetail_query)){ print(span style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($eventdetail[0])./span); print(nbspspan style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($eventdetail[1])./span); print(span style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($eventdetail[2])./spanp); } } ? -- -- What am I missing? TIA Karl-Heinz # # Table structure for table `event` # CREATE TABLE event ( id smallint(2) unsigned NOT NULL auto_increment, veranstaltung smallint(2) unsigned NOT NULL default '0', inserted date NOT NULL default '-00-00', information text NOT NULL, eventname text NOT NULL, date varchar(30) NOT NULL default '', title varchar(100) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM; # # Table structure for table `eventdetail` # CREATE TABLE eventdetail ( id smallint(2) unsigned NOT NULL auto_increment, event smallint(2) NOT NULL default '0', informations text NOT NULL, titles varchar(100) NOT NULL default '', file_name varchar(100) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM; Tracking #: 5CF2A36BDC27D14BA1C3A19CBAC7214ED510CB7E What you've already given us is great but it would really help if you described the problem you are encountering. It's not clear whether you are getting error messages from MySQL or your result sets simply don't match your expectations or if you are getting compile errors from php. If you could state just what the problem is, and ideally show the result you are getting (if any) versus the result you expected, it would be easier to help you. Rhino -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: SQL Syntax Question
Philippe, I changed my to the following but the result is now (I deleted the print stuff for better reading) ? $event_query = mysql_query(select id, inserted, information, eventname, date, title from event order by inserted desc LIMIT 0 , 30); while($event = mysql_fetch_row($event_query)){ $eventdetail_query = mysql_query(select titles, informations, file_name from eventdetail, event where event.id=eventdetail.event AND event.id=.$event[0]); while($eventdetail = mysql_fetch_row($eventdetail_query)){ } } ? Event 1 Event 2 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 But I would need Event 1 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 Event 2 Details 1 for event 2 Details 2 for event 2 Details 3 for event 2 Is this even possible? TIA -Original Message- From: Philippe Poelvoorde [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 04, 2004 5:52 AM To: Karl-Heinz Schulz Cc: [EMAIL PROTECTED] Subject: Re: SQL Syntax Question Karl-Heinz Schulz wrote: Thank you for trying to help me. The output is wrong I get either Event 1 Event 2 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 that query is wrong : $eventdetail_query = mysql_query(select informations, titles, file_name from eventdetail, event where eventdetail.event =.$event[0]); try : select informations, titles, file_name from eventdetail, event where event.id=.$event[0] AND event.id=eventdetails.event Tracking #: 3842A5D2EB81014B918FDB71F1DE0830A35E8D56 -- Philippe Poelvoorde COS Trading Ltd. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
SQL Syntax Question
I tried to get an answer on the PHP mailing list and I was told that this list would be quicker to get me a solution. I have two tables Event and Eventdetails (structures dump can be found at the end of the message). I want to display all events and the related information from the eventdetails table like Event 1 Details 1 for event 1 Details 2 for event 1 Details 3 for event 1 Event 2 Details 1 for event 2 Details 2 for event 2 Details 3 for event 2 Etc. I cannot figure it out. Here is my PHP code. ?php require(../admin/functions.php); include(../admin/header.inc.php); ? ? $event_query = mysql_query(select id, inserted, information, eventname, date, title from event order by inserted desc LIMIT 0 , 30); while($event = mysql_fetch_row($event_query)){ print(bspan style=\font-family: Arial, Helvetica, sans-serif;color:#003300;font-size:14px;\.html_decode($event[5])./span /bbr); print(span style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($event[4])./spanbr); print(span style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($event[2])./spanp); $eventdetail_query = mysql_query(select informations, titles, file_name from eventdetail, event where eventdetail.event =.$event[0]); //$eventdetail_query = mysql_query(select titles, informations, file_name from eventdetail, event where eventdetail.event = event.id); while($eventdetail = mysql_fetch_row($eventdetail_query)){ print(span style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($eventdetail[0])./span); print(nbspspan style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($eventdetail[1])./span); print(span style=\font-family: Arial, Helvetica, sans-serif;font-size:12px;\.html_decode($eventdetail[2])./spanp); } } ? What am I missing? TIA Karl-Heinz # # Table structure for table `event` # CREATE TABLE event ( id smallint(2) unsigned NOT NULL auto_increment, veranstaltung smallint(2) unsigned NOT NULL default '0', inserted date NOT NULL default '-00-00', information text NOT NULL, eventname text NOT NULL, date varchar(30) NOT NULL default '', title varchar(100) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM; # # Table structure for table `eventdetail` # CREATE TABLE eventdetail ( id smallint(2) unsigned NOT NULL auto_increment, event smallint(2) NOT NULL default '0', informations text NOT NULL, titles varchar(100) NOT NULL default '', file_name varchar(100) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM; Tracking #: 5CF2A36BDC27D14BA1C3A19CBAC7214ED510CB7E -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]