Fetching out Records from Mysq Database

  • stevewise
  • Newbie
  • Newbie
  • stevewise
  • Posts: 7

Post 3+ Months Ago

please I am new to Php and Mysql programming
I am developing a website for a school potal
I am haveing problem fetching records from the database
there are two forms, one of the forms which is the search form
while the other is the result page that is supposed to display the result but I am having problem with my coding please somebody help me out.
The seach page has the following fields which will be used to search for information in the database
MatricNo
Level
Semester
and a button for submit which is supposed to display the records in th result page. That is the result page.
Code: [ Select ]
<?php require_once('dj.php'); ?>
<?php
$matric_no=0009;
$level = "ND1";
$semester = "FIRST SEMESTER";

$host = "localhost";
$account = "root"  
$password = " " 
$database = "student affairs" 
$connect=mysql_connect($host, $account, $password);
mysql_select_db($database, $connect);

$sql="SELECT *
FROM populate
WHERE matricno LIKE '$matric_no'
AND level LIKE '$level'
AND semester LIKE '$semester'";

$result=mysql_query($sql, $connect);
$row=mysql_fetch_array($result);

mysql_close();


?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#apDiv1 {
    position:absolute;
    width:886px;
    height:340px;
    z-index:1;
}
-->
</style>
</head>

