|
 |
|
select table ส่งค่ามาโชว์ในตาราง แล้ว จำค่าเดิมไม่ยอมเปลี่ยน ช่วยดูโค้ดให้หน่อยนะคะ |
|
 |
|
|
 |
 |
|
Code (PHP)
แสดงลิงค์
<a href="<? echo "show.php?idcode=$c_id"; ?>"><? echo "$cname";?>
ไฟล์โชว์
Code (PHP)
<?
$host="localhost";
$username="root";
$password="1234";
$db="train";
mysql_connect($host,$username,$password)or die("ติดต่อกับฐานข้อมูล MySql ไม่ได้");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
$cs1="SET character_set_results=tis620";
mysql_query($cs1) or die('Eror query:'.mysql_error());
$cs2="SET character_set_client=tis620";
mysql_query($cs2) or die('Eror query:'.mysql_error());
$cs3="SET character_set_connection=tis620";
mysql_query($cs3) or die('Eror query:'.mysql_error());
$c_id=$_GET['idcode'];
$sql="SELECT c_id, cname, caddress, zipcode,phone, fax, companytype.ctname, worktime.woname ,location.loname FROM company INNER JOIN companytype ON company.ctypeid = companytype.ctypeid INNER JOIN worktime ON company.worktimeid = worktime.worktimeid INNER JOIN location ON company.locationid = location.locationid ;";
$db_query=mysql_db_query($db,$sql);
$result=mysql_fetch_array($db_query);
$c_id=$result[c_id];
$cname=$result[cname];
$caddress=$result[caddress];
$zipcode=$result[zipcode];
$ctname=$result[ctname];
$woname=$result[woname];
$loname=$result[loname];
$phone=$result[phone];
$fax=$result[fax];
?>
<form id="form1" name="form1" method="post" action="">
<p align="center" class="style2">แสดงรายการข้อมูล</p>
<table width="626" border="0" align="center">
<tr>
<td width="150" bordercolor="0" bgcolor="#FF6699"><div align="right" class="style4">รหัส</div></td>
<td width="367" bordercolor="0" bgcolor="#FFC6FF"><? echo "$c_id";?></td>
</tr>
<tr>
<td bordercolor="0" bgcolor="#FF6699"><div align="right" class="style4">ชื่อสถานประกอบการ : </div></td>
<td bordercolor="0" bgcolor="#FFC6FF"><? echo "$cname";?> </td>
</tr>
<tr>
<td bordercolor="0" bgcolor="#FF6699"><div align="right" class="style4">ประเภทสถานประกอบการ : </div></td>
<td bordercolor="0" bgcolor="#FFC6FF"><? echo "$ctname";?></td>
</tr>
<tr>
<td bordercolor="0" bgcolor="#FF6699"><div align="right" class="style4">ที่อยู่ : </div></td>
<td bordercolor="0" bgcolor="#FFC6FF"><? echo "$caddress";?></td>
</tr>
<tr>
<td bordercolor="0" bgcolor="#FF6699"><div align="right" class="style4">เวลาทำการ : </div></td>
<td bordercolor="0" bgcolor="#FFC6FF"><? echo "$woname";?></td>
</tr>
<tr>
<td bordercolor="0" bgcolor="#FF6699"><div align="right" class="style4">พื้นที่ทำงาน : </div></td>
<td bordercolor="0" bgcolor="#FFC6FF"><? echo "$loname";?></td>
</tr>
<tr>
<td bordercolor="0" bgcolor="#FF6699"><div align="right" class="style4">เบอร์โทรศัพท์ : </div></td>
<td bordercolor="0" bgcolor="#FFC6FF"><? echo "$phone";?></td>
</tr>
<tr>
<td bordercolor="0" bgcolor="#FF6699"><div align="right" class="style4">เบอร์โทรสาร : </div></td>
<td bordercolor="0" bgcolor="#FFC6FF"><? echo "$fax";?></td>
</tr>
</table>
<p align="center" class="style3"><a href="com_list.php">กลับสู่หน้าจอแสดงรายการข้อมูล</a></p>
</form>


Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2010-09-27 08:30:18 |
By :
maltra |
View :
1039 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่แน่ใจว่าลืมใส่เงื่อนไข WHERE หรือป่าวครับ ....
|
 |
 |
 |
 |
Date :
2010-09-27 09:03:27 |
By :
EvoLutionGT |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
echo $sql;
ลองเอาไปทดสอบใน phpMyAdmin ดูน่ะครับ ว่าสามารถ Query ได้ตามที่ต้องการหรือเปล่าครับ
|
 |
 |
 |
 |
Date :
2010-09-27 09:04:25 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากมายค่ะ ลืมใส่ where c_id=$c_id    
|
 |
 |
 |
 |
Date :
2010-09-27 10:45:44 |
By :
maltra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
SELECT c_id, cname, caddress, zipcode,phone, fax, companytype.ctname, worktime.woname ,location.loname FROM company INNER JOIN companytype ON company.ctypeid = companytype.ctypeid INNER JOIN worktime ON company.worktimeid = worktime.worktimeid INNER JOIN location ON company.locationid = location.locationid where c_id=$c_id
|
 |
 |
 |
 |
Date :
2010-09-27 10:46:31 |
By :
maltra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|