here it is working:
http://phpcode.hu/students/
in the form lets put ? to the action.
i always keep the order when creating a submit button: name, type, class, value
connect.php:
<?php
/// For the following details,
/// please contact your server vendor
$hostname='***'; //// specify host, i.e. 'localhost'
$user='****'; //// specify username
$pass='****'; //// specify password
$dbase='****'; //// specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
?>
<?php
//include 'conetcion.php'; //learn to spell connect
include("connect.php");
if(isset($_POST['Submit'])) {
echo "BUTTON WORKS";
students_from_stpr();
}
function students_from_stpr() {
$Stud_pr = 'Stud_pr1';
$query = "SELECT Student_Id, Student_Name FROM students WHERE Stud_pr = '$Stud_pr'";
$result = mysql_query($query);
if (!$result) {
echo "Could not successfully run query ($query) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so I'm exiting";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo $row["Student_Id"];
echo " ";
echo $row["Student_Name"];
echo "</br>";
}
mysql_free_result($result);
}
//students_from_stpr()
?>
<form action="?" method="post">
<input name="Submit" type="submit" class="button" value="Submit">
</form>
if its not working, lets create the table, and fill with a row, where the Stud_pr value has an entry: Stud_pr1
CREATE TABLE students (
Students_Id int(11) NOT NULL auto_increment,
Student_Name varchar(255) character set latin2 NOT NULL,
Stud_pr varchar(255) character set latin2 NOT NULL,
PRIMARY KEY (students_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin2 AUTO_INCREMENT=1 ;
INSERT INTO students (students_id, Student_Id, Student_Name, Stud_pr) VALUES
(1, '1', 'asd', 'Stud_pr1');