単純なフォームを使用してハッシュタグの名前をphpファイルに設定していますが、結果をフォームと同じページに表示したいと思います。私のフォームとPHPは次のとおりです
<form id"search" method="post" action="twitter.php">
<input type="text" name="hash" id="hash"/>
<input type="submit" name="submit" value="submit"/>
</form>
私のPHPはハッシュタグ検索の結果を表示します
<?php
global $total, $hashtag;
$hashtag = $_POST["hash"];
$total = 0;
function getTweets($hash_tag, $page) {
global $total, $hashtag;
$url = 'http://search.twitter.com/search.json?q='.urlencode($hash_tag).'&';
$url .= 'page='.$page;
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$json = curl_exec ($ch);
curl_close ($ch);
echo "<pre>";
$json_decode = json_decode($json);
print_r($json_decode->results);
$json_decode = json_decode($json);
$total += count($json_decode->results);
if($json_decode->next_page){
$temp = explode("&",$json_decode->next_page);
$p = explode("=",$temp[0]);
getTweets($hashtag,$p[1]);
}
}
echo $total;
getTweets($hashtag,1);
?>
phpの結果をフォームの下と同じページに表示するにはどうすればよいですか。よろしくお願いします。