0

使用查询访问 $current_rank 这个值想在不同的查询中访问但是这个值在不同的查询中不能访问任何地方所以如何访问 $current_rank ......

$query = "select * from menu_master where menu_id = 
          $row_id and hotel_id='" . $_REQUEST['hotel_id'] . "'";

$result = mysql_query($query)."<br/>";
while($row=mysql_fetch_array($result))
{
     $rank = $row['set_rank'];
}
$current_rank = $rank;

//echo $current_id = $row_id."<br/>";
//echo $new_rank =$_REQUEST['set_rank']."<br/>";

$sql = "select * from menu_master where set_rank = '$new_rank ' and hotel_id='".$_REQUEST['hotel_id']."'" ; 
// echo  $sql."<br/>";

$rs = mysql_query($sql)."<br/>";

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']."'";
    //echo  $sql."<br/>";
    mysql_query($sql)."<br/>";
}

$sql="update menu_master set 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']."'";
    //echo  $sql."<br/>";
    //exit;
    mysql_query($sql);
4

2 回答 2

0

您的 current_rank 似乎是一个数组。如果 current_rank 中有单个值,则不要使用 while 循环。只需使用 $row=mysql_fetch_array($result); $current_rank = $row['set_rank'];

于 2013-05-31T06:12:41.623 回答
0

你也注释掉了这一行。//echo $new_rank =$_REQUEST['set_rank']."
"; 所以你对 $new_rank 没有价值

于 2013-05-31T06:35:03.833 回答