Status
Not open for further replies.

shakac

Active Member
47
2011
0
0
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:
<?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='problem here:value in not getting'/>
    </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 to get student_id in input form sid[]
please help
 
6 comments
thanks lockdown for your help
but unfortunately there is no data getting from student_id
here is my modified code
PHP:
<?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);
$sid = $result['student_id']; 
    // 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='text' value='$sid->no id was getting'/>
    </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
 
Ok then ..

do this:

PHP:
<?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( is_numeric($_GET['number_of_fields']) && $_GET['number_of_fields'] >  $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 )
    { $row1 = mysql_fetch_row($result);
$sid = $row1['student_id'];     
$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='text' value='$sid'/>
    </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;
?>
 
Last edited:
Thank you Lockdown
and thanks wjunction
Lockdown i am successful by your code.
thank you very very much.
reputation added.
 
Status
Not open for further replies.
Back
Top