LeratoSelepe Posted March 9, 2017 Share Posted March 9, 2017 Hi Im a php noob Can anyone please assist in splitting a table into two columns in the following script: <?php foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) { // Skip core fields shown earlier in the ticket view $answers = $form->getAnswers()->exclude(Q::any(array( 'field__flags__hasbit' => DynamicFormField::FLAG_EXT_STORED, Q::not(array('field__flags__hasbit' => DynamicFormField::FLAG_CLIENT_VIEW)), 'field__name__in' => array('subject', 'priority'), ))); if (count($answers) == 0) continue; ?> <table class="custom-data" cellspacing="0" cellpadding="4" width="100%" border="0"> <tr><td colspan="2" class="headline flush-left"><?php echo $form->getTitle(); ?></th></tr> <?php foreach($answers as $a) { if (!($v = $a->display())) continue; ?> <tr> <th><?php echo $a->getField()->get('label'); ?>:</th> <td><?php echo $v; ?></td> </tr> <?php } ?> </table> <?php $idx++; } ?> I have attached an image and wish to make the table below "Jobcard Details" appear the same as the one above it Thank you Lerato Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 9, 2017 Share Posted March 9, 2017 Sorry but you really need to learn how to stay either in php mode or out of php mode and stop switching back and forth. Your script is way too hard to follow. Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 9, 2017 Share Posted March 9, 2017 You should typically not use a foreach loop to dump all fields out anyway. If you were to ever include a field in the query that should not be displayed - the user would see it. I think the code to output content should be explicit. having said that, it appears you want the output to be in a specific layout and not dynamic anyway. So, create a template using variables in the applicable fields. I can't tell from your code what the field names are since you are dynamically outputting the fields. But, here is an example with how it could look pulling a record using PDO <?php $query = 'SELECT invoice_no, paid, amount_paid, colour, size, print, embroidery, sew, supplier, customer, acknowledged From table_name WHERE invoice_no = ?'; $stmt = $pdo->prepare($query); $stmt->execute([$invoiceNo]); $record = $stmt->fetch(PDO::FETCH_ASSOC); ?> <table class="custom-data" cellspacing="0" cellpadding="4" width="100%" border="0"> <tr><td colspan="4" class="headline flush-left"><?php echo $form->getTitle(); ?></th></tr> <tr> <th>Invoice Number:</th><td><?=$recod['invoice_no']?></td> <th>Paid</th><td><?=$recod['paid']?></td> </tr> <tr> <th>Amount Paid:</th><td><?=$recod['amount_paid']?></td> <th>Colour</th><td><?=$recod['colour']?></td> </tr> <tr> <th>Size:</th><td><?=$recod['size']?></td> <th>Print</th><td><?=$recod['print']?></td> </tr> <tr> <th>Embroidery:</th><td><?=$recod['embroidery']?></td> <th>Sew</th><td><?=$recod['sew']?></td> </tr> <tr> <th>Supplier:</th><td><?=$recod['supplier']?></td> <th>Customer</th><td><?=$recod['customer']?></td> </tr> <tr> <th>Acknowledged:</th><td><?=$recod['acknowledged']?></td> <th> </th><td> </td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
LeratoSelepe Posted March 18, 2017 Author Share Posted March 18, 2017 thank you @psycho will try your methood Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.