-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
You can just do this (if it is set then it must have been checked) $wallboxReqd = isset($_REQUEST['wallbox']) ? 1 : 0;
-
Tinyint is fine. BTW, only checked checkbox values are posted.
-
New rows not working, overwriting last entry in cell.
Barand replied to FrankieGee's topic in PHP Coding Help
Give your checkboxes a name attribute ending with "[]" eg name=\"$item_no[]\" All selected values will then be posted in an array -
try outputting $roll instead of $roll1
-
Did you change that line to use your own connection values? What error messages are you getting?
-
PHP runs on the server. JS runs on the client once PHP has rendered the page.
-
Make the id column auto_increment primary key. Make (date, route) a unique key.
-
Export data from multiple databases with one single select statement
Barand replied to michaeljdornan's topic in MySQL Help
On reflection, change UNION above to UNION ALL UNION will suppress duplicates. -
capture image of server side output (not displayed to user)
Barand replied to Q695's topic in PHP Coding Help
If your printer can handle transparencies, can't you just print the page? -
If you are going to use print_r(), put it between <pre>..</pre> tags. It makes it so much more legible. echo '<pre>', print_r($myarray, true), '</pre>'; Or, better still, use var_export($myarray) then others can copy it straight into their editor.
-
capture image of server side output (not displayed to user)
Barand replied to Q695's topic in PHP Coding Help
You can use the GD library to copy a load of smaller images into a larger image and then save the large image. If that is what you mean? -
Combine Overly-Redundant Table Of Data (PHP/MySQL)
Barand replied to gamefreak13's topic in PHP Coding Help
You were clearing the $fdarray each time around the loop so you only finished up with the last one. I am now storing the $fdarray s into the $data array for processing. $oHTML = str_get_html($sHtml); $oTRs = $oHTML->find('table tr'); $data = array(); foreach($oTRs as $oTR) { $fdarray = array(); $oTDs = $oTR->find('td'); if ($oTDs) { foreach($oTDs as $oTD) { $fdarray[] = trim($oTD->plaintext); } $data[] = $fdarray; } } echo '<pre>',print_r($data, true),'</pre>'; echo "<hr>"; $new = array(); foreach ($data as $arr) { $key = join('|', array_slice($arr,0,3)); if (isset($new[$key])) { $new[$key][3][] = $arr[4]; } else { $new[$key] = array ($arr[0], $arr[1], $arr[2], array($arr[4])); } } foreach ($new as $arr) { echo "<hr>"; echo $arr[0]." --- ".$arr[1]." --- ".$arr[2]." --- ".join(', ', $arr[3])."<br>\n"; } -
Export data from multiple databases with one single select statement
Barand replied to michaeljdornan's topic in MySQL Help
try $db = new mysqli(HOST, USERNAME, PASSWORD, DATABASE ); $sql = "SHOW DATABASES"; $res = $db->query($sql); while (list($dbname) = $res->fetch_row()) { switch ($dbname) { case 'information_schema': case 'mysql': continue; default : $queries[] = "SELECT `NickName`,`FirstName`,`LastName`,`Email` FROM `$dbname`.`Profiles` \n"; break;; } } $sql = join(" UNION\n", $queries) . "ORDER BY Email"; echo '<pre>' . $sql . '</pre>'; // $sql IS THE QUERY TO BE EXECUTED You can check for duplicate emails as you process results -
Couple of other errors $pnd = "£"; - there should be a ; after pound $_REQUEST['answer'] = $answer; should be $answer = $_REQUEST['answer'];
-
Output each card into a <div> with float:left style and desired width and height. Easier than table cells.
-
try this $db = new mysqli(HOST, USERNAME, PASSWORD, 'elso' ); // // GET DISP_VALUES FOR HEADINGS // $sql = "SELECT DISTINCT disp_value FROM option_choices"; $res = $db->query($sql); $blank_discounts = array(); $output = "<tr><th>Product</th><th>Price</th>"; while ($row = $res->fetch_row()) { $output .= "<th>{$row[0]}</th>"; $blank_discounts[$row[0]] = 0; } $output .= "</tr>\n"; // // CREATE THE PRICING GRID // $current_prod = ''; $current_price = 0; $sql = "SELECT product_name, default_price, disp_value, percentage FROM product INNER JOIN product_options USING (product_ID) INNER JOIN option_choices USING (option_number) ORDER BY product_name"; #echo query2HTMLtable($db, $sql); $res = $db->query($sql); while (list($prod, $price, $disp, $pc) = $res->fetch_row()) { if ($current_prod != $prod) { if ($current_prod) { $output .= "<tr><td>$current_prod</td><td>$current_price</td>"; foreach ($prod_discounts as $disc) { $output .= "<td>$disc</td>"; } $output .= "</tr>\n"; } $current_prod = $prod; $current_price = $price; $prod_discounts = $blank_discounts; } $prod_discounts[$disp] = number_format($pc,3); } $output .= "<tr><td>$current_prod</td><td>$current_price</td>"; foreach ($prod_discounts as $disc) { $output .= "<td>$disc</td>"; } $output .= "</tr>\n"; ?> <table border="1" cellpadding="4"> <?php echo $output ?> </table> results attached
-
Create a user_views table. When a user views a product, store id | user_id | product_id | timestamp That gives you ability to analyse by user, by product, by date and do things like "users who viewed that product also viewed ...."
-
I agree with mac_gyver. Do not double post the same problem.
-
Combine Overly-Redundant Table Of Data (PHP/MySQL)
Barand replied to gamefreak13's topic in PHP Coding Help
Your original array had element [3] as the one that was to be grouped. You now say it is element [4]. Just change my code to use 4 instead of 3. -
WHERE date > curdate()-INTERVAL 7 day
-
Help inserting data from a csv file to mysql using php
Barand replied to adman4054's topic in PHP Coding Help
Perhaps you have some code that might help to make some sense of the question? -
Issues trying: Multiple LIKES && ORDER BY multiple values
Barand replied to justin7410's topic in MySQL Help
What he actually said was you don't need the % at the beginning of those LIKE expressions ie LIKE '2013-05%'- 3 replies
-
- mysql
- phpmyadmin
-
(and 3 more)
Tagged with:
-
Update table wont work not even following this tutorial
Barand replied to unasemana's topic in MySQL Help
You aren't picking up the POSTed form data -
add ORDER BY category to the end of your current query see http://dev.mysql.com/doc/refman/5.6/en/select.html