我的索引頁(yè) <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Some name</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <div class="container"> <br /> <h2 align="center">Search by name</h2><br /> <div class="form-group"> <div class="input-group"> <span class="input-group-addon">Search</span> <input type="text" name="search_text" id="search_text" placeholder="Enter model / search here" class="form-control" /> </div> </div> <br /> <div id="result"></div> </div> </body> </html> <script> $(document).ready(function(){ load_data(); function load_data(query) { $.ajax({ url:"fetch.php", method:"POST", data:{query:query}, success:function(data) { $('#result').html(data); } }); } $('#search_text').keyup(function(){ var search = $(this).val(); if(search != '') { load_data(search); } else { load_data(); } });});</script>AND MY fetch.php PAGE,用于從數(shù)據(jù)庫(kù)表中獲取數(shù)據(jù)并輸出結(jié)果。我還添加了如果結(jié)果 > 50 它會(huì)要求輸入更多字符,因?yàn)槿绻也惶砑?if result > 50 那么我的頁(yè)面需要 20 秒才能顯示所有數(shù)據(jù),因?yàn)槲业臄?shù)據(jù)庫(kù)表有 25000 個(gè)條目。我想要我的每個(gè)結(jié)果的 href 鏈接,并且在點(diǎn)擊時(shí),它應(yīng)該從數(shù)據(jù)庫(kù)表中的 ./"URL" 列下載一個(gè)文件。我的數(shù)據(jù)庫(kù)如下所示:我當(dāng)前的頁(yè)面是http://mss1996.ddns.net:8008/files我嘗試在 outpur'array' 中添加 <a href=".$row["URL"]."> 但它破壞了我的頁(yè)面。
1 回答
海綿寶寶撒
TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊
如果該字段的內(nèi)容確實(shí)是有效的 URL,您應(yīng)該能夠輕松地添加該URL字段以形成有效的 URL。我看到您的代碼中缺少的內(nèi)容是http或者https如果它是外部鏈接。如果它是頁(yè)面內(nèi)的相對(duì)鏈接,那么您就可以了。然后添加</a>關(guān)閉鏈接。所以你會(huì)像這樣形成你的表格列:
echo '<td><a href="' . $row['URL'] . '">' . $row["URL"] . '</a></td>';
- 1 回答
- 0 關(guān)注
- 123 瀏覽
添加回答
舉報(bào)
0/150
提交
取消
