Dtrain Posted December 18, 2015 Share Posted December 18, 2015 Hi, I am making a CMS and I can't get the search page to work right. The CMS is for a new local DJI store and I can't get anything to show up when I search for those who have paid for insurance on their drones. And when I enter a first or last name that multiple people have in common, like Mike or Smith, the info doesn't display correctly, The first customer is displayed correctly, but no one else is. searchcodefirst.php searchcodeinsurance.php searchcodelast.php Quote Link to comment Share on other sites More sharing options...
ginerjm Posted December 18, 2015 Share Posted December 18, 2015 Why don't you pick ONE problem and show us that code? Perhaps if we solve that one, the others will fall into place for you. Key thing is to Show the Code. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 18, 2015 Share Posted December 18, 2015 (edited) searchcodefirst.php searchcodelast.php you should NEVER create different files of code that only differ in the table column being searched. to specifically search for just a first name or just a last name, all you should have is one file and a little program logic that dynamically picks the table column to be searched. you should also NEVER run loop over the result from one query and run another query inside of the loop. you should run one JOINed query, then just loop over the result from that one query. you should also separate the concerns in your code, which would make it easier to debug your code and to just post the portion of the code where the problem is at. at a minimum you should separate the database dependent code (that knows how to retrieve the data) from the presentation code (that knows how to produce the output from that data.) the result (output) from the database dependent code should just be an array of any rows that the query matched. the database dependent code should contain no html and the presentation code should contain no database statements, just php statements that test and operate on the array of data. for debugging, if the array of data contains the expected result, you know the database dependent code is working and that the problem is in the presentation code. lastly, the code you have attached starts after some main query that's not part of the code. without knowing what those main queries are, we cannot possibly help you with anything your code is or is not doing. Edited December 18, 2015 by mac_gyver Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 19, 2015 Share Posted December 19, 2015 (edited) here's another issue with the database design and this code. user/customer information, like first and last names, should be stored in a users/customers table. it should not be stored in tables holding purchase_orders and service_orders data. any rows in the purchase_orders and service_orders tables should be related back to the user/customer data using an id. Edited December 19, 2015 by mac_gyver 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.