-
Posts
24,603 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
Remove the comma before the WHERE
-
You could take the code in your first post, make it a function and use the " wash, rinse, repeat" approach.
-
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_"
-
Does your print_r($attData); on line 8 show the correct data?
-
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?
-
Err500 when trying to open php page from browser
Barand replied to Abhinov's topic in PHP Coding Help
From the php manual... -
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.
-
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] );
-
How to make an associative array with $key => $value pairs
Barand replied to makamo66's topic in PHP Coding Help
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 ! -
Display which row and which column has the biggest number of 1's
Barand replied to Dobby's topic in PHP Coding Help
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> {$data[$r][$c]} </td>"; } echo "</tr>\n"; } echo "</table>\n"; ?> -
Err500 when trying to open php page from browser
Barand replied to Abhinov's topic in PHP Coding Help
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. -
Err500 when trying to open php page from browser
Barand replied to Abhinov's topic in PHP Coding Help
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 -
Err500 when trying to open php page from browser
Barand replied to Abhinov's topic in PHP Coding Help
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. -
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 | +---------+-------------+--------+------+--------+
-
@NotSunfighter He was shown exactly how to do it in a previous topic of his in this forum. Not worth wasting any more time.
-
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)
-
Courier-Deprixa-Pro-v3.2.6.2-Integrated-Web-System Issues
Barand replied to Proiyke's topic in PHP Coding Help
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. -
Implications of entity one-to-one relationships
Barand replied to NotionCommotion's topic in PHP Coding Help
e.g. A custom UOM of "furlongs per fortnight" makes the top speed of your car sound very impressive. -
Display which row and which column has the biggest number of 1's
Barand replied to Dobby's topic in PHP Coding Help
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. -
Really!? Hard to believe that, with your markup, you are actually using css files.
-
Fatal error: Call to a member function bind_param() on a non-object
Barand replied to ACBMSE's topic in PHP Coding Help
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.)