0

I have use code as shown below:

  <?  
$sql = mysql_query("select * from tbl_item where item_category = '$item_cat'");
$i=1;
  while($crows = mysql_fetch_array($sql))
  {
    ;
  ?>    

  <tr>
    <td width="57" align="center" ><? echo $i;?></td>
    <td width="540" align="center" onClick=><div align="center"><? echo $crows["item_name"];?> </div></td>
    <td width="385" align="center">
      1<input name="<? echo $crows["item_name"];?>" type="radio" id="radioqty<? echo $i;?>" value="1" checked="checked"  />

      2<input type="radio" name="<? echo $crows["item_name"];?>" id="radioqty<? echo $i;?>" value="2" />

      3<input type="radio" name="<? echo $crows["item_name"];?>" id="radioqty<? echo $i;?>" value="3" />

      4<input type="radio" name="<? echo $crows["item_name"];?>" id="radioqty<? echo $i;?>" value="4" />
    </td>
    <td width="249" align="center" >
      Full<input name="radioplate<? echo $i?>" type="radio" id="radioplate<? echo $i?>" value="full" checked="checked" /> 
      Half<input type="radio" name="radioplate<? echo $i?>" id="radioplate<? echo $i?>" value="half" /></td>

    <td width="281" align="center">
      <input name="serve" type="button" value="Serve" onclick="get_code('a','get_item_save.php?item_id='+<? echo $crows["item_id"];?>+'&cat_id='+document.exB.item_category.value+'&plate_type='+document.exB.radioplate<? echo $i?>.value+'&qty='+exB.radioqty<? echo $i;?>.value+'&bill_no='+document.exB.bill_summary_bill_no.value+'&bill_date='+document.exB.bill_summary_date.value),get_code('b','get_item_sale_list.php?bill_no='+document.exB.bill_summary_bill_no.value)"/>      </td>
  </tr>
  <? $i++; }?>

Here I'm doing something wrong when I call get_code function and I'm unable to figure out were I'm wrong. Could someone figure out what I'm doing wrong on this line of code:

<td width="281" align="center">
    <input name="serve" type="button" value="Serve" onclick="get_code('a','get_item_save.php?item_id='+<? echo $crows["item_id"];?>+'&cat_id='+document.exB.item_category.value+'&plate_type='+document.exB.radioplate<? echo $i?>.value+'&qty='+exB.radioqty<? echo $i;?>.value+'&bill_no='+document.exB.bill_summary_bill_no.value+'&bill_date='+document.exB.bill_summary_date.value),get_code('b','get_item_sale_list.php?bill_no='+document.exB.bill_summary_bill_no.value)"/>      </td>

I get an error at: document.exB.radioplate<? echo $i?>.value show undefined.

1
  • Firstly, you should refactor your function, in a way that it will take only the parameters,and then create url from them. And secondly, in document.exB.radioplate<? echo $i?>, try to put ; after $i. Commented Apr 4, 2013 at 12:53

1 Answer 1

1

Maybe with mysql_fetch_array($sql, MYSQL_ASSOC) in the while statement.

With the MYSQL_ASSOC you can retrieve the fields by its name, like crows['item_name'].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.