新聞中心
如何解決Linux環(huán)境下訪問PHP頁面時,頁面上顯示數(shù)據(jù)庫代碼的問題
出現(xiàn)此問題的原因是由于在.htaccess文件中添加了下面兩行:
按需定制網(wǎng)站可以根據(jù)自己的需求進行定制,成都網(wǎng)站設計、成都網(wǎng)站制作構(gòu)思過程中功能建設理應排到主要部位公司成都網(wǎng)站設計、成都網(wǎng)站制作的運用實際效果公司網(wǎng)站制作網(wǎng)站建立與制做的實際意義
AddHandler application/x-httpd-php53 .php
AddHandler application/x-httpd-php54 .php
在這些行的開始位置插入#注釋掉之后就可以正常使用了。
PHP,如何表單保存到數(shù)據(jù)庫并且顯示
首先可以采用的是Jquery的Ajax技術(shù)進行操作。
思路是這樣的,首先現(xiàn)在前端判斷JS并提交給后臺,代碼如下:
$(function(){
$.ajax({
type:post,
dataType:json,
url:?save.php,
data:$("input[name=x]").val(),
success:function(data){
}
});
});
這樣后端接收到Ajax請求后進行連接數(shù)據(jù)庫并且插入數(shù)據(jù)
其它操作類似進行操作即可。
php用表單形式顯示數(shù)據(jù)庫信息
初學者寫的,你可以試試
form?name="myform"?method="post"?action="mysql.php"
table?border="1"
tr
td?width="605"?height="51"?bgcolor="#CC99FF"?colspan="2"
div?align="center"請輸入用戶名稱
input?name="txt_user"?type="text"?id="txt_user"?size="25"nbsp;
input?type="submit"?name="Submit"?value="查詢"
/div
/td
/tr
tr
td?align='center'用戶名稱/td
td?align='center'年齡/td
/tr
?php
//?mysql_connect(服務器,用戶名,密碼)
$link?=?mysql_connect("localhost","root","root");
//?mysql_select_db(數(shù)據(jù)庫,$link)
$db_selected?=?mysql_select_db("php_test",$link);
//?編碼格式(貌似很重要)
mysql_query("set?names?'utf8'");
?
?php
$sql?=?mysql_query("select?name_,age_?from?t_user");
$info?=?mysql_fetch_array($sql);
if($_POST[Submit]=="查詢"){
$txt_user?=?$_POST[txt_user];
$sql?=?mysql_query("select?*?from?t_user?where?name_?like?'%".trim($txt_user)."%'");
$info?=?mysql_fetch_array($sql);
}
?
?php
if($info==false){
echo?'trtd?width="605"?height="51"?bgcolor="#CC99FF"?colspan="2"';
echo?"div?align='center'?style='color:#FF0000;font-size:12px;'對不起,您查找的用戶信息不存在!/div";
echo?'/td/tr';
}elseif($info){
echo?'elseif';
}
?
?php
do{
?
tr?align="center"?bgcolor="#FFFFFF"
td?height="20"align="center"??php?echo?$info['NAME_']?/td
td??php?echo?$info['AGE_']?/td
/tr
?php
}while($info?=?mysql_fetch_array($sql));
mysql_free_result($sql);
mysql_close($link);
?
/table
/form
PHP輸入關(guān)鍵詞后在數(shù)據(jù)庫搜索并顯示記錄
加密部分:
?php
$name="油菜";
echo "/search.php?keywords=".urlencode($name);
?
解密部分:
?php
//$_REQUEST為PHP的預定義全局數(shù)組,可以用來獲取URL中的參數(shù)值
$name=urldecode($_REQUEST($name));
?
數(shù)據(jù)庫搜索部分:
?php
$sql="select * form table where greenKind like '%".$name."%'";
$server='localhost';
$username='root';
$password='12345678';
$db='mycounter';
$conn=mysql_connect($server,$username,$password,$db);
$result=mysql_query($sql);
$row=mysql_fetch_array($result);取結(jié)果中的一行
foreach($row as $col)
echo $col;//輸出每一個字段
?
網(wǎng)頁名稱:php輸入時顯示數(shù)據(jù)庫 php里輸出數(shù)據(jù)庫數(shù)據(jù)函數(shù)
本文網(wǎng)址:http://fisionsoft.com.cn/article/ddoidij.html