新聞中心
求一個上報日產(chǎn)量的PHP源碼(內(nèi)詳)?
//open file
成都創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站建設(shè)、做網(wǎng)站與策劃設(shè)計,朔城網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十余年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:朔城等地區(qū)。朔城做網(wǎng)站價格咨詢:13518219792
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
//write file
$stringData = "Bobby Bopper\n";
fwrite($fh, $stringData);
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData);
fclose($fh); //close
參考資料:
phpnow安裝好,環(huán)境配置好后,怎么運行網(wǎng)上下載的php做的系統(tǒng)源碼呢,有數(shù)據(jù)庫的,求解答。
PHPnow是Win32下綠色免費的Apache + PHP + MySQL 環(huán)境套件包,詳細(xì)可以看看
要搞清楚的是,它是包含PHP環(huán)境和一些管理服務(wù)組件的,可以理解為一個帶各種管理平臺的PHP環(huán)境安裝包,
要運行PHP做的系統(tǒng)源碼不是相對PHPNOW而言的,是相對APACHE+PHP而言的,你只要把文件放在APACHE的虛擬目錄就可以了。以下是設(shè)置步驟:
1.安裝PHPNOW,比較簡單,不詳細(xì)說了,一定要安裝了,打開“Setup.cmd”會提示選擇安裝APACHE和MYSQL的,選22,51分別安裝兩個軟件的較新版本。
2.初始化,可以打開“Init.cmd”設(shè)置,(其實1步驟已經(jīng)提示是否初始化化了,選擇Y就可以了)
3.向?qū)瓿珊髸詣哟蜷_“127.0.0.1”的地址,這個是本機(jī)的虛擬路徑,頁面顯示了很多配置信息,你提問的是問題答案就在這里了
4.找到“網(wǎng)站主目錄”,一般會是你安裝的目錄下的一個“htdocs”文件夾,只要把PHP程序拷貝進(jìn)去就可以運行的,如下載了一個源碼文件夾是“aaa”,拷貝過去后使用瀏覽器訪問“127.0.0.1/aaa/”一般都能自動打開aaa里面的index.html或index.php文件。
5.有數(shù)據(jù)庫怎么辦?數(shù)據(jù)庫信息在“127.0.0.1”頁面的“MySQL 連接測試”欄上,一般下載的源碼如果有數(shù)據(jù)庫都會有一個數(shù)據(jù)庫連接文件的,里面會要連接地址、數(shù)據(jù)庫名稱、用戶、密碼等需要填寫的,改為“MySQL 連接測試”欄上對應(yīng)的就可以了。
按照以上步驟應(yīng)該是沒有問題的,因為不能截圖所有要慢慢理解哦,PHPNOW是輔助配置軟件,因為我們手動逐個配置PHP環(huán)境和常用工具比較繁瑣,所以有這些產(chǎn)品輔助安裝配置,但也讓很多初學(xué)的理解不到系統(tǒng)的運行結(jié)構(gòu),出問題都不知道如何入手,簡單地說,如果只是為了運行你的源碼,安裝APACHE+PHP+MYSQL就可以了,另外,你也可以在網(wǎng)上找一下免費的空間,也可以省了在固定電腦安裝的麻煩,開發(fā)的程序放上空間,任何地方都能調(diào)試開發(fā)。
PHP 怎么顯示數(shù)據(jù)庫中的數(shù)據(jù) 求源代碼
讀數(shù)據(jù)庫,以表格輸出的示例代碼:
?php
header('Content-type:text/html;charset=utf-8');
$db = new mysqli('localhost','root','root','books');
$rows = $db-query('SELECT * FROM customers');
echo 'table border="1"trtd姓名/tdtd年齡/td/tr';
while($row = $rows-fetch_assoc()){
echo 'trtd'.$row['name'].'/td';
echo 'td'.$row['address'].'/td/tr';
}
?
學(xué)生管理系統(tǒng)php源碼誰有
php學(xué)生管理系統(tǒng)源碼,供大家參考,具體內(nèi)容如下
功能:
1.添加/刪除/修改
2.數(shù)據(jù)存儲.
界面分布:
index.php
---主界面
add.php ---stu添加
action --- sql中add/del/update
(處理html表單--mysql的數(shù)據(jù)存儲 && 頁面跳轉(zhuǎn))
edit.php ---stu修改
menu.php
--首頁
1. index.php
!DOCTYPE html
html lang="en"
head
meta charset="UTF-8"
title學(xué)生信息管理/title
script
function doDel(id) {
if(confirm('確認(rèn)刪除?')) {
window.location='action.php?action=delid='+id;
}
}
/script
/head
body
center
?php
include ("menu.php");
?
h3瀏覽學(xué)生信息/h3
table width="500" border="1"
tr
thID/th
th姓名/th
th性別/th
th年齡/th
th班級/th
th操作/th
/tr
?php
// 1. 鏈接數(shù)據(jù)庫
try{
$pdo = new PDO("uri:mysqlPdo.ini","root","1");
}catch (PDOException $e) {
die('connection failed'.$e-getMessage());
}
//2.執(zhí)行sql
$sql_select = "select * from stu";
//3.data 解析
foreach ( $pdo-query($sql_select) as $row) {
echo "tr";
echo "th{$row['id']} /th";
echo "th{$row['name']}/th";
echo "th{$row['sex']} /th";
echo "th{$row['age']} /th";
echo "th{$row['classid']}/th";
echo "td
a href='edit.php?id={$row['id']}'修改/a
a href='javascript:void(0);' onclick='doDel({$row['id']})'刪除/a
/td";
echo "/tr";
}
?
/table
/center
/body
/html
2. add.php
!DOCTYPE html
html lang="en"
head
meta charset="UTF-8"
title學(xué)生管理系統(tǒng)/title
/head
body
center
?php include ('menu.php'); ?
h3增加學(xué)生信息/h3
form action="action.php?action=add" method="post"
table
tr
td姓名/td
tdinput type="text" name="name"/td
/tr
tr
td年齡/td
tdinput type="text" name="age"/td
/tr
tr
td性別/td
tdinput type="radio" name="sex" value="男"男/td
tdinput type="radio" name="sex" value="女"女/td
/tr
tr
td班級/td
tdinput type="text" name="classid"/td
/tr
tr
!-- td /td--
tda href="index.php"返回/td
tdinput type="submit" value="添加"/td
tdinput type="reset" value="重置"/td
/tr
/table
/form
/center
/body
/html
3. action.php
?php
/**
* Created by PhpStorm.
* User: hyh
* Date: 16-7-7
* Time: 下午9:37
*/
//1. 鏈接數(shù)據(jù)庫
try{
$pdo = new PDO("uri:mysqlPdo.ini","root","1");
}catch (PDOException $e) {
// echo 'Connection failed: ' . $e-getMessage();
die('connection failed'.$e-getMessage());
}
//2.action 的值做對操作
switch ($_GET['action']){
case 'add'://add
$name = $_POST['name'];
$sex = $_POST['sex'];
$age = $_POST['age'];
$classid = $_POST['classid'];
$sql = "insert into stu (name, sex, age, classid) values ('{$name}', '{$sex}','{$age}','{$classid}')";
$rw = $pdo-exec($sql);
if ($rw 0){
echo "scriptalter('添加成功');/script";
}else{
echo "scriptalter('添加失敗');/script";
}
header('Location: index.php');
break;
case 'del'://get
$id = $_GET['id'];
$sql = "delete from stu where id={$id}";
$rw = $pdo-exec($sql);
if ($rw 0){
echo "scriptalter('刪除成功');/script";
}else{
echo "scriptalter('刪除失敗');/script";
}
header('Location: index.php');
break;
case 'edit'://post
$id = $_POST['id'];
$name = $_POST['name'];
$age = $_POST['age'];
$classid = $_POST['classid'];
$sex = $_POST['sex'];
// echo $id, $age, $age, $name;
$sql = "update stu set name='{$name}', age={$age},sex='{$sex}',classid={$classid} where id={$id};";
// $sql = "update myapp.stu set name='jike',sex='女', age=24,classid=44 where id=17";
print $sql;
$rw = $pdo-exec($sql);
if ($rw 0){
echo "scriptalter('更新成功');/script";
}else{
echo "scriptalter('更新失敗');/script";
}
header('Location: index.php');
break;
default:
header('Location: index.php');
break;
}
4.edit.php
!DOCTYPE html
html lang="en"
head
meta charset="UTF-8"
title學(xué)生管理系統(tǒng)/title
/head
body
center
?php include ('menu.php');
//1. 鏈接數(shù)據(jù)庫
try{
$pdo = new PDO("uri:mysqlPdo.ini","root","1");
}catch (PDOException $e) {
die('connection failed'.$e-getMessage());
}
//2.執(zhí)行sql
$sql_select = "select * from stu where id={$_GET['id']}";
$stmt = $pdo-query($sql_select);
if ($stmt-rowCount() 0) {
$stu = $stmt-fetch(PDO::FETCH_ASSOC); // 解析數(shù)據(jù)
}else{
die("no have this id:{$_GET['id']}");
}
?
h3修改學(xué)生信息/h3
form action="action.php?action=edit" method="post"
input type="hidden" name="id" value="?php echo $stu['id'];?"
table
tr
td姓名/td
tdinput type="text" name="name" value="?php echo $stu['name'];?"/td
/tr
tr
td年齡/td
tdinput type="text" name="age" value="?php echo $stu['age'];?"/td
/tr
tr
td性別/td
td
input type="radio" name="sex" value="男" ?php echo ($stu['sex'] == "男")? "checked":"";? 男
/td
td
input type="radio" name="sex" value="女" ?php echo ($stu['sex'] == "女")? "checked":"";? 女
/td
/tr
tr
td班級/td
tdinput type="text" name="classid" value="?php echo $stu['classid']?"/td
/tr
tr
td /td
tdinput type="submit" value="更新"/td
tdinput type="reset" value="重置"/td
/tr
/table
/form
/center
?php
?
/body
/html
5. menu.php
!DOCTYPE html
html lang="en"
body
h2學(xué)生管理系統(tǒng)/h2
a href="index.php" 瀏覽學(xué)生/a
a href="add.php" 添加學(xué)生/a
hr
/body
/html
網(wǎng)頁標(biāo)題:php數(shù)據(jù)上報系統(tǒng)源碼,php顯示源碼
網(wǎng)站URL:http://fisionsoft.com.cn/article/dsehdhd.html