Jump to content

Passing a variable from the 1st form to allow it to be used in the php page


siblood

Recommended Posts

Hi guys, I am really new to PHP. I am experimenting with it as I believe the college I work at can benefit from the technology. I am currently using MS Access 2007 as the backend database although once I get this working I will move it all to MySQL.

 

At present I can retrieve all of the data from the students database and present it in a webpage with the following code:

 

<?PHP

$conn=odbc_connect("VEGAS","","");

 

 

print('<html>

<title>PHP and MS ACCESS</title>

</head>');

 

print('<body>');

print('<table align=center width=90%>');

print('<tr><th>Student Number</th><th>Course</th><th>Last Name</th><th>First Name</th></tr>');

 

if ($conn)

{

$sql=("SELECT * FROM Students");

$row=odbc_exec($conn,$sql);

 

    while(odbc_fetch_row($row))

{

$studentid=odbc_Result($row,1);

$course=odbc_Result($row,2);

$lastname=odbc_Result($row,3);

$firstname=odbc_Result($row,4);

print ('<tr><td>'.$studentid.'</td><td>'.$course.'</td><td>'.$lastname.'</td><td>'.$firstname.'</td></tr>');

}

}

 

print('</table>');

print('</body>');

print('</html>');

 

However I want to be able to create a form page which passes the studentid value entered into this php script as a variable which can then be searched (pulled out of the database). Does anyone have any suggestions? (I feel that if I can get an answer to this then it will set the ball rolling for me!!) Thanks in advance and for listening to a newbie.

 

Kind regards

 

Simon.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.