How to display the total size in MB
Just wondering if someone can help me out with this quickly.

I have a php script It works fine, However, I would like it to display the `Total Memory` in MB.

 

    <div class="TitleBar">VM List</div>   
    
          <?php
    				
    				$conn = pg_connect("host=".MGRCONFIG_DB_HOST."  port=".MGRCONFIG_DB_PORT." dbname=".MGRCONFIG_DB_NAME. " user=" .MGRCONFIG_DB_USER." password=".MGRCONFIG_DB_PASSWORD);
    				if (!$conn) 
    				{
    					AddLog("vmlist.php","Could not connect to Database",ERR_DEBUG_HIGH);		
    				}
    				$query = "select guid,vmname,hostid,guestosname,cputype,cpucycle,totalmemory from vmobjects order by vmname";
    				$result = pg_query($conn,$query);
    				AddLog("vmlist.php","Query: ".$query,ERR_DEBUG_HIGH);
    
    				$guid_array=Array();
    				$lastname_array=Array();
    				$firstname_array=Array();
    				$osname_array=Array();
    				$cptype_array=Array();
    				$cpcycle_array=Array();
    				$tom_array=Array();
    				$no_of_record = 0; 				
    				
    				while ($row = pg_fetch_array($result)) 
    				{	
    					$num_rows=0;
    					$subquery = "select bussinessappid from bussinessapppolicyassoc where vmid ='".$row[0]."'";
    					AddLog("vmlist.php","Query: ".$query,ERR_DEBUG_LOW);
    					$subresult = pg_query($conn,$subquery);
    					$num_rows=pg_num_rows($subresult);
    					
    					$guid_array[$no_of_record] = $row[0].'|'.$num_rows;
    					$lastname_array[$no_of_record] = $row[1];
    					
    					$hostid = $row[2];
    					$osname_array[$no_of_record] = $row[3];
    					$cptype_array[$no_of_record] = $row[4];
    					$cpcycle_array[$no_of_record] = $row[5];
    					$tom_array[$no_of_record] = $row[6];					
    							
    					 
    					$query = "select name from hosts where guid='".$hostid."'";
    					$result1 = pg_query($conn,$query);
    					AddLog("vmlist.php","Query: ".$query,ERR_DEBUG_HIGH);
    					while ($row1 = pg_fetch_array($result1)) 
    					{
    						 $firstname_array[$no_of_record] = $row1[0];
    					}						
    					$no_of_record++;					
    				}
    
    				pg_close($conn);
    				?>
          <table class="objList" cellspacing="0" cellpadding="0" id="vmtable">
            <tr>
    		  <td class="tbHeader"></td>
              <!--<td class="tbHeader"></td>
    		  <td class="tbHeader"></td>-->
              <td class="tbHeader">Name </td>
    		  <td class="tbHeader">Hostname</td>
    		  <td class="tbHeader">OS Name</td>
    		  <td class="tbHeader">CPU Type</td>
    		  <td class="tbHeader">CPU Cycle</td>
    		  <td class="tbHeader">Total Memory</td>
    		  
    		  
              
    		  
            </tr>
            <?php
    			
    			for ($i =0; $i < $no_of_record; $i++)
    			{
    				echo "<tr class=\"objList\" id=\"".$i."\">";
    
    				echo "<td height=\"20\" width=\"25\" valign=\"top\" class=\"objList\">";
    
    				//if(strcmp($_SESSION['mntvm_edit'],"1") == 0 || strcmp($_SESSION['mntvm_delete'],"1") == 0)
    				{
    					echo "<img id=\"".$guid_array[$i]."\" src=\"images/icon-reports.gif\" alt=\"Options\" title=\"Options\" width=\"25\" height=\"20\" border=\"0\">";
    				}
    				echo "</td>";
    				echo "<td class=\"objList\" value=\"".$lastname_array[$i]."\" width=\"\">".$lastname_array[$i]."</td>";				
    
    				echo "<td class=\"objList\" value=\"".$firstname_array[$i]."\" width=\"\">".$firstname_array[$i]."</td>";	
    				
    				echo "<td class=\"objList\" value=\"".$osname_array[$i]."\" width=\"\">".$osname_array[$i]."</td>";
    				echo "<td class=\"objList\" value=\"".$cptype_array[$i]."\" width=\"\">".$cptype_array[$i]."</td>";
    				echo "<td class=\"objList\" value=\"".$cpcycle_array[$i]."\" width=\"\">".$cpcycle_array[$i]."</td>";
    				echo "<td class=\"objList\" value=\"".$tom_array[$i]."\" width=\"\">".$tom_array[$i]."</td>";
    				
    				echo "</tr>";					
    			}
    			?>
          </table>  
    </div>
