-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
But you are storing the same information to different table, just with different values. Table1, Table2 etc all have the same format. Or am I being misled by a poor naming in the question and they are supposed to be the press, prepress, postpress, qc, binding and dispatch (six) tables in your query? Why not say so if that is the case? Assuming that is the case the ambiguity is caused by your use of order_no in the WHERE clause without a qualifying table name. Don't use that syntax for table joins, use more efficient explicit joins SELECT order_no FROM prepress INNER JOIN press ON press.order_no=prepress.order_no INNER JOIN postpress ON postpress.order_no=prepress.order_no INNER JOIN qc ON qc.order_no=prepress.order_no INNER JOIN binding ON binding.order_no=prepress.order_no INNER JOIN dispatch ON dispatch.order_no=prepress.order_no
-
When I run your code $vis = array ( '19/5/14' => array ( '94-DE-80-28-CF-BC' => Array ( 7 => Array ( 'qax'=> 1 ) ) ) ); $date = '19/5/14'; $macp = '94-DE-80-28-CF-BC'; $id = 3; // arbitrary test value $country = 'uk'; // arbitrary test value array_push( $vis[$date][$macp], array( "$id"=>array( "$country"=>1 ) )); Nothing gets overridden, I get Array ( [19/5/14] => Array ( [94-DE-80-28-CF-BC] => Array ( [7] => Array ( [qax] => 1 ) [8] => Array ( [3] => Array ( [uk] => 1 ) ) ) ) )
-
ORDER BY upvotes, downvotes
-
Why?
-
Center text vertically in image in PHP not working
Barand replied to newsoft's topic in PHP Coding Help
Well, you omitted to mention that you were trying to output multi-line text. Find the bounding box and find the height of a single line. The text output should start a single lineheight below the top of the bounding box. Note that this is approximate. To do it accurately you would need font metrics and use the ascent, descent and leading values. $im = imagecreate(200,200); $str = "Barand\nBarand"; $bg = imagecolorallocate($im, 0,0,0); $col= imagecolorallocate($im, 0xFF, 0xFF, 0xFF); $yel = imagecolorallocate($im, 0xFF, 0xFF, 0); // get height and width of text $box = imagettfbbox(50,0,'calibri.ttf',$str); $textht = $box[7] - $box[1]; $textwd = $box[2] - $box[0]; // get ht of a single line $box2 = imagettfbbox(50,0,'calibri.ttf','X'); $lineht = $box2[7] - $box2[1]; $x = (imagesx($im) - $textwd) / 2; $y = (imagesy($im) - $textht) / 2; // first baseline is top of box - singlw line height $y1 = $y + $textht - $lineht; imagettftext($im, 50, 0, $x, $y1, $col, 'calibri.ttf', $str); // show bounding box imagerectangle($im, $x, $y, $x+$textwd, $y+$textht, $yel); // output header("Content-type: image/png"); imagepng($im); imagedestroy($im); -
Center text vertically in image in PHP not working
Barand replied to newsoft's topic in PHP Coding Help
Just remove the line that draws the rectangle. I only put it in there to demonstrate what/where the bounding box was. -
Center text vertically in image in PHP not working
Barand replied to newsoft's topic in PHP Coding Help
$im = imagecreate(200,100); $str = 'Barand'; $bg = imagecolorallocate($im, 0,0,0); $col= imagecolorallocate($im, 0xFF, 0xFF, 0xFF); $yel = imagecolorallocate($im, 0xFF, 0xFF, 0); // get height and width of text $box = imagettfbbox(50,0,'calibri.ttf',$str); $textht = $box[7] - $box[1]; $textwd = $box[2] - $box[0]; $x = (imagesx($im) - $textwd) / 2; $y = (imagesy($im) - $textht) / 2; imagettftext($im, 50, 0, $x, $y, $col, 'calibri.ttf', $str); // show bounding box imagerectangle($im, $x, $y, $x+$textwd, $y+$textht, $yel); // output header("Content-type: image/png"); imagepng($im); imagedestroy($im); -
Why don't you save yourself some coding and SELECT department , SUM(amount) as amt FROM requisition WHERE date = '$new_date' GROUP BY department
-
See FAQ http://forums.phpfreaks.com/topic/273121-readme-php-resources-faqs/?do=findComment&comment=1405508
-
What does your original db table look like and what is your query?
-
... or if the identifier contains spaces or other special characters. EG SELECT SUM(price) as `Total Sales` ...
-
One field needs clarification before comment, viz. user_date ?Some should not be in there cart_productname - you should only store the productname in the product table and not repeat in all the cart records cart_productprice - ditto cart_by - cart items belong to the order and you already have order_by cart_subtotal - don't store derived items like totals. Use a query to SUM the items when you want the total. order_total - as above order_productid - an order can be for several products, that's why there is the cart table to hold the productid's
-
If changing the js code doesn't work, you can always reformat it in PHP $calendar_date = '17/05/14'; $dt = DateTime::createFromFormat('d/m/y', $calendar_date); $formatted_date = $dt->format('Y-m-d'); echo $formatted_date; //--> 2014-05-17
-
-
You should end up with something like this +----------+--------------+ +--------------+-------------------+ | ClientId | ClientName | | ProductID | ProductName | +----------+--------------+ +--------------+-------------------+ | 1 | Jean | | 1 | Product one | | 2 | Mond | | 2 | Product two | | 3 | Richard | | 3 | Product three | | 4 | Gwen | | 4 | Product four | +----------+--------------+ | 5 | Product five | | +--------------+-------------------+ | | +----------------------------+ | | | Cart | | +------+------------+--------------+ | id | clientId | productId | +------+------------+--------------+ | 1 | 1 | 1 | | 2 | 1 | 2 | Client 1 has products | 3 | 1 | 3 | 1, 2, 3, 4 and 5 | 4 | 1 | 4 | | 5 | 1 | 5 | | 6 | 2 | 2 | Client 2 has products | 7 | 2 | 4 | 2, 4, and 5 | 7 | 2 | 5 | +------+------------+--------------+ Now, by searching on clientid you know what each client bought. By searching on productid you know who bought each product.
-
The point is that putting them in one field is the wrong way to do it http://lmgtfy.com/?q=data+normalization
-
Read up on data normalization
-
Yes EG CREATE TABLE IF NOT EXISTS testprice ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, price VARCHAR(10) ); INSERT INTO testprice (price) VALUES ('125.99'), ('15.99'), ('12.49'), ('1.00'), ('0.50'); SELECT * FROM testprice; +----+--------+ | id | price | +----+--------+ | 1 | 125.99 | | 2 | 15.99 | | 3 | 12.49 | | 4 | 1.00 | | 5 | 0.50 | +----+--------+ Now alter the column type ALTER TABLE `test`.`testprice` CHANGE COLUMN `price` `price` DECIMAL(10,2) NULL DEFAULT NULL; SELECT * FROM testprice; +----+--------+ | id | price | +----+--------+ | 1 | 125.99 | | 2 | 15.99 | | 3 | 12.49 | | 4 | 1.00 | | 5 | 0.50 | +----+--------+
-
try $previousdate=''; $events = array(); while($row = mysqli_fetch_assoc($result)) { $dutydate = $row['myDate']; if($dutydate != $previousdate) { if ($previousdate) { echo $previousdate . '<br>' . join(", ", $events) . '<br><br>'; } $events = array(); $previousdate = $dutydate; } $events[] = $row['event_name']; } echo $previousdate . '<br>' . join(", ", $events) . '<br><br>';
-
Are you storing your prices as varchar in your database? Should be something like DECIMAL(10,2)
-
This works for me. Note it uses mysqli and not mysql librarybut apart from that it is fundamentally the same code. <?php $db = new mysqli(HOST,USERNAME,PASSWORD,'test'); // use your credentials error_reporting(-1); if(isset($_POST['del_event'])) { if(isset($_POST['check'])) { $del_ids = join(',', array_map('intval', $_POST['check'])); $sqlqueer = mysqli_query($db,"DELETE FROM event WHERE event_id IN ($del_ids)"); if(!$sqlqueer) { die ("Error in delete query"); } } } ?> <html> <head> <title>Sample</title> </head> <body> <form class="event-button-wrap" method="post" action=""> <div class="button-wrap"> <input type="submit" id="del_event" name="del_event" value="Delete Event"/> </div> <div class="event-list-table2" > <table class="event-table"> <thead> <tr> <th>Event Name</th> <th class="head">Event Date</th> <th class="head">Venue</th> </tr> </thead> <tbody class="tbody-event-list-table2"> <?php // require "connection.php"; $check = mysqli_query($db,"SELECT * FROM event"); if(mysqli_num_rows($check) > 0) { while($row = mysqli_fetch_array($check)) { $id = $row['event_id']; $name = $row['event_name']; $dstart = $row['start_date']; $venue = $row['event_venue']; echo "<tr> <td> <input type='checkbox' name='check[]' class='check' value='$id'>$name </td> <td>$dstart</td> <td>$venue</td> </tr>"; } } else { echo "<tr> <td colspan='3'>There Are No Events.</td> </tr>"; } ?> </tbody> </table> </div> </form> </body> </html>
-
Have you looked at the page source to get any clues?
-
Is phpChart putting them in or you? echo '<pre>', print_r($price, 1), '</pre>';
-
You're quite right. I'll shut up :-)