...

View Full Version : getting table column data in array problem



shakac
12-14-2011, 06:34 AM
Hello
webmasters please help me
i have 2 table 1 is
student_information
and
exam_classtest_term
in student_information table there has these coloumn
id
student_id
firstname
lastname
nickname
class roll_no
session

and in exam_classtest_term table there has these coloumn
id
student_id
student_class
student_roll
sub_name
session
term
obtain_marks

i want to insert data to exam_classtest_marks for all student from student_information everytihing is fine but i could not get student_id data to insert exam_classtest_term
how to get all student_id from student_information and make them serially to insert exam_classtest_term table against student_roll

my php is code is

<?php
session_start();
include("header.php");
$class=$_SESSION['class']=$_POST['class'];
$sess=$_SESSION['session'] = $_POST['session'];
$sub=$_SESSION['subject'] = $_POST['subject'];
$term=$_SESSION['term'] = $_POST['term'];
include("config.php");
$query="SELECT * FROM student_information WHERE class='$class'";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);

// initialization
$photo_upload_fields = "";
$counter = 1;

// default number of fields
$number_of_fields = $num_rows;

// If you want more fields, then the call to this page should be like,
// preupload.php?number_of_fields=20

if( $_GET['number_of_fields'] )
$number_of_fields = (int)($_GET['number_of_fields']);

// Firstly Lets build the Category List

// Lets build the Photo Uploading fields
while( $counter <= $number_of_fields )
{
$photo_upload_fields .=<<<__HTML_END
<tr>
<td>
roll {$counter}:<br />
<input type='hidden' name='roll[]' value='$counter'/>
</td>
</tr>
<tr>
<td>
<input name='sid[]' type='hidden' value='value in not getting'/><br />problem here
</td>
</tr>
<tr>
<td>
marks:<input name='marks[]' type='text' />
</td>
</tr>
<tr>
<td>
<input name='sub[]' type='hidden' value='$sub'/>
</td>
</tr>
<tr>
<td>
<input name='sess[]' type='hidden' value='$sess'/>
</td>
</tr>
<tr>
<td>
<input name='class[]' type='hidden' value='$class'/>
</td>
</tr>
<tr>
<td>
<input name='term[]' type='hidden' value='$term'/>
</td>
</tr>
__HTML_END;
$counter++;
}

// Final Output
echo <<<__HTML_END
<html>
<body>
<form action='marksentry1.php' method='post'>
<table width='90%' border='0' align='center' style='width: 90%;'>
<tr>
<td>
<p>&nbsp;</p>
</td>
</tr>

<!-Insert the photo fields here -->
$photo_upload_fields

<tr>
<td>
<input type='submit' name='submit' value='Add marks' />
</td>
</tr>
</table>
</form>
</body>
</html>
__HTML_END;
?>
please help me anybody

sunfighter
12-14-2011, 03:52 PM
I don't understand what you want, but I do know that your query won't work:

$query="SELECT * FROM student_information WHERE class='$class'";
because you have no column named 'class' in the 'student_information' table.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum