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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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