using query more than 4 query for fetch the data base the four query are run properly but i use one more query for fetch the hotel_id and this hotel_id use in different query but when i run the query, the query run properly but didn't get output in while loop and what is my mistake in the code..... this query working properly but $query1 = "select hotel_id from menu_master where menu_id=".$id; but in $hid = $row['hotel_id']; can't store any value in $hid..
使用查询超过4个查询获取数据库四个查询运行正常但我使用另一个查询来获取hotel_id和这个hotel_id在不同的查询中使用但是当我运行查询时,查询运行正常但没有得到在while循环中输出,我在代码中的错误是什么.....这个查询工作正常,但是$ query1 =“从menu_master中选择hotel_id,其中menu_id =”。$ id;但在$ hid = $ row ['hotel_id'];不能在$ hid中存储任何值..
$query1 = "select hotel_id from menu_master where menu_id=".$id;
$res = mysql_query( $query1);
while($row=mysql_fetch_array($res))
{
$hid = $row['hotel_id'];
}
$query = "select set_rank from menu_master where menu_id = $row_id and hotel_id='".$_REQUEST['hotel_id']."'";
//echo $query."<br/>";
$result = mysql_query($query);
while($row=mysql_fetch_array($result))
{
$current_rank = $row['set_rank'];
}
$current_id = $row_id;
$new_rank =$_REQUEST['set_rank'];
$sql = "select * from menu_master where set_rank = '$new_rank ' and hotel_id='".$_REQUEST['hotel_id']."'" ;
$rs = mysql_query($sql);
while($row = mysql_fetch_array($rs))
{
$menu_id = $row['menu_id'];
$sql="update menu_master
set set_rank=$current_rank where menu_id= $menu_id and hotel_id='".$_REQUEST['hotel_id']."'";
mysql_query($sql);
}
$sql="update menu_master set
hotel_id = '".mysql_real_escape_string($_REQUEST['hotel_id'])."',
menu_name = '".mysql_real_escape_string($_REQUEST['menu_name'])."',
menu_name_ar = '".mysql_real_escape_string($_REQUEST['menu_name_ar'])."',
is_active = '".$is_active."',
set_rank=$new_rank where menu_id= '$current_id' and hotel_id='".$_REQUEST['hotel_id']."'";
mysql_query($sql);
}
2 个解决方案
#1
0
Try this code
试试这个代码
$query1 = "select hotel_id from menu_master where menu_id=".$id;
$row = mysql_fetch_array(mysql_query($query1));
$hid = $row['hotel_id'];
#2
0
$query1 = "select hotel_id from menu_master where menu_id=".$id;
$ query1 =“从menu_master中选择hotel_id,其中menu_id =”。$ id;
$res = mysql_query( $query1);
while($row1=mysql_fetch_array($res))
{
$hid = $row1['hotel_id'];
$query = "select set_rank from menu_master where menu_id = $row_id and hotel_id='".$hid."'";
//echo $query."<br/>";
$result = mysql_query($query);
while($row=mysql_fetch_array($result))
{
$current_rank = $row['set_rank'];
}
$current_id = $row_id;
$new_rank =$_REQUEST['set_rank'];
$sql = "select * from menu_master where set_rank = '$new_rank ' and hotel_id='".$hid."'" ;
$rs = mysql_query($sql);
while($row = mysql_fetch_array($rs))
{
$menu_id = $row['menu_id'];
$sql="update menu_master
set set_rank=$current_rank where menu_id= $menu_id and hotel_id='".$hid."'";
mysql_query($sql);
}
$sql="update menu_master set
hotel_id = '".mysql_real_escape_string($_REQUEST['hotel_id'])."',
menu_name = '".mysql_real_escape_string($_REQUEST['menu_name'])."',
menu_name_ar = '".mysql_real_escape_string($_REQUEST['menu_name_ar'])."',
is_active = '".$is_active."',
set_rank=$new_rank where menu_id= '$current_id' and hotel_id='".$hid."'";
mysql_query($sql);
}
#1
0
Try this code
试试这个代码
$query1 = "select hotel_id from menu_master where menu_id=".$id;
$row = mysql_fetch_array(mysql_query($query1));
$hid = $row['hotel_id'];
#2
0
$query1 = "select hotel_id from menu_master where menu_id=".$id;
$ query1 =“从menu_master中选择hotel_id,其中menu_id =”。$ id;
$res = mysql_query( $query1);
while($row1=mysql_fetch_array($res))
{
$hid = $row1['hotel_id'];
$query = "select set_rank from menu_master where menu_id = $row_id and hotel_id='".$hid."'";
//echo $query."<br/>";
$result = mysql_query($query);
while($row=mysql_fetch_array($result))
{
$current_rank = $row['set_rank'];
}
$current_id = $row_id;
$new_rank =$_REQUEST['set_rank'];
$sql = "select * from menu_master where set_rank = '$new_rank ' and hotel_id='".$hid."'" ;
$rs = mysql_query($sql);
while($row = mysql_fetch_array($rs))
{
$menu_id = $row['menu_id'];
$sql="update menu_master
set set_rank=$current_rank where menu_id= $menu_id and hotel_id='".$hid."'";
mysql_query($sql);
}
$sql="update menu_master set
hotel_id = '".mysql_real_escape_string($_REQUEST['hotel_id'])."',
menu_name = '".mysql_real_escape_string($_REQUEST['menu_name'])."',
menu_name_ar = '".mysql_real_escape_string($_REQUEST['menu_name_ar'])."',
is_active = '".$is_active."',
set_rank=$new_rank where menu_id= '$current_id' and hotel_id='".$hid."'";
mysql_query($sql);
}