|
|
|
ช่วยแนะนำหน่อยครับ เกี่ยวกับ php งง มากๆไม่รู้จะแก้ตรงส่วนไหนครับ |
|
|
|
|
|
|
|
คือผมเปลี่ยน Ser. จาก app ser เป็น xampp พอติดตั้งเรียบร้อย ผม import ไฟล์ SQL เข้ามา แตพอมช้งานไม่สามารถใช้งานได้ครับ
Code (PHP)
<?php
session_start();
if($_SESSION['UserID'] == "")
{
echo "Please Login!";
exit();
}
if($_SESSION['Status'] != "USER")
{
echo "This page for User only!";
exit();
}
mysql_connect("localhost","root","root");
mysql_select_db("member");
$strSQL = "SELECT * FROM member WHERE UserID = '".$_SESSION['UserID']."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<title>
Pissanu Pongoubon Test
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
// ???????????????????
$host="localhost"; // ????? host
$username="root"; // ????? username
$pass_word="root"; // ????? Password
$db="test_create_database"; // ??????????????????
$Conn = mysql_connect( $host,$username,$pass_word) or die ("?????????????????????");// ???????????????
mysql_query("SET NAMES utf8",$Conn); // set ?????????????
mysql_select_db($db) or die("????????????????????"); // ??????????????
//--->
{
$del_id = $_REQUEST['del_id'];
$sql_del = "delete from customer where id = '$del_id';";
mysql_query($sql_del) or die(mysql_error());
}
?><style type="text/css">
<!--
a:link {
color: #0000FF;
text-decoration: none;
}
a:visited {
color: #0000FF;
text-decoration: none;
}
a:hover {
color: #0000FF;
text-decoration: none;
}
a:active {
color: #0000FF;
text-decoration: none;
}
body,td,th {
color: #000000;
}
body {
background-color: #99FFCC;
}
.style6 {color: #FF0000}
.style7 {
font-size: 18px;
font-weight: bold;
}
.style9 {color: #0000FF}
.style15 {color: #000000}
.style16 {font-size: 12px}
.style17 {font-size: 16px}
-->
-->login
-->
</style>
<table width="2542" height="100" border="1">
<tr>
<td width="200" height="100"><table width="228" border="1" style="width: 250
px">
<tbody>
<tr>
<td width="84"> Username</td>
<td width="128"><?php echo $objResult["Username"];?> <div align="center"></div></td>
</tr>
<tr>
<td height="23"> Name</td>
<td><?php echo $objResult["Name"];?></td>
</tr>
</tbody>
</table>
<a href="edit_profile.php">Edit</a><br />
<a href="logout.php">Logout</a></td>
<td width="2326"> </td>
</tr>
</table>
<table width="2542" height="55" border="1">
<tr>
<td width="265" height="49"><img src="Img/A.jpg"width="275" height="45" /></td>
<td width="2261"><table width="597" border="1"cellspacing="0" cellpadding="0"bgcolor="#FFFF99"bordercolor="#FF9900">
<tr>
<th width="393" height="40" align="center" ><form id="form1" name="form1" method="post" action="show.php"><div align="center">search
<input name="txt_search" type="text" value="<?=$_POST['txt_search']?>" />
<input name="Search" type="submit" value="search" />
</div>
</form></th>
<th width="84" scope="col"><a href="add_form.php?edit_id=<?=$row_show[id]?>">Add data</a></th>
<th width="98" scope="col">
<!--#print Previwe -->
<script language="javascript">
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
</script>
<input name="btnPrint" type="button" id="btnPrint" value="Print" onClick="JavaScript:this.style.display='none';printpr();"></th>
</tr>
</table></td>
</tr>
</table>
<table width="2544" border="1">
<tr>
<th width="233" rowspan="2" valign="top" scope="col"><div align="left">
<table width="233" border="1"cellspacing="0" cellpadding="0"bgcolor="#FFFFFF"bordercolor="#FF3300">
<tr>
<th width="223" scope="col"><span class="style15">DIVISION / DEPARTMENT</span></th>
</tr>
<tr>
<td><span class="style9"><a href="..//SoftwareLicense/ADMINISTRATION.php"> ADMINISTRATION</a></span></td>
</tr>
<tr>
<td><span class="style9"><a href="..//SoftwareLicense/FINANCE & ACCOUNTING.php"> FINANCE & ACCOUNTING</a></span></td>
</tr>
<tr>
<td><span class="style9"> PUCHASING</span></td>
</tr>
<tr>
<td><span class="style9"> PLANNING</span></td>
</tr>
<tr>
<td><span class="style9"> EDP</span></td>
</tr>
<tr>
<td><span class="style9"> MAINTENANCE</span></td>
</tr>
<tr>
<td><span class="style9"> IMPORT & EXPORT</span></td>
</tr>
<tr>
<td><span class="style9"> MATERIAL </span></td>
</tr>
<tr>
<td><span class="style9"> ELECTRIC (PCB,HN,PP,TR,EL Eng.,)</span></td>
</tr>
<tr>
<td><span class="style9"><a href="..//SoftwareLicense/MATERIAL.php"> MATERIAL</a></span></td>
</tr>
<tr>
<td><span class="style9"> SHEET METAL</span></td>
</tr>
<tr>
<td><span class="style9"> CERAMICS</span></td>
</tr>
<tr>
<td><span class="style9"> DOCUMENT ART CENTRE</span></td>
</tr>
<tr>
<td><span class="style9"> ENGINEERING</span></td>
</tr>
<tr>
<td><span class="style9"> THAI TECHNICAL SUPPORT</span></td>
</tr>
<tr>
<td><span class="style9"> QUALITY CONTROL</span></td>
</tr>
<tr>
<td><span class="style9"> QUALITY ASSURANCE</span></td>
</tr>
<tr>
<td><span class="style9"> ASSEMBLY</span></td>
</tr>
<tr>
<td><span class="style9"> CUSTOMER SERVICE</span></td>
</tr>
<tr>
<td><span class="style9"> Notebook</span></td>
</tr>
<tr>
<td><span class="style9"></span></td>
</tr>
</table>
</div></th>
<th width="326" height="205" valign="top" scope="col">
<div align="left">
<table width="326" border="1" cellspacing="0" cellpadding="0"bgcolor="#FFFF99"bordercolor="#FF9900">
<tr>
<th width="109" scope="col"><div align="center"><span class="style6">Program</span></div></th>
<th width="67" scope="0"><div align="center"><span class="style6">Amount</span></div></th>
<th width="74" scope="col"><div align="center"><span class="style6">Use</span></div></th>
<th width="66" scope="col"> <div align="center"><span class="style6">Total</span> </div></th>
</tr>
<tr>
<td><div align="center">Office Excel </div></td>
<td><table width="68" border="0" cellspacing="2" cellpadding="2">
<?
$sql_show = "select * from test";
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td width="60"><div align="center">
<?=$row_show['excel2']?>
</div></td>
</tr>
<tr> </tr>
<?
}
?>
</table></td>
<td><div align="center">
<?php
// Make a MySQL Connection
$query = "SELECT excel, SUM(excel) FROM customer GROUP BY excel";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "". $row['']. " ". $row['SUM(excel)'];
echo "<br />";
}
?>
</div></td>
<td><div align="center">
<?PHP
$excel2 = 20;
$excel = 15;
echo " ".($excel2 - $excel );
echo "<br/>";
{
echo "</tr>";
$excel2 = $excel + ($row['excel2']*$row['excel']);
}
?>
</div></td>
</tr>
<tr>
<td><div align="center">Off.std</div></td>
<td><div align="center"><table width="68" border="0" cellspacing="2" cellpadding="2">
<?
$sql_show = "select * from test";
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td width="60"><div align="center">
<?=$row_show['offstd']?>
</div></td>
</tr>
<tr> </tr>
<?
}
?>
</table>
</div>
<div align="center"></div></td>
<td><div align="center"><?php
// Make a MySQL Connection
$query = "SELECT offstd, SUM(offstd) FROM customer GROUP BY offstd";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "". $row['']. " ". $row['SUM(offstd)'];
echo "<br />";
}
?>
</div></td>
</tr>
<tr>
<td><div align="center"><span class="style6 style15">Off.pro</span></div></td>
<td><div align="center"><table width="68" border="0" cellspacing="2" cellpadding="2">
<?
$sql_show = "select * from test";
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td width="60"><div align="center"><?=$row_show['offpro']?>
</div></td>
</tr>
<tr> </tr>
<?
}
?>
</table>
</div></td>
<td><div align="center"><?php
// Make a MySQL Connection
$query = "SELECT offpro, SUM(offpro) FROM customer GROUP BY offpro";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "". $row['']. " ". $row['SUM(offpro)'];
echo "<br />";
}
?></div></td>
<td> </td>
</tr>
<tr>
<td><div align="center"><span class="style15">Foxit</span></div></td>
<td><table width="68" border="0" cellspacing="2" cellpadding="2">
<?
$sql_show = "select * from test";
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td width="60"><div align="center">
<?=$row_show['foxit']?>
</div></td>
</tr>
<tr> </tr>
<?
}
?>
</table></td>
<td><div align="center"><?php
// Make a MySQL Connection
$query = "SELECT foxit, SUM(foxit) FROM customer GROUP BY foxit";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "". $row['']. " ". $row['SUM(foxit)'];
echo "<br />";
}
?></div></td>
<td> </td>
</tr>
<td><div align="center"><span class="style15"><table width="68" border="0" cellspacing="2" cellpadding="2">
<?
$sql_show = "select * from test";
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td width="60"><div align="center"><a href="edit1.php?edit_id=<?=$row_show[id]?>" class="style16">edit</a></div></td>
</tr>
<?
}
?>
</table>
</span></div></td>
</table>
</div></th>
<th width="1963" valign="top" scope="col"><div align="left">
<table width="326" border="1" cellspacing="0" cellpadding="0"bgcolor="#FFFF99"bordercolor="#FF9900">
<tr>
<th width="109" scope="col"><div align="center"><span class="style6">Program</span></div></th>
<th width="67" scope="0"><div align="center"><span class="style6">Amount</span></div></th>
<th width="74" scope="col"><div align="center"><span class="style6">Use</span></div></th>
<th width="66" scope="col"> <div align="center"><span class="style6">Total</span> </div></th>
</tr>
<tr>
<td><div align="center"><span class="style15">Acrobat</span></div></td>
<td><div align="center"><table width="68" border="0" cellspacing="2" cellpadding="2">
<?
$sql_show = "select * from test";
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td width="60"><div align="center">
<?=$row_show['acrobat']?>
</div></td>
</tr>
<tr> </tr>
<?
}
?>
</table></div></td>
<td><div align="center">
<?php
// Make a MySQL Connection
$query = "SELECT acrobat, SUM(acrobat) FROM customer GROUP BY acrobat";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "". $row['']. " ". $row['SUM(acrobat)'];
echo "<br />";
}
?>
</div></td>
<td><div align="center">
<?php
$Amount = 100;
$excel =4;
echo " ".( $Amount - $excel );
echo "<br/>";
?>
</div></td>
</tr>
<tr>
<td><div align="center"><span class="style15">Visio</span></div></td>
<td><div align="center"><div align="center"><table width="68" border="0" cellspacing="2" cellpadding="2">
<?
$sql_show = "select * from test";
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td width="60"><div align="center">
<?=$row_show['visio']?>
</div></td>
</tr>
<tr> </tr>
<?
}
?>
</table></div></div></td>
<td><div align="center">
<?php
// Make a MySQL Connection
$query = "SELECT visio, SUM(visio) FROM customer GROUP BY visio";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "". $row['']. " ". $row['SUM(visio)'];
echo "<br />";
}
?>
</div></td>
<td><div align="center">
<?php
$Amount = 100;
$offstd = 5;
echo " ".( $number1 - $offstd );
echo "<br/>";
?>
</div></td>
</tr>
<tr>
<td><div align="center"> </div></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div></th>
</tr>
<tr>
<td height="283" colspan="2" valign="top"><table width="2656" border="1" cellspacing="0" cellpadding="0"bgcolor="#FFFF99"bordercolor="#FF9900">
<br>
<tr>
<td width="87"><div align="center" class="style6"> PC</div></td>
<td width="83"><div align="center" class="style6">Monitor</div></td>
<td width="106"><div align="center" class="style6">NAME PC </div></td>
<td width="146"><div align="center" class="style6">LOCATION</div></td>
<td width="152"><div align="center" class="style6">CPU</div></td>
<td width="83"><div align="center" class="style6">RAM</div></td>
<td width="80"><div align="center" class="style6">HDD</div></td>
<td width="301"><div align="center" class="style6">OTHER</div></td>
<td width="79"><div align="center" class="style6">EMP.CODE</div></td>
<td width="51"><div align="center" class="style6">USER</div></td>
<td width="108"><div align="center" class="style6">USER CLASS</div></td>
<td width="116"><div align="center" class="style6">GROUP</div></td>
<td width="192"><div align="center" class="style6">EMAIL</div>
</div></td>
<td width="210"><div align="center" class="style6">OS</div></td>
<td width="50"><div align="center" class="style6">Excel</div></td>
<td width="46"><div align="center" class="style6">Off.std</div></td>
<td width="46"><div align="center" class="style6">Off.pro</div></td>
<td width="68"><div align="center" class="style6">Foxit</div></td>
<td width="50"><div align="center" class="style6">Acrobat</div></td>
<td width="50"><div align="center" class="style6">Visio</div></td>
<td width="331"><div align="center" class="style6">Other</div></td>
<td width="81"><div align="center" class="style6">IP Address</div></td>
<td width="41"><div align="center" class="style6">delete</div></td>
<td width="49"><div align="center" class="style6">edit</div></td>
</tr>
<?
$sql_show = "select * from customer";
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
?>
<?
$sql_show = "select * from customer";
if($_POST['Search'])
{
$txt_search = $_POST['txt_search'];
$sql_show.=" where '%$txt_search%' or email like '%$txt_search%' or pc like '%$txt_search%' or namepc like '%$txt_search%' or user like '%$txt_search%'or roup like '%$txt_search%' ";
}
$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show))
{
?>
<tr>
<td><div align="center"><?=$row_show['pc']?></div></td>
<td><div align="center"><?=$row_show['Monitor']?></div></td>
<td><div align="center"><?=$row_show['namepc']?></div></td>
<td><div align="center"><?=$row_show['location']?></div></td>
<td><div align="center"><?=$row_show['cpu']?></div></td>
<td><div align="center"><?=$row_show['ram']?></div></td>
<td><div align="center"><?=$row_show['hdd']?></div></td>
<td><div align="center"><?=$row_show['other']?></div></td>
<td><div align="center"><?=$row_show['empcode']?></div></td>
<td><div align="center"><?=$row_show['user']?></div></td>
<td><div align="center"><?=$row_show['userclass']?></div></td>
<td><div align="center"><?=$row_show['roup']?></div></td>
<td><div align="center"><?=$row_show['email']?></div></td>
<td><div align="center"><?=$row_show['os']?></div></td>
<td><div align="center"><?=$row_show['excel']?></div></td>
<td><div align="center"><?=$row_show['offstd']?></div></td>
<td><div align="center"><?=$row_show['offpro']?></div></td>
<td><div align="center"><?=$row_show['foxit']?></div></td>
<td><div align="center"><?=$row_show['acrobat']?></div></td>
<td><div align="center"><?=$row_show['visio']?></div></td>
<td><div align="center"><?=$row_show['other1']?></div></td>
<td><div align="center"><?=$row_show['ipaddress']?></div></td>
<td><div align="center"><a href="show.php?del_id=<?=$row_show[id]?>"onclick="return confirm('Are you sure you want to delete')">delete</a></div></td>
<td><div align="center"><a href="edit.php?edit_id=<?=$row_show[id]?>">edit</a></div></td
>
</tr>
<script language="JavaScript">
function Conf<? echo "$id" ?>(object)
{
if (confirm("Do you want to delete [ <? echo " $id " ?> ] ?") ==true)
{
return true;
}
return false;
}
</font>
</script>
<?
}
?>
</table>
<br>
<table width="597" border="1"cellspacing="0" cellpadding="0"bgcolor="#FFFF99"bordercolor="#FF9900">
<tr>
<th width="393" height="40" align="center" ><form id="form1" name="form1" method="post" action="show.php"><div align="center">search
<input name="txt_search" type="text" value="<?=$_POST['txt_search']?>" />
<input name="Search" type="submit" value="search" />
</div>
</form></th>
<th width="84" scope="col"><a href="add_form.php?edit_id=<?=$row_show[id]?>">Add data</a></th>
<th width="98" scope="col">
<!--#print Previwe -->
<script language="javascript">
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
</script>
<input name="btnPrint" type="button" id="btnPrint" value="Print" onClick="JavaScript:this.style.display='none';printpr();"></th>
</tr>
</table>
</tr>
</table>
<br />
<td width="135"><label></label></td>
<DIV id="report">
<!--#include file="include/css_div_print.inc" -->
</DIV>
<table width="2253" height="174" border="0">
<tr>
<th height="41" scope="col"><div id="div">
<table width="885" height="35" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#0000FF" style="background:#999999 url(img/bg_green_gradient.gif) left center repeat-x;">
<tr>
<td class="footdetail"><div align="center" class="style7">Copyright © 2015-2016 Sodick (Thailand) Co., Ltd. All Rights Reserved.</div></td>
</tr>
</table>
</div></th>
</tr>
<tr>
<th height="41" scope="col"> </th>
</tr>
</table>
<table width="1664" border="1">
</table>
รบกวนผู้รอบรู้ด้วยครับ งง มากๆครับ
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2015-11-05 11:24:36
|
|
|
|
|
Date :
2015-11-05 11:21:19 |
By :
pissanu8970 |
View :
889 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xampp เช็คพวก เครื่องหมายให้ถูกต้องด้วย พวก tag ย่อต่างๆ บางทีใช้ไม่ได้ ถ้าไม่ได้ไปเปิดก่อน
<? แก้เป็น <?php ให้หมด
|
|
|
|
|
Date :
2015-11-05 11:30:12 |
By :
progamer2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ตามแล้วครับ เหมือนจะได้ แต่ติดแบบนี้อีกหน่อยครับ
|
|
|
|
|
Date :
2015-11-05 11:38:24 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะเกี่ยวกับภาษารึเปล่าครับ
|
|
|
|
|
Date :
2015-11-05 11:45:38 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|