พอดีผมได้ code ที่เป็นภาษา asp จากเพื่อนมาครับ แต่ผมอยากได้ให้เป็นภาษา php จะต้องทำยังงั้ยครับ..มีทั้งหมด 7 code ครับ..ผมเพิ่งหัดเขียนภาษา php ได้ไม่นานครับ รบกวนพี่ๆ ที่รู้ช่วยหน่อยครับ..ความรู้เล็กๆ อาจเป็นวิทยาทานให้ผู้ที่เริ่มหัดเขียน ใหม่อย่างผมครับ..ขอบคุณครับ
code 1
<%
i=1
SqlText="Select * from songg where major='R' order by no "
Set RS= Server.CreateObject("ADODB.Recordset")
RS.open SqlText , Conn , 1 , 3
if not rs.eof then
%>
code2
<a href="javascript:newwin('music2.asp?id=<%=RS("no")%>&n=<%=RS("name")%>',688,515)" title="Online">[</a><%=RS("counter")%>]
code 3
<%
RS.Movenext
i=i+1
wend
RS.Close
%>
code 4
<%
i=1
SqlText="Select * from songg where major='A' order by no "
Set RS= Server.CreateObject("ADODB.Recordset")
RS.open SqlText , Conn , 1 , 3
if not rs.eof then
%>
code 5
<%
RS.Movenext
i=i+1
wend
RS.Close
Conn.Close
%>
code 6
<%
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb); DBQ=" & Server.MapPath("dbinformation.mdb")
id=request.QueryString("id")
namee=request.QueryString("n")
s=""
t=""
f=""
z=""
si=""
p=""
SqlText="Select * from songg where no = "&id
Set RS= Server.CreateObject("ADODB.Recordset")
RS.open SqlText , Conn , 1 , 3
if not RS.eof then
if request.querystring("ด")="1" then
s=RS("file")
else
s=RS("add")
end if
z=RS("zip")
m=RS("zip_mp3")
t=RS("textfile")
si=RS("sing")
p=RS("papan")
RS("counter")=RS("counter")+1
RS.Update
end if
RS.Close
Conn.close
%>
code 7
<%
if t<>"" then
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
MsgFile = Server.MapPath (t)
On Error Resume Next
Set InStream= FileObject.OpenTextFile (MSGFile, 1, False, False)
Response.Write Instream.ReadAll & "<BR>"
Set Instream=Nothing
else
response.Write("ไม่มี")
end if
%>
code 1
<%
i=1
SqlText="Select * from songg where major='R' order by no "
Set RS= Server.CreateObject("ADODB.Recordset")
RS.open SqlText , Conn , 1 , 3
if not rs.eof then
%>
code2
<a href="javascript:newwin('music2.asp?id=<%=RS("no")%>&n=<%=RS("name")%>',688,515)" title="Online">[</a><%=RS("counter")%>]
code 3
<%
RS.Movenext
i=i+1
wend
RS.Close
%>
code 4
<%
i=1
SqlText="Select * from songg where major='A' order by no "
Set RS= Server.CreateObject("ADODB.Recordset")
RS.open SqlText , Conn , 1 , 3
if not rs.eof then
%>
code 5
<%
RS.Movenext
i=i+1
wend
RS.Close
Conn.Close
%>
code 6
<%
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb); DBQ=" & Server.MapPath("dbinformation.mdb")
id=request.QueryString("id")
namee=request.QueryString("n")
s=""
t=""
f=""
z=""
si=""
p=""
SqlText="Select * from songg where no = "&id
Set RS= Server.CreateObject("ADODB.Recordset")
RS.open SqlText , Conn , 1 , 3
if not RS.eof then
if request.querystring("ด")="1" then
s=RS("file")
else
s=RS("add")
end if
z=RS("zip")
m=RS("zip_mp3")
t=RS("textfile")
si=RS("sing")
p=RS("papan")
RS("counter")=RS("counter")+1
RS.Update
end if
RS.Close
Conn.close
%>
code 7
<%
if t<>"" then
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
MsgFile = Server.MapPath (t)
On Error Resume Next
Set InStream= FileObject.OpenTextFile (MSGFile, 1, False, False)
Response.Write Instream.ReadAll & "<BR>"
Set Instream=Nothing
else
response.Write("ไม่มี")
end if
%>
จากโค๊ดนี้ต้องการแปลงเป็น PHP เพื่อใช้งานบน OS ใดครับฐานข้อมูลเป็น Access เหมือนเดิมหรือไม่ครับ แล้วต้องการให้แบ่งเป็น 7 ส่วนเช่นเดิมหรือไม่อย่างไรครับ
Davinci

