Jump to content

2 table results


phpbeginner

Recommended Posts

I have a database table and it stores a meeting, date, time, location and agenda (filename is in database but file is stored in a folder).

 

Now they would like to update any minutes when they come in so I created another database table. This gets the id from the first table and also has minutes (same as above, storing filename but filename is in a folder).

 

This is all fine and storing everything in the database as it should, I just can't get it to display the results properly. Here is what I have but do not know how to add minutes to the data table if mid from table 2 = id from table 1.

 

Thanks in Advance.....

 

 

<?php
$rs=mysql_query("select * from tbl### ORDER BY date DESC");                        
while($row=mysql_fetch_row($rs)){
$date = $row[3]; 
$row[3] = strtotime($date); 
$row[3] = date('M. d, Y', $row[3]);
foreach ($row as $k => $v){
$row[$k] = nl2br($v);

}
                            
                              echo("<tr><td>" . $row[1] . "</td>");      
                              echo("<td>" . $row[3] . "</td>");
                              echo("<td>" . $row[2] . "</td>");
                              echo("<td>" . $row[4] . "</td>");
                              if($row[5]!="")
			      {
                              echo("<td><a href='agenda/" . $row[5] . "' target='_new'>View</a></td></tr>");    
                                      }
                              else
                                      {
                              echo("<td>N/A</td></tr>");
                                      }
                              }                     
                           
                              ?> 

 

Link to comment
https://forums.phpfreaks.com/topic/175359-2-table-results/
Share on other sites

Use a join then alter your html to show the minutes field from table2 .

 

$rs=mysql_query("select * from tbl1 JOIN tbl2 on tbl1.id=tbl2.mid ORDER BY date DESC");                        
while($row=mysql_fetch_row($rs)){
$date = $row[3]; 
$row[3] = strtotime($date); 
$row[3] = date('M. d, Y', $row[3]);
foreach ($row as $k => $v){
$row[$k] = nl2br($v);

}
                            
                              echo("<tr><td>" . $row[1] . "</td>");      
                              echo("<td>" . $row[3] . "</td>");
                              echo("<td>" . $row[2] . "</td>");
                              echo("<td>" . $row[4] . "</td>");
                              if($row[5]!="")
                  {
                              echo("<td><a href='agenda/" . $row[5] . "' target='_new'>View</a></td></tr>");    
                                      }
                              else
                                      {
                              echo("<td>N/A</td></tr>");
                                      }
                              }                     
                           
                              ?>

Link to comment
https://forums.phpfreaks.com/topic/175359-2-table-results/#findComment-924106
Share on other sites

Your suggestion will only display results if there is minutes posted.

 

Can anyone help with this? Thanks, I really appreciate it!

 

I have a database table and it stores a meeting, date, time, location and agenda (filename is in database but file is stored in a folder).

 

Now they would like to update any minutes when they come in so I created another database table. This gets the id from the first table and also has minutes (same as above, storing filename but filename is in a folder).

 

This is all fine and storing everything in the database as it should, I just can't get it to display the results properly. Here is what I have but do not know how to add minutes to the data table if mid from table 2 = id from table 1.

 

Thanks in Advance.....

 

 

<?php
$rs=mysql_query("select * from tbl### ORDER BY date DESC");                        
while($row=mysql_fetch_row($rs)){
$date = $row[3]; 
$row[3] = strtotime($date); 
$row[3] = date('M. d, Y', $row[3]);
foreach ($row as $k => $v){
$row[$k] = nl2br($v);

}
                            
                              echo("<tr><td>" . $row[1] . "</td>");      
                              echo("<td>" . $row[3] . "</td>");
                              echo("<td>" . $row[2] . "</td>");
                              echo("<td>" . $row[4] . "</td>");
                              if($row[5]!="")
			      {
                              echo("<td><a href='agenda/" . $row[5] . "' target='_new'>View</a></td></tr>");    
                                      }
                              else
                                      {
                              echo("<td>N/A</td></tr>");
                                      }
                              }                     
                           
                              ?>

Link to comment
https://forums.phpfreaks.com/topic/175359-2-table-results/#findComment-924248
Share on other sites

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.