Displaying an order status form
I can totally understand the frustration of your colleague that will need to maintain this code.

But would have been more constructive to tell that this code is considered a "mess" mainly because:


Logic of fetching order status is mixed in the middle of table rendering;
"Dirty" formatting: inconsistent indentation and trailing spaces;


The exact same thing could be better expressed like that:

&lt;?php
function getOrderTrackingStatus($orderId) {
    $url = 'https://plapi.ecomexpress.in/track_me/api/mawbd/';
    $url.= "?awb=awbnumber&amp;order=$orderId&amp;username=admin&amp;password=admin123";

    $ch = curl_init();
    // some curl code
    $res = explode("\n", $output);

    $status = isset($res[13]) ? $res[13] : null;
    return $status;
}
?&gt;

&lt;p&gt;
    &lt;button type="button" class="call"&gt;Show Status&lt;/button&gt;
&lt;/p&gt;

&lt;table class="tbl-qa" border="1"&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th class="table-header"&gt;&lt;/th&gt;
            &lt;th class="table-header"&gt;ORDERID&lt;/th&gt;
            &lt;th class="table-header"&gt;Status&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;

    &lt;tbody id="table-body"&gt;
    &lt;?php $tabindex = 1; ?&gt;
    &lt;?php foreach($orderrecords as $record): ?&gt;

        &lt;tr class="table-row"
            id="table-row-&lt;?php echo $record['id']; ?&gt;"
            tabindex="&lt;?php echo $tabindex++; ?&gt;"&gt;
            &lt;td&gt;
                &lt;input type="checkbox"
                       name="assigneeid"
                       id="assigneeid-&lt;?php echo $record['order_id']; ?&gt;"
                       value="&lt;?php echo $record['order_id']; ?&gt;"
                       onclick="assignorderids('&lt;?php echo $record['order_id']; ?&gt;')"&gt;
            &lt;/td&gt;
            &lt;td&gt;&lt;?php echo $orderId; ?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;?php echo getOrderTrackingStatus($orderId); ?&gt;&lt;/td&gt;
        &lt;/tr&gt;

    &lt;?php endforeach; ?&gt;
    &lt;/tbody&gt;
&lt;/table&gt;


Ideally this getOrderTrackingStatus function would be moved somewhere else, instead of living inside the same file that handles data visualisation.

Hope it helps you, and depending on your project you should consider using a templating engine as a way to force yourself to move logic code away from the views.