SalientAnimal Posted June 18, 2012 Share Posted June 18, 2012 Ok so I have managed to get my other problem working, but now I'm sitting with another. I am access a database to display entries captured so that you can then search and update individual records. This is working fine, however there is a small problem: The original submit process the information is captured to multiple tables in a particular database. When the information is then displayed on my page, I am getting duplicate results. Can anyone tell me why? Here is my code to show the information from the two tables: <?php session_start(); $conn = @mysql_connect("localhost","root","password") or exit("Could not establish a connection to MySQL Server. mysql_error()"); $select = @mysql_select_db("database",$conn) or exit("Could not select the appropriate database for this operation. mysql_error()"); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $name = $_COOKIE['ID_my_name']; $pass = $_COOKIE['Key_my_site']; $check = @mysql_query("SELECT * FROM userinfo WHERE username='$username'") or die("Failed to execute SQL Statement."); while($info = mysql_fetch_array($check)) { if($pass != $info['password']) { header("Location: login.php"); } else{ } } } else{ header("Location:login.php"); } include "navigation/backoffice.html"; ?> <title> © 2012 Churn Management </title> <script type="text/javascript"> var count = 0; var delay = 250; var text = "© 2012 Churn Management "; function scroll () { document.title = text.substring(count, text.length) + text.substring (0, count) if (count < text.length) { count ++; } else { count = 1; } setTimeout ("scroll()", delay); } scroll(); </script> <LINK REL="SHORTCUT ICON" HREF="favicon.ico"> <script language="javascript" src="js/admin.js"></script> <style type="text/css"> <!-- #form1 table tr td { color: #FFF; } #form1 table tr td { font-family: "Segoe Print", Tahoma, "Segoe UI"; font-size: 13px; } #form1 p { color: #FFF; font-size: 36px; font-weight: bold; text-align: center; font-family: "Segoe Print", Tahoma, "Segoe UI"; } --> </style> </head> <link rel="stylesheet" type="text/css" href="http://10.249.135.30"/> </head> <html> <table width="100%" border="0"> <tr> <td width="20%"></td> <td width="80%"><p align="justify"></p></td> </tr> <tr> <p>Input the Reference, to make sure we have the right one:<br> (Quick Search Listed Below)</p> <form method=post action="amend_churn_it.php"> <input type="text" name="record" size="50"> <br> <img src="images/find.png" alt="find"> <input type="submit" name="search" value="Search"> </form> <?php // Show simple format of the records so person can choose the reference name/number // this is then passed to the next page, for all details $con = mysql_connect("localhost" ,"root" ,"password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $sql="SELECT staff_churn.reference , staff_churn.champ , staff_churn.churn_type , staff_churn_it.champ_portal , staff_churn_it.pc , staff_churn_it.email , staff_churn_it.phone , staff_churn_it.lan , staff_churn_it.g_folders , staff_churn_it.h_folders , staff_churn_it.distribution , staff_churn_it.clarify_access FROM staff_churn_it LEFT JOIN database.staff_churn ON database.staff_churn_it.reference = database.staff_churn.reference WHERE champ_portal = 'Champ Portal' OR pc = 'Laptop' OR pc like 'Desktop%' OR email = 'E-Mail' OR phone = 'Soft Phone' OR phone like 'Hard Phone%' OR lan = 'LAN' OR g_folders like 'G%' OR h_folders like 'H%' OR distribution like 'List%' OR clarify_access like 'Clarify Level%' "; $result = mysql_query( $sql) or die(" - Failed More Information:<br><pre>$sql</pre><br>Error: " . mysql_error()); $num_rows = mysql_num_rows($result); if ($myrow = mysql_fetch_array($result)) { echo "<br><p>Outstanding Churn Management<BR></p><br>"; echo "<table border=1>\n"; echo "<tr> <td bgcolor=#444444 align=center><p><b>Reference</p></td> <td bgcolor=#444444 align=center><p><b>Champ</p></td> <td bgcolor=#444444 align=center><p><b>Churn Type</p></td> <td bgcolor=#444444 align=center><p><b>Champ Portal</p></td> <td bgcolor=#444444 align=center><p><b>PC Requirements</p></td> <td bgcolor=#444444 align=center><p><b>E-Mail</p></td> <td bgcolor=#444444 align=center><p><b>Phone</p></td> <td bgcolor=#444444 align=center><p><b>LAN</p></td> <td bgcolor=#444444 align=center><p><b>G:\ Drive</p></td> <td bgcolor=#444444 align=center><p><b>H:\ Drive</p></td> <td bgcolor=#444444 align=center><p><b>Distribution List</p></td> <td bgcolor=#444444 align=center><p><b>Clarify Access</p></td> </tr>\n"; do { printf("<tr> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> </tr>\n" ,$myrow["reference"] ,$myrow["champ"] ,$myrow["churn_type"] ,$myrow["champ_portal"] ,$myrow["pc"] ,$myrow["email"] ,$myrow["phone"] ,$myrow["lan"] ,$myrow["g_folders"] ,$myrow["h_folders"] ,$myrow["distribution"] ,$myrow["clarify_access"] ); } while ($myrow = mysql_fetch_array($result)); echo "</table>\n"; } else { echo "$ref There are currently no pending actions"; } mysql_free_result($result); mysql_close($con); ?></html> Link to comment https://forums.phpfreaks.com/topic/264378-duplicate-results-displayed/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.