ลองใช้คำสั่ง var_dump(); หรือ print_r(); เืพื่อตรวจสอบค่าที่ได้ออกมาจากฐานข้อมูล นะครับ หลังจากนั้นก็ดูว่า array index ที่เราเรียกหา ถูกต้องตามชื่อฟิลด์หรือเปล่า สุดท้ายก็ให้ดู tag A ว่ามันเป็นรูปแบบที่จะส่งค่าไปให้หน้าที่เราต้องการได้หรือไม่
ถ้าจะให้เดาผมเดาว่า array index ที่เรียกใช้งาน น่าจะไม่มีอยู่จริง เพราะ syntax ไม่มีปัญหาอะไร
<?php
if(isset($HerbRec_id)){
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("herbarium");
mysql_query("SET NAMES UTF8");
$sql="SELECT* FROM herb_recipe INNER JOIN disease ON (herb_recipe.Disease_id=disease.Disease_id) INNER JOIN source ON (herb_recipe.Source_id=source.Source_id) WHERE HerbRec_id LIKE '%$HerbRec_id%'";
$sql2="SELECT Herb_Content,Herb_Ratio,Unit_name
FROM herb_content INNER JOIN herb_recipe ON (herb_content.HerbRec_id=herb_recipe.HerbRec_id)
INNER JOIN herb ON (herb_content.Herb_id=herb.Herb_id)
INNER JOIN unit ON (herb_content.Unit_id=unit.Unit_id)
WHERE herb_recipe.HerbRec_id LIKE '%$HerbRec_id%'";
$sql3="SELECT OtIngredient_content,OtIngredient_ratio,Unit_name
FROM other_ingredient_content INNER JOIN herb_recipe ON (other_ingredient_content.HerbRec_id=herb_recipe.HerbRec_id)
INNER JOIN other_ingredient ON (other_ingredient_content.OtIngredient_id=other_ingredient.OtIngredient_id)
INNER JOIN unit ON (other_ingredient_content.Unit_id=unit.Unit_id)
WHERE herb_recipe.HerbRec_id LIKE '%$HerbRec_id%'";
$result3=mysql_query($sql3) or die ("ไม่สามารถ Query คำสั่งได้");
if($result3){
/*$num3=mysql_num_rows($result3);
if($num3==0){
echo"ไม่พบข้อมูล";
return;
}