Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by TapeGun007

  1. Barand, Thanks as always. I did discover through my trials and errors that the conditions in the WHERE clause were causing some issues. After much reading I had put them in the JOIN ON section, but you confirmed what I wasn't 100% sure of. So your definition confirms also that I was supposed to use the INNER JOIN because I did only want to show records if the match was in both tables. I did not know that LEFT JOINS were much slower however, that part I had not yet discovered.
  2. Is this a less correct way to write it then? This gave me the result I was looking for, but being a bit OCD, I like to ensure I'm writing solid code. SELECT * FROM Deals INNER JOIN Prospects ON Prospects.ProspectID = Deals.ProspectID AND Deals.Status = 'Won' AND Deals.PIGLead = ? ORDER BY SoldDate DESC Yeah, I just put the * in there to shorten it.
  3. Ok never mind. I got it. I had to use an INNER JOIN. I had also made an error above, the Status column was set to "Won" not "Sold". Thanks for helping me get on the right path.
  4. ON Prospects.ProspectID = Deals.ProspectID AND Deals.PIGLead = 2 WHERE Deals.Status = 'Sold' So... the ON line works sort of, but it lists clients that nothing was sold to. So I tried the WHERE above and now nothing comes up. LOL.
  5. Ok, so I was on the right track. I wrote this code: SELECT Prospects.ProspectID, Prospects.FirstName, Prospects.LastName, Prospects.Address, Prospects.Address2, Prospects.City, Prospects.State, Prospects.Zip, Deals.ProspectID, Deals.Product, Deals.Price FROM Prospects LEFT JOIN Deals ON Prospects.ProspectID = Deals.ProspectID So this works. But how can I narrow it down to just like WHERE PIGLead = 2 ? I now see why Union does not work, there would not be an equal amount of rows returned (if I'm understanding this correctly).
  6. I've been reading so many websites about LEFT JOIN, and now UNION, so before I go off on a major rabbit trail please help me figure out which is best by telling you what I want to accomplish. I'm going attach two images of my tables: The first table is called Prospects, and the 2nd table is simply called Deals. I'm going to try to write what I want in a non working version of code, but I hope it will translate what I want better: Under Table Deals, the field Status must be equal to "Sold" Under Tables Deals and Prospects, the ProspectID must match Under Table Deals, the PIGLead must be equal to 2 I want the table to show the Prospect information (name, address, phone, etc), then under the Prospect information, I want to see the deals sold to them where Status = "Sold". I want to see the Product and Price. Best method?
  7. Is it better or are you able to auto insert a percentage based upon a value. Example: Tech1 sells a $1,000 referral item and gets 5% commission Tech1 sells a $2,500 referral item and gets 7% commission instead. I know I could code this in php no problem. I'm just wondering if this makes sense or if it's possible just to auto insert either 5% for under $2,500 or 7% if the sale is equal or over $2,500. There is only 5% and 7%, no other options. The sale amount is stored in the same table.
  8. New question related to this. So... when a new prospect is created, the database inserts an automatic value of null. But then I set a follow up date and then when that date passes, I need to reset that value to a null. I simply put if $followupdate !isset then $followupdate = null; But when $followupdate is written to the database, it is now "0000-00-00" and I cannot seem to get the value back to null in mySQL. Everything works fine the way I have it, but call me OCD.
  9. Ah, I probably got some bad information in my reading, but I was under the perception that when the date is set to 0000-00-00 it is considered a NULL. This, of course, did not make sense to me. In my testing just now, I see the NULL value when auto inserted by mySQL. Thanks.
  10. Ah nvm, I got it unless there is a better way to write this, I would be interested. SELECT * FROM Prospects WHERE UserID = ? AND FollowUpDate < ? AND FollowUpDate > '0000-00-00'
  11. Not all items in my database have a due date. I already have a page that lists everything that is due today and that's fine. What I want to do is sort out all of the null dates "0000-00-00" but list the overdue items (past today) and not the current due dates (today's date). This was my failed attempt: $stmt = $pdo->prepare('SELECT * FROM Prospects WHERE UserID = ? AND FollowUpDate IS NOT NULL AND FollowUpDate < ?'); $stmt->execute([$ID,$today]); The above will list all the dates that are null anyway. I can't seem to figure out how to write this correctly. Thanks.
  12. Uh... thanks benanamen. Heheh. I kept searching, reading, and finally found the solution: $stmt = $pdo->prepare("SELECT SUM(Price) AS sumprice FROM Deals"); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); echo $row['sumprice'];
  13. This might be more of a mySQL question or a PHP question, I'm not exactly sure. I have a field in my table (Deals) called "Price". All I want is the sum of that field. I tried using something like: $price += $row['Price']; This ended up as one long string, even though the database is set as a decimal number field. Then I tried doing it from mySQL like this (from what I read), but I don't think I have the full answer: foreach($stmt->query('SELECT SUM(Price) FROM Deals') as $row) { echo "<tr>"; echo "<td>Total</td>"; echo "<td> ->".$row['SUM(Price)']."</td>"; echo "</tr>"; } Anyway, if someone could just show me how to get that sum, I would greatly appreciate it because I am missing something here.
  14. Just curious, but is it better to use a php framework say like Laravel than coding just plain php? And which framework do you recommend? I've read several websites that suggest Laravel is the better one but who knows who really posted that, so ... just curious from some real dev's what they prefer.
  15. I know you can query multiple DB's using UNION, but can you also UPDATE multiple db's, is that even possible? Not something I really want to do, but I'm trying to work around what I inherited until we hire internal dev's to fix this.
  16. Ask your web host. I have been able to keep documents outside of my "www" folder with some web hosts, and others I had no choice but to store it in a sub folder. One simple thing you can do, is let's say you have your www/production/ folder, simply put a blank file in that folder as index.html and you cannot use a web browser to peruse the other files.
  17. I believe this would be a JS question, but I could be wrong: I query a database, it creates a table with all the matches, and then I click "Edit" next to one of the matches which passes an id so I can edit the user info. However, if I click 'Back' in the browser, I get the usual Is there a way to create a back button that would basically resubmit that form or is that even possible? Yes, I don't want to have to re-click "refresh" to populate the form again. Call me lazy, I don't care.
  18. Ah. Dadgum it, I really worked hard trying to figure out the error on my own. Now I understand. I had thought about that, but what I also misunderstood is that the last CSS code always overwrites the first CSS code... which apparently is NOT true. But yes, that fixed it, and I'm very grateful for all your help!!!! I feel like you really went the extra mile on this.. and it's very much appreciated.
  19. Hi Psycho, I already changed the color back to #99000 (I was just testing to see what that did). This is not the issue. The *ONLY* difference between your picture and my picture is that under the "drivers" menu option (set to active), you have a background of #f6f6f6 (for "add driver" and "search drivers") and I have background color of #99000. This is what I'm trying to understand. I thought maybe it was a browser issue, but I tried this in Chrome, Firefox, and Edge all with the same result. Here is my entire code: <?php //definition of available menu $menuLinks = array( 'Home' => array( 'href' => 'Home.php' ), 'Territory Manager' => array( 'href' => 'tms.php', 'children' => array ( 'Add TM' => '#', 'Search TM' => 'search.php?search=TM' ), ), 'Sales' => array( 'href' => 'sales.php', 'children' => array ( 'Add Sales Person' => '#', 'Search Sales' => 'search.php?search=sales' ), ), 'Drivers' => array( 'href' => 'testcss.php', 'children' => array ( 'Add Driver' => '#', 'Search Drivers' => 'testcss.php' ), ), 'Passengers' => array( 'href' => 'passengers.php', 'children' => array ( 'Add Passenger' => '#', 'Search Passengers' => 'search.php?search=passengers' ) ) ); //Function to create html content for menu function createMenu($menuLinks, $webpage=false) { $menuLinksHtml = ''; foreach($menuLinks as $parentLabel => $parentLink) { //Determine link if parent is active or not $active = ($webpage == $parentLink['href']) ? ' active' : ''; $menuLinksHtml .= "<li class=\"dropdown{$active}\">\n"; //Determine if parent link has children if(!isset($parentLink['children'])) { //No child elements $menuLinksHtml .= "<a href='{$parentLink['href']}'>{$parentLabel}</a>\n"; } else { //Has child elements $menuLinksHtml .= "<a href=\"javascript:void(0)\" class=\"dropbtn\">{$parentLabel}</a>"; $menuLinksHtml .= "<div class=\"dropdown-content\">\n"; foreach($parentLink['children'] as $childLabel => $childLink) { $menuLinksHtml .= "<a href=\"{$childLink}\">{$childLabel}</a>\n"; } $menuLinksHtml .= "</div>\n"; } $menuLinksHtml .= "</li>\n"; } //Return HTML content return $menuLinksHtml; } ?> <!DOCTYPE HTML> <html> <head> <!-- <link rel="stylesheet" type="text/css" href="components/css/rs.css"> --> <style> /***** Begin Menu CSS *****/ ul { width: 100%; list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { float: left; } li a, .dropbtn{ display: inline-block; font-size: 15px; color: white; text-align: center; padding: 14px 16px; text-decoration: none; border-right: 1px solid #bbb; } /* Color of the main menu text when hovering */ li a:hover { background-color: red; } /* Once the mouse has moved off the main menu button and is now highlighting a sub menu button, this defines what that main menu button color is */ .dropdown:hover{ background-color: red; } /* Color of main menu button when not selected */ .dropbtn { background-color: 333; } li .dropdown { position:relative; display: inline-block; } li:last-child { border-right: none; } .dropdown-content{ display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 5px 7px 5px 0px rgba(0,0,0,0.2); z-index: 1; } /* Links inside the dropdown */ .dropdown-content a{ color: black; padding: 12px 16px; text-decoration: none; display: block; text-align: left; background-color: #f6f6f6; /* Sets background color of the drop down menu (not selected) */ } /* Change color of dropdown links on hover */ .dropdown-content a:hover {background-color: #ccc} .dropdown:hover .dropdown-content{ display: block; } /* I have no idea what this does as it appears nothing... li a:hover:not(.active) { background-color: #blue; } */ li.active a { background-color: #990000; } .active dropdown-content{ display: none; position: absolute; min-width: 160px; box-shadow: 5px 7px 5px 0px rgba(0,0,0,0.2); z-index: 1; } .active dropdown-content a{ color: black; padding: 12px 16px; text-decoration: none; display: block; text-align: left; } li.active a.dropbtn { background-color: #990000; } /***** End Menu CSS *****/ </style> </head> <body> <ul> <?php echo createMenu($menuLinks, "testcss.php"); ?> </ul> </body> </html>
  20. That's very odd. Your picture is exactly how I would like it to look, but on my screen... it's like the picture above (minus the dark red Home button). Can you re-post your entire page code? I did go into Chrome and completely delete all cached files and such just to be sure.
  21. li.active a.dropbtn { background-color: #f6f6f6; /* This set the background of the actively selected top menu item */ } What that does is makes the word "Driver" on the main menu turn to a light gray. But it doesn't change the background color of the drop down box.
  22. So that background color on the drop down which is the same as the background of "Drivers" is a bit hard on the eyeballs.
  23. Yeah, I had noticed and was trying to find the issue. But drop down box of the selected item is still dark red (background) even with that. The background of a the active item drop down should be #f6f6f6 (or whatever other color).
  • 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.