title: Integrate a PHP script and an IPhone application?
body: <p>I'm developing an application for a School project.So i'll try to explain in a properly way:</p>
  
  <p>I have a php script that allow the user to search in a MYSQL table for some keywords,the code is bellow:</p>
  
  <pre><code>&lt;?php
  
  
  //get data
  $button = $_GET['submit'];
  $search = $_GET['search'];
  
  
  $s = $_GET['s'];
  if (!$s)
  $s = 0;
  
  
  $e = 10; // Just change to how many results you want per page
  
  
  $next = $s + $e;
  $prev = $s - $e;
  
  
  
  
   if (strlen($search)&lt;=2)
    echo "Must be greater then 3 chars";
   else
   {
    echo "&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='juzzy.jpg' /&gt;&lt;/td&gt;&lt;td&gt;&lt;form action='search.php' method='GET'&gt;&lt;input type='text' onclick=value='' size='50' name='search' value='$search'&gt; &lt;input type='submit' name='submit' value='Search'&gt;&lt;/form&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
  
    //connect to database
    mysql_connect("localhost","root","root");
    mysql_select_db("content");
  
     //explode out search term
     $search_exploded = explode(" ",$search);
  
     foreach($search_exploded as $search_each)
     {
  
          //construct query
      $x++;
      if ($x==1)
       $construct .= "keywords LIKE '%$search_each%'";
      else
       $construct .= " OR keywords LIKE '%$search_each%'";
  
     }
  
    //echo outconstruct
    $constructx = "SELECT * FROM searchengine WHERE $construct";
  
    $construct = "SELECT * FROM searchengine WHERE $construct LIMIT $s,$e";
    $run = mysql_query($constructx);
  
    $foundnum = mysql_num_rows($run);
  
  
    $run_two = mysql_query("$construct");
  
    if ($foundnum==0)
     echo "No results found for &lt;b&gt;$search&lt;/b&gt;";
    else
    {
     echo "&lt;table bgcolor='#0000FF' width='100%' height='1px'&gt;&lt;br /&gt;&lt;/table&gt;&lt;table bgcolor='#f0f7f9' width='100%' height='10px'&gt;&lt;tr&gt;&lt;td&gt;&lt;div align='right'&gt;Showing 1-10 of &lt;b&gt;$foundnum&lt;/b&gt; results found for &lt;b&gt;$search.&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;";
  
     while ($runrows = mysql_fetch_assoc($run_two))
     {
      //get data
     $title = $runrows['title'];
     $desc = $runrows['description'];
     $url = $runrows['url'];
  
     echo "&lt;table width='300px'&gt;
     &lt;h4&gt;&lt;a href='http://$url'&gt;&lt;b&gt;$title&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
     $desc&lt;br&gt;
     &lt;font color='00CC00'&gt;$url&lt;/font&gt;&lt;/table&gt;&lt;/h4&gt;
     ";
  
  
     }
  ?&gt;
  
  
  &lt;table width='100%'&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;div align="center"&gt;
  
  &lt;?php
  if (!$s&lt;=0)
   echo "&lt;a href='search.php?search=$search&amp;s=$prev'&gt;Prev&lt;/a&gt;";
  
  $i =1; 
  for ($x=0;$x&lt;$foundnum;$x=$x+$e)
  {
  
  
   echo " &lt;a href='search.php?search=$search&amp;s=$x'&gt;$i&lt;/a&gt; ";
  
  
  $i++;
  
  
  }
  
  if ($s&lt;$foundnum-$e)
    echo "&lt;a href='search.php?search=$search&amp;s=$next'&gt;Next&lt;/a&gt;";
  
      }
  }  
  
  
  ?&gt;
  &lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>So i need to integrate this code and an iPhone app,i've already build the for execute the query,its bellow:</p>
  
  <pre><code>-(IBAction)executeQuery:(id)sender{
  
      NSString *encodedValue = [queryValue.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  
      NSString *cont11 = [NSString stringWithFormat:@"http://localhost:8888/searchengine/searchengine/search.php?search=%@",encodedValue];
  
      NSData *cont12 = [NSData dataWithContentsOfURL:[NSURL URLWithString:cont11]];
  
      NSString *cont13 = [[[NSString alloc] initWithData:cont12 encoding:NSUTF8StringEncoding]autorelease];
  
      NSLog(@"%@", cont13);
  
      [queryValue resignFirstResponder];
  
  
  }
  </code></pre>
  
  <p>So how the app is suppose to work,</p>
  
  <ol>
  <li>When the user digit some text on a UITextField and press the button,the code execute the query[THIS PART IS WORKING PROPERLY].</li>
  <li>After that,the code have to get the results from the PHP and display it on a UITableView or anything UI(can be UILabels)[THIS PART ISN'T WORKING].</li>
  </ol>
  
  <p>My question is:</p>
  
  <p>How can i execute the query and display the results(on a IOS app)?</p>