Thu 25 May 2006 19:17:10
Thu 25 May 2006 19:17:10
เอางั้นเลยหรอครับ...
เท่าที่ดูมีโค๊ด 6 เท่านั้นที่พอจะเป็นโปรแกรมอยู่บ้าง ที่เหลือแปลงไปก็ไม่สามารถเอาไปใช้งานได้เพราะตัดมาแค่ส่วนหนึ่งของชุดคำสั่งเอาไปรันก็ error นะครับ
เท่าที่ดูมีโค๊ด 6 เท่านั้นที่พอจะเป็นโปรแกรมอยู่บ้าง ที่เหลือแปลงไปก็ไม่สามารถเอาไปใช้งานได้เพราะตัดมาแค่ส่วนหนึ่งของชุดคำสั่งเอาไปรันก็ error นะครับ
bluedream

Tue 30 May 2006 15:15:46
Tue 30 May 2006 15:15:46
ฐานข้อมูลเป็น Access ครับ
code 1
<?
$i=1;
$SqlText="Select * from songg where major='R' order by no ";
$link = odbc_connect($dsn, $user, $pass);
$res = odbc_query($SqlText, $link);
while($row = odbc_fetch_array($res)){
?>
code2
<a href="javascript:newwin('music2.asp?id=<? echo $row["no"]; ?>&n=<? echo $row["name"]; ?>',688,515)" title="Online">[</a><? echo $row["counter"]; ?>]
code 3
<?
}
odbc_free_result($res);
?>
code 4
<?
$i=1;
$SqlText = "Select * from songg where major='A' order by no ";
$res = odbc_query($SqlText, $link);
while($row = odbc_fetch_array($res)){
?>
code 5
<?
$i++
}
odbc_free_result($res);
odbc_close($link);
?>
code 6
<?
$link = odbc_connect($dsn, $user, $pass);
$id = $_GET["id"];
$namee = $_GET["n"];
$s="";
$t="";
$f="";
$z="";
$si="";
$p="";
$SqlText = "Select * from songg where no = ".$id;
$res = odbc_query($SqlText, $link);
while($row = odbc_fetch_array($res)){
if($_GET["ด"] == "1"){
$s = $row["file"];
}else{
$s = $row["add"];
}
$z = $row["zip"];
$m = $row["zip_mp3"];
$t = $row["textfile"];
$si = $row["sing"];
$p = $row["papan"];
odbc_query("UPDATE songg SET counter=counter+1 WHERE no = ".$id);
}
odbc_close($link);
?>
code 7
<?
if($t != ""){
$FileObject = fopen($t, "r");
$InStream = fread($FileObject, filesize($t));
echo $InStream."<BR>";
fclose($FileObject);
}else{
echo "ไม่มี";
}
?>
<?
$i=1;
$SqlText="Select * from songg where major='R' order by no ";
$link = odbc_connect($dsn, $user, $pass);
$res = odbc_query($SqlText, $link);
while($row = odbc_fetch_array($res)){
?>
code2
<a href="javascript:newwin('music2.asp?id=<? echo $row["no"]; ?>&n=<? echo $row["name"]; ?>',688,515)" title="Online">[</a><? echo $row["counter"]; ?>]
code 3
<?
}
odbc_free_result($res);
?>
code 4
<?
$i=1;
$SqlText = "Select * from songg where major='A' order by no ";
$res = odbc_query($SqlText, $link);
while($row = odbc_fetch_array($res)){
?>
code 5
<?
$i++
}
odbc_free_result($res);
odbc_close($link);
?>
code 6
<?
$link = odbc_connect($dsn, $user, $pass);
$id = $_GET["id"];
$namee = $_GET["n"];
$s="";
$t="";
$f="";
$z="";
$si="";
$p="";
$SqlText = "Select * from songg where no = ".$id;
$res = odbc_query($SqlText, $link);
while($row = odbc_fetch_array($res)){
if($_GET["ด"] == "1"){
$s = $row["file"];
}else{
$s = $row["add"];
}
$z = $row["zip"];
$m = $row["zip_mp3"];
$t = $row["textfile"];
$si = $row["sing"];
$p = $row["papan"];
odbc_query("UPDATE songg SET counter=counter+1 WHERE no = ".$id);
}
odbc_close($link);
?>
code 7
<?
if($t != ""){
$FileObject = fopen($t, "r");
$InStream = fread($FileObject, filesize($t));
echo $InStream."<BR>";
fclose($FileObject);
}else{
echo "ไม่มี";
}
?>

















