Jump to content

daniel0816

Members
  • Posts

    45
  • Joined

  • Last visited

daniel0816's Achievements

Member

Member (2/5)

0

Reputation

  1. Yea I never thought about it that way I apologize. The reason why I am saying I dont want to use union is because I had already tried it and the query worked great but it didnt output the data correctly into the HTML table. Each set of data wasnt lined up correctly and I dont know how to remove the empty table cells inorder to align the data up correctly in the table
  2. How is that relevant for this all I want to know is how to combine these two simple queries together and thats it. The relationships I have between my tables is not of your concern all I ask for is a simple solution to a small problem i.e. combine the two queries above. The result that I expect should be self explanatory through the two simple queries above I just want to know how to join them together into one query. Yes you are probably right I shouldnt be creating multiple threads but I really need to find a solution to this problem asap.
  3. I have the two following queries: SELECT CUST_ID FROM Customers WHERE CUST_ID LIKE '%$criteria%' SELECT J_RefNum FROM Jobs WHERE J_RefNum LIKE '%$criteria%' How would I merge them together into one query without using union. Any help would be greatly appreciated thanks.
  4. Ok apologies here is my query to go along with it. By the way there are only two sets of data that are stored in the database, really dont know why it repeats them. Thanks again. $criteria = $_POST['sCriteria']; $sql="SELECT Customers.CUST_ID, Customers.CUST_Forename, Customers.CUST_Surname, Customers.CUST_Email, Customers.CUST_Mobile, Customers.CUST_HomeNum, Customers.CUST_AddressL1, Customers.CUST_AddressL2, Customers.CUST_AddressL3, Customers.CUST_Postcode, Jobs.J_RefNum, Manufacturers.MANU_Name, Jobs.J_Model, OperatingSystems.OS_Name, Jobs.J_ReceivedBy, Jobs.J_DateRec, Jobs.J_FaultDesc, Jobs.J_PassWinAdmin, Jobs.J_DataRecYN, Jobs.J_PowerSuppYN, JobStatus.JS_Status FROM Customers, Jobs, Manufacturers, OperatingSystems, JobStatus WHERE ( Customers.CUST_ID LIKE '%$criteria%') OR ( Customers.CUST_Forename LIKE '%$criteria%') OR (Customers.CUST_Surname LIKE '%$criteria%') OR (Customers.CUST_Email LIKE '%$criteria%') OR (Customers.CUST_Mobile LIKE '%$criteria%') OR (Customers.CUST_HomeNum LIKE '%$criteria%') OR (Customers.CUST_AddressL1 LIKE '%$criteria%') OR (Customers.CUST_AddressL2 LIKE '%$criteria%') OR (Customers.CUST_AddressL3 LIKE '%$criteria%') OR (Customers.CUST_Postcode LIKE '%$criteria%') OR (Jobs.J_RefNum LIKE '%$criteria%') OR (Manufacturers.MANU_Name LIKE '%$criteria%') OR (Jobs.J_Model LIKE '%$criteria%') OR (OperatingSystems.OS_Name LIKE '%$criteria%') OR (Jobs.J_ReceivedBy LIKE '%$criteria%') OR (Jobs.J_DateRec LIKE '%$criteria%') OR (Jobs.J_FaultDesc LIKE '%$criteria%') OR (Jobs.J_PassWinAdmin LIKE '%$criteria%') OR (Jobs.J_DataRecYN LIKE '%$criteria%') OR (Jobs.J_PowerSuppYN LIKE '%$criteria%') ";
  5. Well if I didnt know what data it was returning do you think I would have posted with the problem of repeating the data over and over?
  6. I have a MySQL query which gets the required data ok. But when I submit the results into the HTML table it displays the data ok but it repeats it over and over. Here is my code: $result=mysql_query($sql) or die(mysql_error()); if($result) { ?> <table name='details' border='2'> <thead> <tr> <th>Customer ID</th> <th>Forename</th> <th>Surname</th> <th>Email</th> <th>Mobile Number</th> <th>Home Number</th> <th>Address Line 1</th> <th>Address Line 2</th> <th>Address Line 3</th> <th>Postcode</th> <th>Job Reference Number</th> <th>Manufacturer</th> <th>Model</th> <th>Operating System</th> <th>Received By</th> <th>Date Received</th> <th>Fault Description</th> <th>Password - Windows Admin</th> <th>Data Recovery?</th> <th>Power Supply?</th> <th>Job Status</th> </tr> </thead> <tbody> <?php } while($row=mysql_fetch_array($result)) { echo "<tr>"; echo '<td>' . $row['CUST_ID'] . '</td>'; echo '<td>' . $row['CUST_Forename'] . '</td>'; echo '<td>' . $row['CUST_Surname'] . '</td>'; echo '<td>' . $row['CUST_Email'] . '</td>'; echo '<td>' . $row['CUST_Mobile'] . '</td>'; echo '<td>' . $row['CUST_HomeNum'] . '</td>'; echo '<td>' . $row['CUST_AddressL1'] . '</td>'; echo '<td>' . $row['CUST_AddressL2'] . '</td>'; echo '<td>' . $row['CUST_AddressL3'] . '</td>'; echo '<td>' . $row['CUST_Postcode'] . '</td>'; echo '<td>' . $row['J_RefNum'] . '</td>'; echo '<td>' . $row['MANU_Name'] . '</td>'; echo '<td>' . $row['J_Model'] . '</td>'; echo '<td>' . $row['OS_Name'] . '</td>'; echo '<td>' . $row['J_ReceivedBy'] . '</td>'; echo '<td>' . $row['J_DateRec'] . '</td>'; echo '<td>' . $row['J_FaultDesc'] . '</td>'; echo '<td>' . $row['J_PassWinAdmin'] . '</td>'; echo '<td>' . $row['J_DataRecYN'] . '</td>'; echo '<td>' . $row['J_PowerSuppYN'] . '</td>'; echo '<td>' . $row['JS_Status'] . '</td>'; echo "</tr>"; } ?> </tbody> </table> Thanks Again
  7. I want to remove individual empty cells.
  8. Ok bad example for talk sake assume that the customer table has a MANU_ID.
  9. Say I have the following queries: "SELECT CUST_ID, CUST_Forename, CUST_Surname FROM Customers WHERE (CUST_ID LIKE '%$criteria%') OR (CUST_Forename LIKE '%$criteria%') OR (CUST_Surname LIKE '%$criteria%')"; "SELECT MANU_Name FROM Manufacturers WHERE (MANU_Name LIKE '%$criteria%')"; What I want to do is have these two queries in one query. I also want the query to echo the results into an HTML table like the following: <table name='details' border='2'> <thead> <tr> <th>Customer ID</th> <th>Forename</th> <th>Surname</th> <th>Manufacturer</th> </tr> </thead> <tbody> echo "<tr> <td>{$row['CUST_ID']}</td> <td>{$row['CUST_Forename']}</td> <td>{$row['CUST_Surname']}</td> <td>{$row['MANU_Name']}</td> </tr>\n"; Thanks Again
  10. Can anyone provide me with an alternative query that does the same job as the following solution. Using UNION causes the result to not be suitable for what I want to do with it. Any help would be greatly appreciated thanks. $sql="SELECT CUST_ID, CUST_Forename, CUST_Surname, CUST_Email, CUST_Mobile, CUST_HomeNum, CUST_AddressL1, CUST_AddressL2, CUST_AddressL3, CUST_Postcode, '' as J_RefNum, '' as MANU_Name, '' as J_Model, '' as OS_Name, '' as J_ReceivedBy, '' as J_DateRec, '' as J_FaultDesc, '' as J_PassWinAdmin, '' as J_DataRecYN, '' as J_PowerSuppYN, '' as JS_Status FROM Customers WHERE (CUST_ID LIKE '%$criteria%') OR (CUST_Forename LIKE '%$criteria%') OR (CUST_Surname LIKE '%$criteria%') OR (CUST_Email LIKE '%$criteria%') OR (CUST_Mobile LIKE '%$criteria%') OR (CUST_HomeNum LIKE '%$criteria%') OR (CUST_AddressL1 LIKE '%$criteria%') OR (CUST_AddressL2 LIKE '%$criteria%') OR (CUST_AddressL3 LIKE '%$criteria%') OR (CUST_Postcode LIKE '%$criteria%') UNION SELECT '', '', '', '', '', '', '', '', '', '', J_RefNum, '', J_Model, '', J_ReceivedBy, J_DateRec, J_FaultDesc, J_PassWinAdmin, J_DataRecYN, J_PowerSuppYN,'' FROM Jobs WHERE (J_RefNum LIKE '%$criteria%') OR (J_Model LIKE '%$criteria%') OR (J_ReceivedBy LIKE '%$criteria%') OR (J_DateRec LIKE '%$criteria%') OR (J_FaultDesc LIKE '%$criteria%') OR (J_PassWinAdmin LIKE '%$criteria%') OR (J_DataRecYN LIKE '%$criteria%') OR (J_PowerSuppYN LIKE '%$criteria%') UNION SELECT '', '', '', '', '', '', '', '', '', '', '', MANU_Name, '', '', '', '', '', '', '', '', '' FROM Manufacturers WHERE (MANU_Name LIKE '%$criteria%') UNION SELECT '', '', '', '', '', '', '', '', '', '', '', '', '', OS_Name, '', '', '', '', '', '', '' FROM OperatingSystems WHERE (OS_Name LIKE '%$criteria%') UNION SELECT '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', JS_Status FROM JobStatus WHERE (JS_Status LIKE '%$criteria%')";
  11. yea that doesn't work either. What I am trying to do is remove the empty cells not hide them.
  12. Thanks the query works fine but when I echo the results into the html table the data isn't lined up correctly due to the layout of the query. Is there any way to hide the empty cells so that everything is lined up correctly. Thanks Again
  13. How do I set empty table cells to hidden so that they don't show up on screen therefore all data in the table will be aligned correctly. Here is what I have tried so far: <tbody style="empty-cells:hidden"><?php} while($row=mysql_fetch_assoc($result)){ echo "<tr> <td>{$row['CUST_ID']}</td> <td>{$row['CUST_Forename']}</td> <td>{$row['CUST_Surname']}</td> <td>{$row['CUST_Email']}</td> <td>{$row['CUST_Mobile']}</td> <td>{$row['CUST_HomeNum']}</td> <td>{$row['CUST_AddressL1']}</td> <td>{$row['CUST_AddressL2']}</td> <td>{$row['CUST_AddressL3']}</td> <td>{$row['CUST_Postcode']}</td> <td>{$row['J_RefNum']}</td> <td>{$row['MANU_Name']}</td> <td>{$row['J_Model']}</td> <td>{$row['OS_Name']}</td> <td>{$row['J_ReceivedBy']}</td> <td>{$row['J_DateRec']}</td> <td>{$row['J_FaultDesc']}</td> <td>{$row['J_PassWinAdmin']}</td> <td>{$row['J_DataRecYN']}</td> <td>{$row['J_PowerSuppYN']}</td> <td>{$row['JS_Status']}</td> </tr>\n"; } Any suggestions would be greatly appreciated thanks
  14. How would that work because each select is taking data from a different table?
×
×
  • 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.