Checking if a student ID is present in the database What I need to do is fetch the XML link using curl then get a student ID and check if the ID is present in the database. If yes, then I need to get other details from another database table.

My code works fine but it's kinda slow. I later need to add more functions in this which will make the loading speed slower. Is there any way I can improve this code?

It currently takes around 5-6 second to display result when XML has 10-12 ID elements.

&lt;?php

$parseXml = "example.com/xml.xml";
$result = curl_json($parseXml);
if ($result['httpcode'] === 200) {
    $output = simplexml_load_string($result['result']) or die('err');
    if ($output-&gt;result) {
        echo 'Results: ';
        foreach ($output-&gt;result as $resultItem) {
            echo checkID($resultItem-&gt;title, $resultItem-&gt;dataID);
        }
        echo '';
    } else {
        echo 'no result';
    }
}

function checkID($title, $id) {
    $con = mysql_connect(HOST, DBUSER, DBPASS);
    if ($con) {
        mysql_select_db(DBNAME);
        $sql = "SELECT * FROM idlist WHERE id='$id'";
        $retval = mysql_query($sql);
        if (!$retval) {
            die();
        }
        $num_rows = mysql_num_rows($retval);
        if ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
            $out['val'] = 'yes';
            $out['data'] = getInfo($id);
            return $out;
        }
    }
}

function getInfo($id) {
    $con = mysql_connect(HOST, DBUSER, DBPASS);
    if ($con) {
        mysql_select_db(DBNAME);
        $sql = "SELECT * FROM infolist WHERE id='$id'";
        $retval = mysql_query($sql);
        if (!$retval) {
            die();
        }
        if ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
            $arr = array();
            $arr['name'] = $row['name'];
            $arr['class'] = $row['class'];
            return $arr;
        }
    }
}

function curl_json($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    $out['result'] = $result;
    $out['httpcode'] = $httpcode;

    return($out);
}
mysql_ is deprecated, and it has been for quite a while. It will be removed in PHP 7, so you should not use it anymore. 
you are open to SQL injection. Never put variables directly into SQL queries, always use prepared statements.
if you use prepared statements, you could prepare your queries only once, and then execute them with multiple different values, which might increase your performance. 
use one connection across your code instead of creating new ones for every query (this can increase your performance).
profile your code to find out what actually causes performance problems. There is no need to "improve" code that is not causing problems. My guess would be that the curl request is the bottleneck, but without profiling, it's hard to say.
return early to reduce your level of nesting. Eg if (!$cond) return false (or throw an exception).
don't just silently fail, as it will be extremely difficult to debug your code this way. You silently fail if the httpcode of your curl request isn't 200, you silently fail if you can't create a database connection, etc.
don't die in functions, it makes it impossible for the calling code to recover. Throw an exception instead. If you do die, at the very least add a message stating the reason for it, as it will otherwise be really hard to debug your code.