0

I have a list of request data, when user edit 1 data or more, edit data screen direct to input request screen..so, data put back to when they input request.. but in the input request screen, have 10 column to input...in this case user just edit 1 data..9 another column empty..i dont know why showing the error..but 1 data user select show to input request screen..pls help me

sorry for my bad english..

here is my code :

<?php
  if(isset($_GET['IdEnt']))
  {
   $IdEnt=$_GET['IdEnt'];
   $queryC="select Nominal,InputDate,TypeCost,convert(varchar(20),EntDate,103) as 'EntDate',EntParty,Premi,Div,RemarksAgent from entReq where IdEnt=".$IdEnt;
   $resultC1=sqlsrv_query($conn, $queryC);
   $resultC2=sqlsrv_query($conn, $queryC);
   $resultC3=sqlsrv_query($conn, $queryC);
   $resultC4=sqlsrv_query($conn, $queryC);
   $resultC5=sqlsrv_query($conn, $queryC);
   $resultC6=sqlsrv_query($conn, $queryC);
   $resultC7=sqlsrv_query($conn, $queryC);
   $resultC8=sqlsrv_query($conn, $queryC);
   $resultC9=sqlsrv_query($conn, $queryC);
   $resultC10=sqlsrv_query($conn, $queryC);

   // echo $queryC."<br>";
   $rowC1=sqlsrv_fetch_array($resultC1);
   $Nominal1=$rowC1['Nominal'];
   $InputDate1=$rowC1['InputDate'];
   $TypeCost1=$rowC1['TypeCost'];
   $EntDate1=$rowC1['EntDate'];
   $EntParty1=$rowC1['EntParty'];
   $Premi1=$rowC1['Premi'];
   $Div =$rowC1['Div'];
   $RemarksAgent1 = $rowC1['RemarksAgent'];


   $rowC2=sqlsrv_fetch_array($resultC2);
   $Nominal2=$rowC2['Nominal2'];
   $InputDate2=$rowC2['InputDate2'];
   $TypeCost2=$rowC2['TypeCost2'];
   $EntDate2=$rowC2['EntDate2'];
   $EntParty2=$rowC2['EntParty2'];
   $Premi2=$rowC2['Premi2'];
   $Div =$rowC2['Div'];
   $RemarksAgent2 = $rowC2['RemarksAgent2'];
    


   $rowC3=sqlsrv_fetch_array($resultC3);
   $Nominal3=$rowC3['Nominal3'];
   $InputDate3=$rowC3['InputDate3'];
   $TypeCost3=$rowC3['TypeCost3'];
   $EntDate3=$rowC3['EntDate3'];
   $EntParty3=$rowC3['EntParty3'];
   $Premi3=$rowC3['Premi3'];
   $Div =$rowC3['Div'];
   $RemarksAgent3 = $rowC3['RemarksAgent3'];

   $rowC4=sqlsrv_fetch_array($resultC4);
   $Nominal4=$rowC4['Nominal4'];
   $InputDate4=$rowC4['InputDate4'];
   $TypeCost4=$rowC4['TypeCost4'];
   $EntDate4=$rowC4['EntDate4'];
   $EntParty4=$rowC4['EntParty4'];
   $Premi4=$rowC4['Premi4'];
   $Div =$rowC4['Div'];
   $RemarksAgent4 = $rowC4['RemarksAgent4'];

   $rowC5=sqlsrv_fetch_array($resultC5);
   $Nominal5=$rowC5['Nominal5'];
   $InputDate5=$rowC5['InputDate5'];
   $TypeCost5=$rowC5['TypeCost5'];
   $EntDate5=$rowC5['EntDate5'];
   $EntParty5=$rowC5['EntParty5'];
   $Premi5=$rowC5['Premi5'];
   $Div=$rowC5['Div'];
   $RemarksAgent5 = $rowC5['RemarksAgent5'];

   $rowC6=sqlsrv_fetch_array($resultC6);
   $Nominal6=$rowC6['Nominal6'];
   $InputDate6=$rowC6['InputDate6'];
   $TypeCost6=$rowC6['TypeCost6'];
   $EntDate6=$rowC6['EntDate6'];
   $EntParty6=$rowC6['EntParty6'];
   $Premi6=$rowC6['Premi6'];
   $Div =$rowC6['Div'];
   $RemarksAgent6 = $rowC6['RemarksAgent6'];

   $rowC7=sqlsrv_fetch_array($resultC7);
   $Nominal7=$rowC7['Nominal7'];
   $InputDate7=$rowC7['InputDate7'];
   $TypeCost7=$rowC7['TypeCost7'];
   $EntDate7=$rowC7['EntDate7'];
   $EntParty7=$rowC7['EntParty7'];
   $Premi7=$rowC7['Premi7'];
   $Div =$rowC7['Div'];
   $RemarksAgent7 = $rowC7['RemarksAgent7'];

   $rowC8=sqlsrv_fetch_array($resultC8);
   $Nominal8=$rowC8['Nominal8'];
   $InputDate8=$rowC8['InputDate8'];
   $TypeCost8=$rowC8['TypeCost8'];
   $EntDate8=$rowC8['EntDate8'];
   $EntParty8=$rowC8['EntParty8'];
   $Premi8=$rowC8['Premi8'];
   $Div =$rowC8['Div'];
   $RemarksAgent8 = $rowC8['RemarksAgent8'];

   $rowC9=sqlsrv_fetch_array($resultC9);
   $Nominal9=$rowC9['Nominal9'];
   $InputDate9=$rowC9['InputDate9'];
   $TypeCost9=$rowC9['TypeCost9'];
   $EntDate9=$rowC9['EntDate9'];
   $EntParty9=$rowC9['EntParty9'];
   $Premi9=$rowC9['Premi9'];
   $Div =$rowC9['Div'];
   $RemarksAgent9 = $rowC9['RemarksAgent9'];

   $rowC10=sqlsrv_fetch_array($resultC10);
   $Nominal10=$rowC10['Nominal10'];
   $InputDate10=$rowC10['InputDate10'];
   $TypeCost10=$rowC10['TypeCost10'];
   $EntDate10=$rowC10['EntDate10'];
   $EntParty10=$rowC10['EntParty10'];
   $Premi10=$rowC10['Premi10'];
   $Div =$rowC10['Div'];
   $RemarksAgent10 = $rowC10['RemarksAgent10'];
   
  }
  else
  {
   $userID1="";
   $Nominal1="";
   $InputDate1="";
   $TypeCost1="";
   $EntDate1="";
   $EntParty1="";
   $Premi1="";
   $Div="";
   $RemarksAgent1="";

   $userID2="";
   $Nominal2="";
   $InputDate2="";
   $TypeCost2="";
   $EntDate2="";
   $EntParty2="";
   $Premi2="";
   $Div="";
   $RemarksAgent2="";

   $userID3="";
   $Nominal3="";
   $InputDate3="";
   $TypeCost3="";
   $EntDate3="";
   $EntParty3="";
   $Premi3="";
   $Div="";
   $RemarksAgent3="";

   $userID4="";
   $Nominal4="";
   $InputDate4="";
   $TypeCost4="";
   $EntDate4="";
   $EntParty4="";
   $Premi4="";
   $Div="";
   $RemarksAgent4="";

   $userID5="";
   $Nominal5="";
   $InputDate5="";
   $TypeCost5="";
   $EntDate5="";
   $EntParty5="";
   $Premi5="";
   $Div="";
   $RemarksAgent5="";

   $userID6="";
   $Nominal6="";
   $InputDate6="";
   $TypeCost6="";
   $EntDate6="";
   $EntParty6="";
   $Premi6="";
   $Div="";
   $RemarksAgent6="";

   $userID7="";
   $Nominal7="";
   $InputDate7="";
   $TypeCost7="";
   $EntDate7="";
   $EntParty7="";
   $Premi7="";
   $Div="";
   $RemarksAgent7="";

   $userID8="";
   $Nominal8="";
   $InputDate8="";
   $TypeCost8="";
   $EntDate8="";
   $EntParty8="";
   $Premi8="";
   $Div="";
   $RemarksAgent8="";

   $userID9="";
   $Nominal9="";
   $InputDate9="";
   $TypeCost9="";
   $EntDate9="";
   $EntParty9="";
   $Premi9="";
   $Div="";
   $RemarksAgent9="";

   $userID10="";
   $Nominal10="";
   $InputDate10="";
   $TypeCost10="";
   $EntDate10="";
   $EntParty10="";
   $Premi10="";
   $Div="";
   $RemarksAgent10="";


  }
 ?>

