miz_luvly@hotmail.com Posted February 2, 2007 Share Posted February 2, 2007 Hi all I have 2 scripts to display data in table format. the first script displays the main table with columns : account no, customer, report, rep name and view/add follow-up(this links to the second script) the second script is to display follow-ups. is there a way to display all the columns in a single table rather than having follow-ups to be on a seperate page. possibly merging the two scripts or some other way. Can someone plz help. I really cant make this to work. please refer check the two scripts below. I have done a html code of what i want, to make it more understandable. Anyhelp would be much appreciated. thanks the current displays is like this: <html> <head> </head> <body> <table border=1> <tr> <td> accouny no </td> <td> customer name </td> <td> report </td> <td> Rep name </td> <td> view/add follow-ups </td> </tr> <tr> <td> 12345 </td> <td> xyz </td> <td> abcd.... </td> <td> aaa </td> <td> <a href='followup.php?activity_id=".$row['activity_id']."'>view here</a> </td> </tr> </table> </body> </html> I am trying to display table in the following format: <html> <head> </head> <body> <table border=1> <tr> <td> accouny no </td> <td> customer name </td> <td> report </td> <td> Rep name </td> <td> follow-ups </td> </tr> <tr> <td> 12345 </td> <td> xyz </td> <td> abcd.... </td> <td> aaa </td> <td> 12/12/06 > Aaaa.... <br/> 22/1/07 > bbbb... <br/> </td> </tr> </table> </body> </html> Script 1 <?php require 'conn.php'; require 'page_header.php'; $end=time(); include "start_timer.php"; include "end_timer.php"; echo '<a href="logout.php">Log out</a><br><br>'; if (($_GET['account_no']!="") or ($_GET['customer_name']!="") or ($_GET['date']!="") or ($_GET['repname']!="")) { $sql = "select distinct repactivity.*, customer_table.CUSTOMER_NAME, DATE_FORMAT(DATE_OF_ENTRY, '%d-%m-%Y %r') AS DATE_OF_ENTRY, concat(outstanding, ' ', outstanding2, ' ') AS outstanding from repactivity, customer_table where customer_table.account_no=repactivity.account_no AND"; if ($_GET['account_no']!="") { $sql = $sql." repactivity.account_no LIKE '".$_GET['account_no']."%'"; } if ($_GET['customer_name']!="") { if ($_GET['account_no']!="") $sql = $sql." and"; $sql = $sql." CUSTOMER_NAME LIKE '".$_GET['customer_name']."%'"; } if ($_GET['date']!="") { if (($_GET['account_no']!="") or ($_GET['customer_name']!="")) $sql = $sql." and"; $sql = $sql." DATE_OF_APPROACH LIKE '%".$_GET['date']."%'"; } if ($_GET['repname']!="") { if (($_GET['account_no']!="") or ($_GET['customer_name']!="") or ($_GET['date']!="")) $sql = $sql." and"; $sql = $sql." full_name LIKE '".$_GET['repname']."' Group by DATE_OF_ENTRY DESC"; } if ($_GET['rep2']!="") { if (($_GET['account_no']!="") or ($_GET['customer_name']!="") or ($_GET['date']!="") or ($_GET['rep2']!="")) $sql = $sql." and"; $sql = $sql." rep2 LIKE '".$_GET['rep2']."%' group by DATE_OF_ENTRY DESC"; } $result = mysql_query($sql); $number=mysql_num_rows($result); if (!$result) { echo 'Could not run query: ' . mysql_error(); } echo "<table border=1 bordercolor='tan' class='rep' width ='150%' " . "cellspacing='5'"."cellpadding='5'>\n"; echo "<tr border=1><th class='searchHeader'><caption> <b>Search Results</b><br>Total Reports = $number</caption> </th></tr>\n"; echo "<tr><td><b>Account No:</b></td> <td><b>Customer Name:</b></td> <td><b>Date of Approach:</b></td> <td width='50%'><b>Report:</b></td> <td width='50%'><b>Outstanding:</b></td> <td><b>Type of Approach:</b></td> <td width='14%'><b>Rep Name: </b></td> <td width='14%'><b>Rep2: </b></td> <td><b>Date of entry: </b></td> <td><b>Updated Status:</b></td><!-- td><b>Updated On:</b></td --> <td><b>View/add Follow-Up</b></td></tr>"; if ($result and !mysql_num_rows ($result)) { echo "<tr class='row1'><td>No results found that match the "; } else { while($row = mysql_fetch_array($result, MYSQL_BOTH)) { echo "<tr><!-- td>".$row['activity_id']."</td --> <td>".$row['account_no']."</td> <td>".$row['CUSTOMER_NAME']."</td> <td>".$row['DATE_OF_APPROACH']."</td> <td>".$row['report']."</td> <td>".$row['outstanding]."</td> <td>".$row['type_of_approach']."</td> <td>".$row['full_name']."</td> <td>".$row['rep2']."</td> <td>".$row['DATE_OF_ENTRY']."</td> <td>".$row['status']."</td> <!-- td>".$row['updated_on']."</td --> <td bgcolor='#FFFFFF'><a href='followup.php?activity_id=".$row['activity_id']."'>view here</a><BR></td></tr>"; // include ('view_topic_report.php?activity_id=$activity_id'); echo "</td>"; } } } ?> script 2 <?php //Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get value of id that sent from address bar $activity_id=$_GET['activity_id']; //$sql="SELECT view $tbl_name.*, customer_table.customer_name, customer_table.account_no from $tbl_name, customer_table where $tbl_name.account_no='$account_no' ORDER BY DATE_OF_ENTRY DESC"; $sql="select * from $tbl_name where activity_id='$activity_id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <a href="logout.php">Logout</a><br> <FORM><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"> </FORM> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF"> <tr> <td bgcolor="#F8F7F1"><strong>Followup : </strong><? echo $rows['outstanding']; ?></td> </tr> <td bgcolor="#F8F7F1"><strong>By : </strong> <? echo $rows['full_name']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Date/time : </strong><? echo $rows['DATE_OF_ENTRY']; ?></td> </tr> </table></td> </tr> </table> <BR> <?php $tbl_name2="forum_answer"; // Switch to table "forum_answer" $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$activity_id'"; $result2=mysql_query($sql2); while($rows=mysql_fetch_array($result2)){ ?> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td bgcolor="#F8F7F1"><strong>Update</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_id']; ?></td> </tr> <tr> <td width="18%" bgcolor="#F8F7F1"><strong>Name</strong></td> <td width="5%" bgcolor="#F8F7F1">:</td> <td width="77%" bgcolor="#F8F7F1"><? echo $rows['a_name']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Answer</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_answer']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Date/Time</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_datetime']; ?></td> </tr> </table></td> </tr> </table><br> <? } $sql3="SELECT $tbl_name.*, customer_table.customer_name, customer_table.account_no from $tbl_name, customer_table where customer_table.account_no=$tbl_name.account_no ORDER BY DATE_OF_ENTRY DESC"; $result3=mysql_query($sql3); $rows=mysql_fetch_array($result3); $view=$rows['view']; // if have no counter value set counter = 1 if(empty($view)){ $activity_id=$_GET['activity_id']; $view=1; $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE activity_id='$activity_id'"; $result4=mysql_query($sql4); } // count more value $addview=$view+1; $sql5="update $tbl_name set view='$addview' WHERE activity_id='$activity_id'"; $result5=mysql_query($sql5); mysql_close(); ?> <BR> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="add_answer_reports.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td width="18%"><strong>Name</strong></td> <td width="3%">:</td> <td width="79%"><input name="a_name" type="text" id="a_name" size="45"></td> </tr> <tr> <td valign="top"><strong>Reply</strong></td> <td valign="top">:</td> <td><textarea name="a_answer" cols="45" rows="3" id="a_answer"></textarea></td> </tr> <tr> <td valign="top"><strong>Status</strong></td> <td valign="top">:</td> <td valign="top"><select name="status"><?php echo $myrow["status"] ?> <option value="" selected>Select</option> <option value="Complete">Complete</option> <option value="Ongoing">Ongoing</option> <option value="Discussed with Ray">Discussed with Ray & closed</option> </select> </td> </tr> <tr> <td> </td> <td><input name="activity_id" type="hidden" value="<? echo $activity_id; ?>"></td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> </tr> </table> </td> </form> </tr> </table> ?> Quote Link to comment Share on other sites More sharing options...
miz_luvly@hotmail.com Posted February 6, 2007 Author Share Posted February 6, 2007 can some1 help plzzz. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 6, 2007 Share Posted February 6, 2007 you should be able to do this one by yourself. shouldnt be to hard, think about it. grab the required stuff and move it over from script 2. 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.