How to display the total size in MB
===

Just wondering if someone can help me out with this quickly.

I have a php script It works fine, However, I would like it to display the `Total Memory` in MB.

 

    <div class="TitleBar">VM List</div>   
    
          <?php
    				
    				$conn = pg_connect("host=".MGRCONFIG_DB_HOST."  port=".MGRCONFIG_DB_PORT." dbname=".MGRCONFIG_DB_NAME. " user=" .MGRCONFIG_DB_USER." password=".MGRCONFIG_DB_PASSWORD);
    				if (!$conn) 
    				{
    					AddLog("vmlist.php","Could not connect to Database",ERR_DEBUG_HIGH);		
    				}
    				$query = "select guid,vmname,hostid,guestosname,cputype,cpucycle,totalmemory from vmobjects order by vmname";
    				$result = pg_query($conn,$query);
    				AddLog("vmlist.php","Query: ".$query,ERR_DEBUG_HIGH);
    
    				$guid_array=Array();
    				$lastname_array=Array();
    				$firstname_array=Array();
    				$osname_array=Array();
    				$cptype_array=Array();
    				$cpcycle_array=Array();
    				$tom_array=Array();
    				$no_of_record = 0; 				
    				
    				while ($row = pg_fetch_array($result)) 
    				{	
    					$num_rows=0;
    					$subquery = "select bussinessappid from bussinessapppolicyassoc where vmid ='".$row[0]."'";
    					AddLog("vmlist.php","Query: ".$query,ERR_DEBUG_LOW);
    					$subresult = pg_query($conn,$subquery);
    					$num_rows=pg_num_rows($subresult);
    					
    					$guid_array[$no_of_record] = $row[0].'|'.$num_rows;
    					$lastname_array[$no_of_record] = $row[1];
    					
    					$hostid = $row[2];
    					$osname_array[$no_of_record] = $row[3];
    					$cptype_array[$no_of_record] = $row[4];
    					$cpcycle_array[$no_of_record] = $row[5];
    					$tom_array[$no_of_record] = $row[6];					
    							
    					 
    					$query = "select name from hosts where guid='".$hostid."'";
    					$result1 = pg_query($conn,$query);
    					AddLog("vmlist.php","Query: ".$query,ERR_DEBUG_HIGH);
    					while ($row1 = pg_fetch_array($result1)) 
    					{
    						 $firstname_array[$no_of_record] = $row1[0];
    					}						
    					$no_of_record++;					
    				}
    
    				pg_close($conn);
    				?>
          <table class="objList" cellspacing="0" cellpadding="0" id="vmtable">
            <tr>
    		  <td class="tbHeader"></td>
              <!--<td class="tbHeader"></td>
    		  <td class="tbHeader"></td>-->
              <td class="tbHeader">Name </td>
    		  <td class="tbHeader">Hostname</td>
    		  <td class="tbHeader">OS Name</td>
    		  <td class="tbHeader">CPU Type</td>
    		  <td class="tbHeader">CPU Cycle</td>
    		  <td class="tbHeader">Total Memory</td>
    		  
    		  
              
    		  
            </tr>
            <?php
    			
    			for ($i =0; $i < $no_of_record; $i++)
    			{
    				echo "<tr class=\"objList\" id=\"".$i."\">";
    
    				echo "<td height=\"20\" width=\"25\" valign=\"top\" class=\"objList\">";
    
    				//if(strcmp($_SESSION['mntvm_edit'],"1") == 0 || strcmp($_SESSION['mntvm_delete'],"1") == 0)
    				{
    					echo "<img id=\"".$guid_array[$i]."\" src=\"images/icon-reports.gif\" alt=\"Options\" title=\"Options\" width=\"25\" height=\"20\" border=\"0\">";
    				}
    				echo "</td>";
    				echo "<td class=\"objList\" value=\"".$lastname_array[$i]."\" width=\"\">".$lastname_array[$i]."</td>";				
    
    				echo "<td class=\"objList\" value=\"".$firstname_array[$i]."\" width=\"\">".$firstname_array[$i]."</td>";	
    				
    				echo "<td class=\"objList\" value=\"".$osname_array[$i]."\" width=\"\">".$osname_array[$i]."</td>";
    				echo "<td class=\"objList\" value=\"".$cptype_array[$i]."\" width=\"\">".$cptype_array[$i]."</td>";
    				echo "<td class=\"objList\" value=\"".$cpcycle_array[$i]."\" width=\"\">".$cpcycle_array[$i]."</td>";
    				echo "<td class=\"objList\" value=\"".$tom_array[$i]."\" width=\"\">".$tom_array[$i]."</td>";
    				
    				echo "</tr>";					
    			}
    			?>
          </table>  
    </div>