phpbeginner Posted September 24, 2009 Share Posted September 24, 2009 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>"); } } ?> Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted September 24, 2009 Share Posted September 24, 2009 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>"); } } ?> Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted September 24, 2009 Author Share Posted September 24, 2009 It would be row[2] from table 2. How do I do that as I cannot use row[2] as that is displaying results from tbl1? Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted September 24, 2009 Author Share Posted September 24, 2009 anyone have any suggestion on this? Thanks In Advance Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted September 24, 2009 Author Share Posted September 24, 2009 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>"); } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.