Jump to content

Splitting table into two columns


LeratoSelepe

Recommended Posts

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

post-203819-0-46195800-1489020676_thumb.jpg

Link to comment
Share on other sites

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>
Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.