|
|
|
พี่ๆครับช่วยดูโค็ดตัวนี้ให้ผมหน่อยครับ การดึงไฟล์มาดาวโหลด พวก .doc |
|
|
|
|
|
|
|
ดฟห่กดา่ฟสาห่กดาสฟสาหก
ฟหกาดวฟา่หกาสด่วฟกา
คุณว่า ทอดไก่ มันอยู่ในตัวอักษรอะไร ครับ
คำตอบคือ ไม่รู้
ผมก็ไม่รู้ว่าตัวแปรคุณอะไรเก็บอะไร ใครเขาจะเดาให้
คำถามแบบนี้ จะโดนตอบน้อยมากนะครับ
ยังไงก็กำกับค่าตัวแปรมาหน่อยว่าอะไรคืออะไร และยกฟังก์ชั่นมาให้ครบ ๆ ไม่งั้นเขาเดาคำถามคุณไม่ออกแน่ ๆ เลยหละ
|
|
|
|
|
Date :
2009-09-17 14:44:07 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่ครับส่วนนี้มันจะแสดงหัวข้อข่าวนะครับ
Code (PHP)
<?php
session_start();
include("Includes/PortalConection.php");
include("Includes/Database.php");
include("Includes/Page.php");
//$strTable="";
//$strTable=TableBodyList($strsql,"","","","",3);
//$strTable=TableMenuList($strsql,"","","","",3);
?>
<HTML>
<HEAD>
<TITLE><?php print PortalTitle ?> </TITLE>
<?php
include ("Includes/Styles.php");
?>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"></HEAD>
<BODY>
<table width="761" height="232" border="0">
<tr>
<td height="87" colspan="2"><img src="image/koh.jpg" width="1024" height="132"></td>
</tr>
<tr>
<td width="155"><p><img src="image/close_topic.gif" width="16" height="16" /><a href="Admin/News/AddModifyInput.php">เพิ่มข่าวใหม่</a></p>
<p><img src="image/close_topic.gif" width="16" height="16" /><a href="Admin/News/List.php">ปรับปรุง/แก้ไขข่าว</a></p>
<p><a href="Logout.php"><img src="image/close_topic.gif" width="16" height="16" border="0" />ออกจากระบบ</a></p>
<p>-----------------------</p></td>
<td width="590"><form action="" method=POST id=frmForm name=frmForm>
<table border=0 align=center width =80%>
<p>*แสดงหัวข้อข่าวล่าสุด*</p>
<p>
<? $numentries=PageSize;
//declares number of entries per page to display
global $start;
//declares start as a global variable
if(!isset($start))
{
$start=0;
//if start is not set, set it to zero
}
$strsql="";
$strsql = "SELECT id as 'ID', title as 'News', DATE_FORMAT(newsdate,'%m/%d/%y') as 'Date' ";
$strsql .=" FROM news_t_newsdetails ";
$strsql .=" WHERE active='Y' ";
$strsql .=" AND DATE_FORMAT(expirydate,'%m/%d/%y') >= DATE_FORMAT(NOW(),'%m/%d/%y')";
$strsql .=" ORDER BY id DESC";
$strsql .=" LIMIT $start,$numentries";
//selects entries from start to number of entires after start
$strTable="";
$strTable=TableMenuList($strsql,"","","","",3);
print $strTable;
print "</TABLE>";
//print "</TD></TR><TR><TD>";
//print "<TABLE border=0 align=right width =80%><TR><TD>";
//$d=0;
//$f=0;
//$g=1; //we use these three variables to keep track of counts
//$strsql="SELECT * ";
//$strsql .=" FROM news_t_newsdetails ";
//$strsql .=" WHERE active='Y' ";
//$strsql .=" AND DATE_FORMAT(expirydate,'%m/%d/%y') >= DATE_FORMAT(NOW(),'%m/%d/%y')";
//$r2=mysql_query($strsql);
// print "<H5 align=right>";
//while($order3=mysql_fetch_array($r2))
//{
// if($f%$numentries==0)
// {
// print "<A href='index.php?start=$d'>$g</a> ";
// $g++;
// }
// $d=$d+1;
// $f++;
//}
//print "</TD>";print "</TR>";
//print "</TABLE>";
//print "</TD>";print "</TR>";
//print "</TABLE>";
?>
</p>
</form></td>
</tr>
</table>
<p> </p>
</BODY>
</HTML>
|
|
|
|
|
Date :
2009-09-17 14:56:48 |
By :
somsak84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่ครัยส่วนนีมันจะแสดงรายละเอียดข่าวครับ
Code (PHP)
<?php
session_start();
include ("Includes/PortalConection.php");
include ("Includes/Database.php");
if (!isset($_GET['ID']))
{
$strID="";
}
else
{
$strID=QuerySafeString($_GET["ID"]);
}
$conclass =new DataBase();
$strnewsdetails="";
$strtitle="";
if (($strID != "") && ($strID != "0"))
{
$strsql = "SELECT id , title,newsdescription FROM news_t_newsdetails" ;
$strsql .=" WHERE id='".$strID."'";
$strError="";
$rst= $conclass->Execute ($strsql,$strError);
if ($strError != "")
{
print $strError;
}
else
{
while ($line = mysql_fetch_array($rst, MYSQL_ASSOC))
{
$strID=$line['id'];
$strtitle=$line['title'];
$strnewsdetails=$line['newsdescription'];
}
}
}
?>
<HTML>
<HEAD>
<TITLE><?php if ($strID != "" ){ print $strtitle;}?></TITLE>
<?php
include ("Includes/Styles.php");
?>
<SCRIPT LANGUAGE=javascript>
<!--
function goBack() {
history.go(-1);
}
//-->
</SCRIPT></HEAD>
<BODY>
<p>::รายละเอียดข่าว::</p>
<p><A HREF=index.php>หน้าหลัก</A></p>
<FORM action="" method=POST id=frmForm name=frmForm>
<TABLE border=0 width=98% align=center>
<TR>
<TD height="22"><p><B>:::::หัวข้อข่าว:::::</B></p>
<p><B><?php print $strtitle?></B></p></TD>
</TR>
<TR>
<TD>:::::เนื้อหาข่าว:::::</p>
<p><?php print $strnewsdetails?>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
|
|
|
|
|
Date :
2009-09-17 15:01:22 |
By :
somsak84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แต่ผมอยากให้พี่ดูก็คือเวลาคลิกหัวข้อข่าวให้มัน ขึ้นdownload file เลยครับ
นี้เป็นส่วนของดาต้าเบสครับ
Code (PHP)
<?php
function Redirect($pstrPath_file)
{
header("Location: ".$pstrPath_file);
}
function killChars($strWords)
{
$badChars = array("select", "drop", ";", "--", "insert", "delete","Update");
$newChars = array("", "", "", "", "", "", "");
$strWords = str_replace($badChars, $newChars, $strWords);
return $strWords;
}
function NewLineinHTML($pstrString)
{
$badChars = array("\n");
$newChars = array("<BR>");
$pstrString = str_replace($badChars, $newChars, $pstrString);
return $pstrString;
}
function NewLinefromHTML($pstrString)
{
$badChars = array("<BR>");
$newChars = array("\n");
$pstrString = str_replace($badChars, $newChars, $pstrString);
return $pstrString;
}
function SQLSafeString($pstrString)
{
$badChars = array("'","\'");
$newChars = array("''","''");
$pstrString = str_replace($badChars, $newChars, $pstrString);
return $pstrString;
}
function JSSafeString($pstrString)
{
$badChars = array("'");
$newChars = array("\'");
$pstrString = str_replace($badChars, $newChars, $pstrString);
return $pstrString;
}
function QuerySafeString($pstrString)
{
$badChars = array("\'");
$newChars = array("'");
$pstrString = str_replace($badChars, $newChars, $pstrString);
$pstrString=killChars($pstrString);
return $pstrString;
}
class Database
{
function Database()
{
/* Connecting, selecting database */
$link = mysql_connect(HOSTM, dbUser, dbPassword)
or die("Could not connect : " . mysql_error());
//print "Connected successfully";
mysql_select_db(dbToUse) or die("Could not select database");
}
function Execute($strSQL,$strErrorMessages)
{
$result = mysql_query($strSQL) or die("Query failed : " . mysql_error());
return $result;
}
}
function ComboBoxOptionList($pstrSQL,$pstrSelectedValue)
{
$datab = new Database();
$rst= $datab->Execute ($strsql,$strTempResults);
$strTemp = "";
if ($strTempResults =="")
{
while ($line = mysql_fetch_array($rst, MYSQL_ASSOC))
{
$strTemp=$line['CODE'];
$strTemp1=$line['VALUE'];
if ($pstrSelectedValue==$strTemp)
{
$strTempResults .= "<OPTION SELECTED VALUE='".$strTemp . "'>". $strTemp1 . "</OPTION>";
}
else
{
$strTempResults .= "<OPTION VALUE='".$strTemp."'>".$strTemp1."</OPTION>";
}
}
}
else
{
$strTempResults = "<OPTION VALUE=''>" . $strTempResults . "</OPTION>";
}
return $strTempResults;
}
function TableBodyList($pstrSQL,$pstrHeaderRowParameters,
$pstrHeaderColumnParameters,
$pstrDataRowParameters,
$pstrDataColumnParameters,
$intFieldCount)
{
$strTemp="";
$datab = new Database;
$result=$datab->Execute($pstrSQL,$strTemp);
if ($strTemp!="")
{
$strTemp="<TR ".$pstrDataRowParameters."><TD ".$pstrDataColumnParameters.">".$strTemp + "</TD></TR>";
}
else
{
$strTemp="";$iCount=0;
$strTemp="<TR ".$pstrHeaderRowParameters . ">";
for ($i = 0;$i<$intFieldCount;$i++)
{
$strTemp.= "<TH " .$pstrHeaderColumnParameters .">" . mysql_field_name($result, $i)."</TH>";
}
if ($_SESSION["Admin"] =="Y") {
$strTemp.= "<TH " .$pstrHeaderColumnParameters.">Delete</TH>";
}
$strTemp.= "</TR>";
//$strTemp=+ "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
//$strTemp=+ "\t<tr>\n";
$strTemp.= "\t<TR ".$pstrDataRowParameters .">\n";
$iCount=0;$strKey="";
foreach ($line as $col_name)
{
if ($iCount==0)
{
$strKey=$col_name;
$strTemp.="<TD ".$pstrDataColumnParameters ."><A HREF =\"javaScript:ModifyData('". $strKey ."')\" >" ;
$strTemp.= $strKey ."</A></TD>";
$iCount=1;
}
else
{
$strTemp.= "\t\t<TD " .$pstrDataColumnParameters. ">". $col_name. "</TD>\n";
//$strTemp=+ "\t\t<td>$col_name</td>\n";
}
}
if ($_SESSION["Admin"] =="Y") {
$strTemp.= "<TD " .$pstrDataColumnParameters . "><A HREF =\"javaScript:DeleteData('" . $strKey . "')\">Delete</TD>";
}
$strTemp.= "\t</tr>\n";
}
//$strTemp.= "</table>\n";
}
return $strTemp;
}
function TableMenuList($pstrSQL,$pstrHeaderRowParameters, $pstrHeaderColumnParameters,$pstrDataRowParameters, $pstrDataColumnParameters,$intFieldCount)
{
$datab = new Database();
$strTemp="";
$rst= $datab->Execute ($pstrSQL,$strTemp);
if ($strTemp!="")
{
$strTemp="<TR ".$pstrDataRowParameters . "><TD " .$pstrDataColumnParameters . ">" . $strTemp . "</TD></TR>";
return $strTemp;
}
else
{
$strTemp="";
//$strTemp="";
while ($line = mysql_fetch_array($rst, MYSQL_ASSOC))
{
$strTemp2=$line['News'];
$strTemp1=$line['ID'];
$strTemp3=$line['Date'];
$strTemp.= "<TR ".$pstrDataRowParameters.">";
$strTemp.="<TD ".$pstrDataColumnParameters."><A HREF =\"NewsDetails.php?ID=" .$strTemp1. "\" >".$strTemp2. "</A></TD>";
$strTemp.="<TD ".$pstrDataColumnParameters.">" .$strTemp3. "</TD>";
$strTemp.= "</TR>";
}
}
return $strTemp;
}
function getTitleBody($pstrHTML)
{
$strTemp=strtoupper($pstrHTML);
$pstrTitle="";
$intFirst= strpos($strTemp , "<TITLE>");
$intLast= strpos($strTemp, "</TITLE>");
if ($intFirst !== FALSE)
{
if ($intLast!==FALSE)
{
if ($intLast>$intFirst)
{
$intFirst=$intFirst+7;
$pstrTitle= substr($pstrHTML,$intFirst,$intLast-$intFirst);
}
}
}
$pstrBody="";
$pstrNoBODY="";
$pstrHead="";
$intFirst= strpos($strTemp, "<BODY");
$intLast= strpos($strTemp, "</BODY>");
if ($intFirst!==FALSE)
{
if ($intLast !== FALSE)
{
if ($intLast > $intFirst)
{
$intFirst1= strpos(substr($strTemp,$intFirst),">")+$intFirst+1;
$pstrHead=substr($pstrHTML, 0,$intFirst1);
$intFirst=$intFirst1;
$pstrBody= substr($pstrHTML,$intFirst,$intLast-$intFirst);
$pstrNoBODY=substr($pstrHTML,$intLast);
//print $pstrNoBODY;
}
}
}
$arr = array("TITLE" =>"","BODY" =>"","NOBODY" =>"","HEAD" =>"");
$arr["TITLE"]=$pstrTitle;
$arr["BODY"]=$pstrBody;
$arr["NOBODY"]=$pstrNoBODY;
$arr["HEAD"]=$pstrHead;
//$arr["TITLE","BODY","NOBODY","HEAD"];
return $arr;
}
function FormatingOriginalHTML($pstrHTML)
{
$pstrHTML =str_replace('/\\/\\/\\','"',$pstrHTML);
$pstrHTML =str_replace('>','>',$pstrHTML);
$pstrHTML =str_replace('<','<',$pstrHTML);
return $pstrHTML;
}
function SaveFile($filename,$somecontent,$opentype)
{
if ($opentype=="N")
{
$strOpen="w+";
}
elseif ($opentype=="E")
{
$strOpen="w+";
}
else
{
return "Specified open type is wrong";
}
// Let's make sure the file exists and is writable first.
if (is_writable($filename) || ($opentype=="N")) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, $strOpen)) {
return "Cannot open file ($filename)";
}
// Write $somecontent to our opened file.
if (fwrite($handle, stripslashes($somecontent)) === FALSE) {
return "Cannot write to file ($filename)";
}
fclose($handle);
}
else
{
return "The file $filename is not writable";
}
}
function DateFormatMysql($pstrDate)
{//return $pstrDate;
$intPos=strpos($pstrDate,'-');
if ($intPos === false) {
$intPos=strpos($pstrDate,'/');
if ($intPos === false) {
$strMonth="";
$strDay="";
$strYear="";
return "";
} else {
$strMonth=substr($pstrDate,0,$intPos);
$intPos1=strpos($pstrDate,'/',$intPos+1);
$strDay=substr($pstrDate,$intPos+1,$intPos1-($intPos+1));
$strYear=substr($pstrDate,$intPos1+1) ;
}
} else {
$strMonth=substr($pstrDate,1,$intPos);
$intPos1=strpos($pstrDate,'-',$intPos);
$strDay=substr($pstrDate,$intPos+1,$intPos1-($intPos+1));
$strYear=substr($pstrDate,$intPos1+1) ;
}
return $strYear.'-'.$strMonth.'-'.$strDay;
}
?>
|
|
|
|
|
Date :
2009-09-17 15:05:57 |
By :
somsak84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|