Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Take a long look at how I coded up your page. Only one php start tag and one end. Pretty simple. You don't have to use a pair of tags for a single line of php code. But - all you had to do was move your first php start tag to the very first line in column 1 and that would have cured you if you got rid of the end tags too. HTH
  2. To clarify the error message points you at the header line but that is not the cause. It is probably that blank line up at the top. When in php mode nothing goes to the client by accident. But when NOT in php mode any blank chars or lines do go to the client and that's the message you are getting. Actually line 1 seems to be your problem.
  3. This more like it should look: <?php session_start(); include_once '../includes/connectvars.php'; include_once '../functions/globalFunctions.php'; $webID = ''; $password = ''; $sendForm = ''; // * Form Processing * if(isset($_POST['username'], $_POST['password'])) { $webID = $_POST['username']; $password = $_POST['password']; // * Validate login * if(validateLoginAdmin($webID, $password, $conn) == false) { $sendForm = false; } else{$sendForm = true;} // * Good to go? Start Session * if($sendForm == true) { //include_once('startSessionAdmin.php'); $query = "SELECT * FROM adminlogin WHERE adminuser = '$webID' limit 1"; $result = mysqli_query($conn, $query); $row = $result->fetch_assoc(); $_SESSION['firstName'] = $row['firstName']; $_SESSION['lastName'] = $row['lastName']; $_SESSION['login'] = 1; $_SESSION['admin'] = 2; $_SESSION['username'] = $webID; header('Location:admin_landing.php'); exit(); } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Login</title> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"> <link rel="stylesheet" href="../css/login.css"> </head> <body> <div class="login"> <h1>Enrichment Week Admin Login</h1> <form action="index.php" method="post"> <label for="username"> <i class="fas fa-user"></i> </label> <input type="text" name="username" placeholder="Username" id="username" required> <label for="password"> <i class="fas fa-lock"></i> </label> <input type="password" name="password" placeholder="Password" id="password" required> <input type="submit" value="Login"> </form> </div> </body> </html> PS Include/requires do not need parens.
  4. What is that blank line between your MULTIPLE php tags? Don't use a close php tag unless you have to. Why isn't the session start up there at the top?
  5. You need to make sure that you have no blank lines/spaces being sent out before you do these things. Make sure that your php tag is the very first byte of your script.
  6. IF I understand you at all here is how I would do this exercise: // assuming that you are using PDO // hint: good practice is to replace the * with just the field names that you need to retrieve $q = "SELECT * from $uniluxModel where gpm = :gpm or ewt = :ewt"; $qst = $dbConn->prepare($q); $parms = array( 'gpm'=>$uniluxGpm, 'ewt'=>$uniluxEwt ); $qst->execute($parms); if ($qst) { $rowcnt = $qst->rowCount(); echo "Found $rowcnt records matching at least one of the inputs<br>"; while ($row = $qst->fetch()) { if ($row['gpm'] == $uniluxGpm && $row['ewt'] == $uniluxEwt) { (process a record that matches both values and prepare the output) } elseif($row['gpm'] == $uniluxGpm) { (process a record that only matches the gpm value and prepare the output) } else { (process the records that only match the ewt value and prepare the output) } // // now output what you prepared from the logic above. // } } else echo "Error executing query"; exit(); Hope this is clear. YOu simply need to add some code/calcs to the if clauses.
  7. You can do your count while you are processing the results of the or query. Logic. Logic. The Or query gets you the records you want to look at. Count them up any way you want. You seem to want things both ways. You want to get the ones what match both and you also want to get the ones that don't match both. Query for the ones that match EITHER and then let your logic decide what to do with each one (and count it) as you loop thru the results
  8. You are misleading us. You have TWO DIFFERENT QUERIES here. Why???? As I already said - run the OR query and then go thru the records examining the values of your two columns to see if you matched both or not. Then do whatever you need to do. It is that simple. Don't know what the count thing is doing for you but that is a whole different question. Good bye.
  9. HOw about showing us the exact query that you are running? It apparently is not what you posted.
  10. You are not telling us something. IF you run an OR query it will return ANY RECORD matching one or the other and will not stop until it searches the whole table. Not sure what you think is happening.
  11. When you process the query results of an OR your code will KNOW what was found. Your logic after that will handle the calcs.
  12. If you use an OR you will get any record that matches either one. Simply by looking at the results you will know which one was found. Not really sure exactly what you are trying to do . HOw about explaining in english, not in the form of a query.
  13. Maybe you want to use an OR instead of an AND? That will give your records with one or the other. The AND only gives the ones with both values. And - those {} are really not needed, although you should begin to use prepared queries.
  14. That's the spirit!
  15. Are you Really going to make me search thru your code to find this line? No thanks. Obviously the guy who did this thought he was doing something very clever instead of just writing out the Cell lines he built a structure and looped thru it just to make maintenance difficult. Yes - the k value if going out of range. You probably have to add a couple entries to those arrays.
  16. Well - I don't know what is on line 141. Do you? Show me. As for the 2nd line - you cannot output anything ahead of the pdf output. That is probably the error message causing this.
  17. I see that 'date' is your new field but it has a horrible name. A good programmer assigns good names to make it clear what he is working with. Comes in very handy 6 months from now when he has to go back in for maintenance or upgrades. I would therefore call it 'ckin_date' (I like short names). And I also see you are calculating a duration between check in and check out so I would call it 'dur' or 'duration' . Then add the CELL calls in the logical spot to output these values. You are so close. Hint - you may want to alter the date formats to condense the data into a shorter width. Unless you need a report that shows the seconds and a 4-digit year.
  18. Looking at your current query I see that you only get the following fields: c.brand, store, v.robot_num, date, total You need to edit the sql statement to add the two new columns from the appropriate table. Then use those names in the output portion (the CELL calls) to add them to the output layout. Suggestion - amend the 'date' field name to a non-reserved word. Describe the date a little better perhaps as 'trans_date'? If you change the query you will have to locate any other uses of a fieldname of 'date' and match the new name.
  19. You have to locate all of the calls to the CELL (or MUTLICELL) function. That is what puts the data on the page. They will be in this script in the order of the output you currently get and when you get to the ''date" value that is being output you will insert a couple of new CELL calls with the data items that you retrieve with your query statement.
  20. Are these 2 new cols already in your db so that your query can retrieve them? If so - then you just need to add their CELL outputs in the right place to output them such as after the CELL call for the Date field/column. Seems like a simple problem with an easy solution so I have to wonder why you are asking. Are you not a coder perhaps?
  21. Not sure I have the full picture from your posted text, but I certainly don't know what your query is supposed to look like. From your text, your reference to a 'sub-query' might mean one of the tables in your total query which is joined to the main table and that you want that one table 'sorted'. Why? It is not the result. It is only a source of data that will comprise the final result and THAT can already be sorted. So - what is the real problem?
  22. What do you mean? Those are commands that you put into your script to turn on error checking. You don't have to look for them. And it is 'ginerjm' please.
  23. I think your JS would have to select each one after it moves it into list B Or maybe select them all when the submit button is clicked
  24. I have no idea what you are saying in the above statement. Apparently you are doing something in the php.ini file. Are you sure you know what you are doing? As for running php 8 and using a 6 year old book - Sure it will teach you most of php but the newer features won't be covered nor will it tell you what is no longer supported.
  25. Hmmm.. Guess I should have corrected his query when I tried to demo using PDO.. OP - the first query is returning an array which you simply used as a singular value in your 2nd query. That should be $cnt = $num[0]; and then use $cnt in your call to RAND. But - you have to re-think how you are using that SQL RAND function. I think you may want to use the PHP 'rand()' function to generate your number and embed that into an OFFSET clause in your query to get a record at random. Read up on it in the manual.
×
×
  • 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.