Ejemplo n.º 1
0
        while ($rows = mysql_fetch_array($results)) {
            array_push($back, ['word' => $rows['word'], 'url' => $rows['url']]);
            // $results[] = [
            // 'word' => $rows['word'],
            // 'url' => $rows['url']
            // ];
        }
        return $back;
    }
}
$kw = new KeyWord();
switch (strtoupper($_GET["action"])) {
    case "GET":
        $kw->page = isset($_GET["page"]) ? (int) $_GET["page"] : 1;
        $kw->size = isset($_GET["size"]) ? (int) $_GET["size"] : 10;
        $rows = $kw->get();
        $res = ['isok' => '1', 'info' => '', 'rows' => $rows];
        echo json_encode($res);
        break;
    default:
        $kw->word = $_GET['word'];
        $kw->url = $_GET['url'];
        $kw->save();
        break;
}
/*
$.ajax({
	url : "http://localhost:520/m47_baidu_keywords/PHP/save.php",
	type : "GET",
	data : {
		word : 'baidu',