kitschkath 0 Newbie Poster

Hello can anybody help me with constructing a PHP ODBC code for retrieving records in a database?

here's my code:

<title>HCPSMSHS: Grade Viewing System</title>
<link rel="stylesheet" href="css.css" type="text/css" charset="UTF-8" media="all">


or die("connect error: ".odbc_error());


$sql="SELECT * FROM tblstudents WHERE S_ID='$username' AND S_PASSWORD1='$password'";

or die ("result error ".odbc_error().'-'.odbc_errormsg());

// if no result: no rows read
if (!odbc_fetch_row($result))
echo "<script>alert(\"ERROR! Try again.\");</script>";
print "<script>";
print " self.location='login.html';";
print "</script>"; 

// else: all is okay
else {



echo "<script>alert(\"Welcome $name!!\")</script>";

$query_subject="Select Subject from tbltablestudent where S_ID='$username'";
or die ("result error ".odbc_error().'-'.odbc_errormsg());


$query_grade="Select Total from $yeah[Subject],tbltablestudent where $yeah[Subject].S_ID=tbltablestudent.S_ID and $yeah[Subject].S_ID='$username'";
or die ("result error ".odbc_error().'-'.odbc_errormsg());




<center><div id="content"></div></center>
<center><div id="subcontent">

echo "$yeah[Subject]";
echo "$yeah2[Total]";

the code only retrieves one record. HELP. I've tried a lot of codings but it still won't work~

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.