<body>
<div id="apDiv1">
 <table border="1">
  <tr>
   <td>matricno</td>
   <td>firstname</td>
   <td>lastname</td>
   <td>othername</td>
   <td>level</td>
   <td>course1</td>
   <td>course2</td>
   <td>course3</td>
   <td>course4</td>
   <td>course5</td>
   <td>course6</td>
   <td>course7</td>
   <td>course8</td>
   <td>course9</td>
   <td>course10</td>
   <td>grade1</td>
   <td>grade2</td>
   <td>grade3</td>
   <td>grade4</td>
   <td>grade5</td>
   <td>grade6</td>
   <td>grade7</td>
   <td>grade8</td>
   <td>grade9</td>
   <td>grade10</td>
   <td>code1</td>
   <td>code2</td>
   <td>code3</td>
   <td>code4</td>
   <td>code5</td>
   <td>code6</td>
   <td>code7</td>
   <td>code8</td>
   <td>code9</td>
   <td>code10</td>
   <td>cgpa</td>
   <td>department</td>
   <td>semester</td>
  </tr>
  <?php do { ?>
   <tr>
    <td><?php echo $row_Recordset1['matricno']; ?></td>
    <td><?php echo $row_Recordset1['firstname']; ?></td>
    <td><?php echo $row_Recordset1['lastname']; ?></td>
    <td><?php echo $row_Recordset1['othername']; ?></td>
    <td><?php echo $row_Recordset1['level']; ?></td>
    <td><?php echo $row_Recordset1['course1']; ?></td>
    <td><?php echo $row_Recordset1['course2']; ?></td>
    <td><?php echo $row_Recordset1['course3']; ?></td>
    <td><?php echo $row_Recordset1['course4']; ?></td>
    <td><?php echo $row_Recordset1['course5']; ?></td>
    <td><?php echo $row_Recordset1['course6']; ?></td>
    <td><?php echo $row_Recordset1['course7']; ?></td>
    <td><?php echo $row_Recordset1['course8']; ?></td>
    <td><?php echo $row_Recordset1['course9']; ?></td>
    <td><?php echo $row_Recordset1['course10']; ?></td>
    <td><?php echo $row_Recordset1['grade1']; ?></td>
    <td><?php echo $row_Recordset1['grade2']; ?></td>
    <td><?php echo $row_Recordset1['grade3']; ?></td>
    <td><?php echo $row_Recordset1['grade4']; ?></td>
    <td><?php echo $row_Recordset1['grade5']; ?></td>
    <td><?php echo $row_Recordset1['grade6']; ?></td>
    <td><?php echo $row_Recordset1['grade7']; ?></td>
    <td><?php echo $row_Recordset1['grade8']; ?></td>
    <td><?php echo $row_Recordset1['grade9']; ?></td>
    <td><?php echo $row_Recordset1['grade10']; ?></td>
    <td><?php echo $row_Recordset1['code1']; ?></td>
    <td><?php echo $row_Recordset1['code2']; ?></td>
    <td><?php echo $row_Recordset1['code3']; ?></td>
    <td><?php echo $row_Recordset1['code4']; ?></td>
    <td><?php echo $row_Recordset1['code5']; ?></td>
    <td><?php echo $row_Recordset1['code6']; ?></td>
    <td><?php echo $row_Recordset1['code7']; ?></td>
    <td><?php echo $row_Recordset1['code8']; ?></td>
    <td><?php echo $row_Recordset1['code9']; ?></td>
    <td><?php echo $row_Recordset1['code10']; ?></td>
    <td><?php echo $row_Recordset1['cgpa']; ?></td>
    <td><?php echo $row_Recordset1['department']; ?></td>
    <td><?php echo $row_Recordset1['semester']; ?></td>
   </tr>
   <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
 </table>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
  1. <?php require_once('dj.php'); ?>
  2. <?php
  3. $matric_no=0009;
  4. $level = "ND1";
  5. $semester = "FIRST SEMESTER";
  6. $host = "localhost";
  7. $account = "root"  
  8. $password = " " 
  9. $database = "student affairs" 
  10. $connect=mysql_connect($host, $account, $password);
  11. mysql_select_db($database, $connect);
  12. $sql="SELECT *
  13. FROM populate
  14. WHERE matricno LIKE '$matric_no'
  15. AND level LIKE '$level'
  16. AND semester LIKE '$semester'";
  17. $result=mysql_query($sql, $connect);
  18. $row=mysql_fetch_array($result);
  19. mysql_close();
  20. ?>
  21. <html>
  22. <head>
  23. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  24. <title>Untitled Document</title>
  25. <style type="text/css">
  26. <!--
  27. #apDiv1 {
  28.     position:absolute;
  29.     width:886px;
  30.     height:340px;
  31.     z-index:1;
  32. }
  33. -->
  34. </style>
  35. </head>
  36. <body>
  37. <div id="apDiv1">
  38.  <table border="1">
  39.   <tr>
  40.    <td>matricno</td>
  41.    <td>firstname</td>
  42.    <td>lastname</td>
  43.    <td>othername</td>
  44.    <td>level</td>
  45.    <td>course1</td>
  46.    <td>course2</td>
  47.    <td>course3</td>
  48.    <td>course4</td>
  49.    <td>course5</td>
  50.    <td>course6</td>
  51.    <td>course7</td>
  52.    <td>course8</td>
  53.    <td>course9</td>
  54.    <td>course10</td>
  55.    <td>grade1</td>
  56.    <td>grade2</td>
  57.    <td>grade3</td>
  58.    <td>grade4</td>
  59.    <td>grade5</td>
  60.    <td>grade6</td>
  61.    <td>grade7</td>
  62.    <td>grade8</td>
  63.    <td>grade9</td>
  64.    <td>grade10</td>
  65.    <td>code1</td>
  66.    <td>code2</td>
  67.    <td>code3</td>
  68.    <td>code4</td>
  69.    <td>code5</td>
  70.    <td>code6</td>
  71.    <td>code7</td>
  72.    <td>code8</td>
  73.    <td>code9</td>
  74.    <td>code10</td>
  75.    <td>cgpa</td>
  76.    <td>department</td>
  77.    <td>semester</td>
  78.   </tr>
  79.   <?php do { ?>
  80.    <tr>
  81.     <td><?php echo $row_Recordset1['matricno']; ?></td>
  82.     <td><?php echo $row_Recordset1['firstname']; ?></td>
  83.     <td><?php echo $row_Recordset1['lastname']; ?></td>
  84.     <td><?php echo $row_Recordset1['othername']; ?></td>
  85.     <td><?php echo $row_Recordset1['level']; ?></td>
  86.     <td><?php echo $row_Recordset1['course1']; ?></td>
  87.     <td><?php echo $row_Recordset1['course2']; ?></td>
  88.     <td><?php echo $row_Recordset1['course3']; ?></td>
  89.     <td><?php echo $row_Recordset1['course4']; ?></td>
  90.     <td><?php echo $row_Recordset1['course5']; ?></td>
  91.     <td><?php echo $row_Recordset1['course6']; ?></td>
  92.     <td><?php echo $row_Recordset1['course7']; ?></td>
  93.     <td><?php echo $row_Recordset1['course8']; ?></td>
  94.     <td><?php echo $row_Recordset1['course9']; ?></td>
  95.     <td><?php echo $row_Recordset1['course10']; ?></td>
  96.     <td><?php echo $row_Recordset1['grade1']; ?></td>
  97.     <td><?php echo $row_Recordset1['grade2']; ?></td>
  98.     <td><?php echo $row_Recordset1['grade3']; ?></td>
  99.     <td><?php echo $row_Recordset1['grade4']; ?></td>
  100.     <td><?php echo $row_Recordset1['grade5']; ?></td>
  101.     <td><?php echo $row_Recordset1['grade6']; ?></td>
  102.     <td><?php echo $row_Recordset1['grade7']; ?></td>
  103.     <td><?php echo $row_Recordset1['grade8']; ?></td>
  104.     <td><?php echo $row_Recordset1['grade9']; ?></td>
  105.     <td><?php echo $row_Recordset1['grade10']; ?></td>
  106.     <td><?php echo $row_Recordset1['code1']; ?></td>
  107.     <td><?php echo $row_Recordset1['code2']; ?></td>
  108.     <td><?php echo $row_Recordset1['code3']; ?></td>
  109.     <td><?php echo $row_Recordset1['code4']; ?></td>
  110.     <td><?php echo $row_Recordset1['code5']; ?></td>
  111.     <td><?php echo $row_Recordset1['code6']; ?></td>
  112.     <td><?php echo $row_Recordset1['code7']; ?></td>
  113.     <td><?php echo $row_Recordset1['code8']; ?></td>
  114.     <td><?php echo $row_Recordset1['code9']; ?></td>
  115.     <td><?php echo $row_Recordset1['code10']; ?></td>
  116.     <td><?php echo $row_Recordset1['cgpa']; ?></td>
  117.     <td><?php echo $row_Recordset1['department']; ?></td>
  118.     <td><?php echo $row_Recordset1['semester']; ?></td>
  119.    </tr>
  120.    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
  121.  </table>
  122. </div>
  123. </body>
  124. </html>
  125. <?php
  126. mysql_free_result($Recordset1);
  127. ?>


Please someone tell me what is wrong with the coding.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

Are you getting any errors? Or is it just not working?
  • Z-axis
  • Novice
  • Novice
  • Z-axis
  • Posts: 16

Post 3+ Months Ago

If using Dreamweaver, under server behaviors, create a new recordset, then bind the desired fields

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 154 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.