0
for($y=1;$y<=$x;$y++){

$query="insert into attendance values('$admission_no[$y]','$date','$state_id')";
     $result=mysql_query($query);
        }

Edited by Dani: Formatting fixed

4
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by paulrajj
0

What is the code supposed to be doing?

If $admission_no[$y] is only supposed to output the value of $y then you can replace "$admission_no[$y]" with just "$y".

Without more of the code and not knowing what it's supposed to do, we can't help much. Could you please provide more of the code. Censor any passwords that may be in the code, obviously. Could you also use the BB Tag when providing PHP code please.[code=php] BB Tag when providing PHP code please.

0

suppose there is a database.there is a one table call attendance.that table is available 3 field call admission no,date and state(student percent,student absent)
there are 3 arrays 1st one with admission no , 2 nd one with state .the admission no's array explode and get the admission no one by one.

$admission = array($admission_n);
$admission_no = explode("~",$admission);

for($y=1;$y<=$x;$y++){

$query="insert into attendance values('$admission_no[$y]','$date')";
     $result=mysql_query($query);
        }

that i wanted to know .that u think the admission no array 10 admission no available.
after that array explode .i want to enter that admission no one by one into database.
there for when i write the query i put $admission_no[$y] inside the value.i wanted to know is this correct.

Edited by mike_2000_17: Fixed formatting

0
$query="insert into attendance values('$admission_no[$y]','$date')";

Should be:

$query="insert into attendance(field1, field2) values('" . $admission_no[$y] . "','" . $date . "')";

You must select the field(s) to insert the value(s). $var="variable $var" and $var = "variable " . $var are not same.

0

if we put query like this is this not correct

$query="insert into attendance values('$admission_no[$y]','$date')";

without putting like this

$query="insert into attendance values('" . $admission_no[$y] . "','" . $date . "')";

0

but i have use some querys like this way those are working

$query="insert into attendance values('$admission_no','$date')";

0

Hi,

May be the fault is depends on the variable $x. Check whether the variable $x contains any values.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.