Jump to content

Barand

Moderators
  • Posts

    24,603
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. Places to look for each of the above steps,,, https://www.php.net/manual/en/reserved.variables.get.php https://www.php.net/manual/en/function.mail.php https://phpdelusions.net/pdo https://www.php.net/manual/en/function.http-build-query.php
  2. Remove the comma before the WHERE
  3. You could take the code in your first post, make it a function and use the " wash, rinse, repeat" approach.
  4. Also, your javascript looks decidedly dodgy to me. Two functions called on same event??? They refer to objects with id = 'det_X' -- you have no objects with ids beginning with "det_"
  5. Does your print_r($attData); on line 8 show the correct data?
  6. Perhaps you could give us a clue What is it doing that it shouldn't do What is it not doing that it should do?
  7. From the php manual...
  8. Then your "MyPHPScript.php" should retrieve the inputs from the $_GET array Send the email Update the database Use http_build_query() to rebuild the querystring then use header("Location: NEW URL WITH QUERYSTRING) to send to remote page. = euphemism for "if someone will write it for me (for free)", which is probably why you can't get the answer you really want.
  9. Seriously!? You let anyone delete any record from any table just by putting values in a query string? http://.../delete.php?target=user&username=admin Brownie points for trying to use "prepare()" but your usage is wrong. The $id variable should not be in the query (that's the whole point of prepared statements). Use a placeholder instead and pass the id as a parameter $stmt = $pdo->prepare("DELETE FROM SOME_DATABASE.$table WHERE $idType = ?"); $status = $stmt->execute( [$id] );
  10. Here's an example if ($_SERVER['REQUEST_METHOD']=='POST') { $post = array_map('trim', $_POST); if (!empty($post['productid']) && !empty($post['qty'])) { if (!isset($_SESSION['cart'][$_POST['productid']])) { $_SESSION['cart'][$_POST['productid']] = 0; } $_SESSION['cart'][$_POST['productid']] += $_POST['qty']; } } from an earlier topic of yours !
  11. Plus I doubt if you'd be interested in the odd cents if you are selling a $5,000,000,000 aircraft carrier. Although if your prices were in guineas...
  12. I assume you've had a go at it yourself by now. Here's my effort... <?php $data = []; for ($r=0; $r<4; $r++) { for ($c=0; $c<4; $c++) { $data[$r][$c] = rand(0,1); } } $rowcounts = $colcounts = []; for ($r=0; $r<4; $r++) { $rowcounts[$r] = count(array_keys($data[$r], 1)); } for ($c=0; $c<4; $c++) { $colcounts[$c] = count(array_keys(array_column($data,$c), 1)); } $rmax = max($rowcounts); $cmax = max($colcounts); $rcmax = max($rmax, $cmax); $hirows = array_keys($rowcounts, $rcmax); $hicols = array_keys($colcounts, $rcmax); echo "<table border='1' style='border-collapse:collapse'>\n"; for ($r=0; $r<4; $r++) { echo "<tr>"; for ($c=0; $c<4; $c++) { $hilite = (in_array($r, $hirows) || in_array($c, $hicols)) ? 'class="max"' : ''; echo "<td $hilite>&nbsp;{$data[$r][$c]}&nbsp;</td>"; } echo "</tr>\n"; } echo "</table>\n"; ?>
  13. Do you have this line in your php.ini file... ;extension=php_oci8_12c.dll If so, remove the ";" to enable the extension and check you have that dll file in your extensions folder.
  14. Sounds like you don't the required library installed or enabled. Check the extensions in the php.ini file or use phpinfo() to see if there is an OCI section. https://www.php.net/manual/en/oci8.requirements.php
  15. If you are selling warships, why not indeed. Whatever your application requires.
  16. Make sure your php.ini file has error_reporting set to "E_ALL" and that display_errors and display_startup_errors are ON You also need to check for any errors returned by your DB server.
  17. I store prices as decimal EG +-------------+------------------+------+-----+----------------------+--------------------------------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------------+------+-----+----------------------+--------------------------------+ | prod_id | int(11) | NO | PRI | NULL | auto_increment | | description | varchar(50) | YES | | NULL | | | price | decimal(10,2) | YES | | NULL | | +-------------+------------------+------+-----+----------------------+--------------------------------+ Query example... TABLE: product TABLE: cart +---------+-------------+--------+ +----+---------+------+ | prod_id | description | price | | id | prod_id | qty | +---------+-------------+--------+ +----+---------+------+ | 1 | Product AZ | 49.99 | | 1 | 1 | 2 | | 2 | Product B | 29.99 | | 2 | 3 | 5 | | 3 | Product C | 9.99 | | 3 | 7 | 1 | | 4 | Product D | 22.99 | | 4 | 6 | 2 | | 5 | Product E | 29.99 | +----+---------+------+ | 6 | Product F | 19.99 | | 7 | Product G | 129.99 | | 8 | Product H | 99.99 | | 9 | Product I | 74.99 | | 10 | Product J | 69.99 | +---------+-------------+--------+ SELECT p.prod_id , p.description , p.price , c.qty , p.price * c.qty as total FROM test_product p JOIN test_cart c USING (prod_id); +---------+-------------+--------+------+--------+ | prod_id | description | price | qty | total | +---------+-------------+--------+------+--------+ | 1 | Product AZ | 49.99 | 2 | 99.98 | | 3 | Product C | 9.99 | 5 | 49.95 | | 7 | Product G | 129.99 | 1 | 129.99 | | 6 | Product F | 19.99 | 2 | 39.98 | +---------+-------------+--------+------+--------+
  18. @NotSunfighter He was shown exactly how to do it in a previous topic of his in this forum. Not worth wasting any more time.
  19. Doesn't sound like you are doing anything like that. In my code, if the product isn't in the cart it adds it, with the quantity. If the product is already in the cart it updates the quantity. No removals required (unless, of course, the user wants to cancel)
  20. You cannot send headers when anything has already been output. You need to reorganize your code so that the php processing precedes the html output.
  21. Why?
  22. e.g. A custom UOM of "furlongs per fortnight" makes the top speed of your car sound very impressive.
  23. Well, you've output a table of 0s and 1s, but what are you going to count? Store the random 0/1s in a two-dimensional array then count the array contents. Output the array into the table.
  24. Really!? Hard to believe that, with your markup, you are actually using css files.
  25. Looks like the prepare() failed. Put this line before your mysqli connection so that errors are trapped mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); (if you don't have display_errors ON check your error log.)
×
×
  • 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.