Table enter image description here

Errors

enter image description here

please help me :(

M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
  • You are wide open to SQL injections. You should look into using [Prepared Statements](http://php.net/manual/en/function.sqlsrv-prepare.php). – M. Eriksson Mar 29 '18 at 07:09
  • see your sql query where id='$id' this means only one row show if u want all rows then donot use where condition – Mazhar Hussain Mar 29 '18 at 07:11
  • Why would you expect `$rowC2['Nominal2']` to be valid, when you're not fetching any column called that? You're literally making the exact same query (returning the exact same columns and values) 10 times in a row, which makes no sense. What's the point of this code? – M. Eriksson Mar 29 '18 at 07:12
  • I'm guessing you only query Nominal (from select statement) $queryC="select Nominal,InputDate, ... but want to access $rowC2['Nominal2'] . Try $Nominal2=$rowC2['Nominal']; (without number...at all fields you want to access) – Jax297 Mar 29 '18 at 07:14
  • Possible duplicate of [PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"](https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef) – M. Eriksson Mar 29 '18 at 07:15
  • The code you posted is incomplete for debugging. – Karlo Kokkak Mar 29 '18 at 07:18
  • @KarloKokkak - Not really. The problem is pretty obvious when you read the code. – M. Eriksson Mar 29 '18 at 07:22
  • someone tell me to use if empty...how i use if empty in my code? – Mathews Edward Mar 29 '18 at 07:26
  • @MagnusEriksson here is my full code... first, when user input data : ent_input.php : https://pastebin.com/k6eEdwS9 when user see list data they input : (ent_list.php) https://pastebin.com/Ya6tdG2x when user want to edit in list data, click date on input date.. – Mathews Edward Mar 29 '18 at 07:42
  • Don't post additions as off-site links. Your question does already contain the relevant code. You're fetching the same columns over and over but are expecting them to automatically change their names. Example: `SELECT Nominal, ...`. Even if you fetch that 100 times, the column will still be called `Nominal`, not `Nominal2`, `Nominal3` etc. – M. Eriksson Mar 29 '18 at 07:44

0 Answers0