display databse records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mubs
    New Member
    • Mar 2007
    • 77

    display databse records

    Hi all,

    I have a website set up using database,

    what i want to achieve is, i want a user to enter their number and then the database to display the records for only that number they entered...am using dreamweaver cs3
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    That sounds fun. But where is your question?

    Comment

    • Mubs
      New Member
      • Mar 2007
      • 77

      #3
      i got this far, but nothing appears just blank, no results are displayed..

      [PHP]<?php require_once('C onnections/mysql_connect.p hp'); ?>
      <?php
      if (!function_exis ts("GetSQLValue String")) {
      function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "", $theNotDefinedV alue = "")
      {
      $theValue = get_magic_quote s_gpc() ? stripslashes($t heValue) : $theValue;

      $theValue = function_exists ("mysql_real_es cape_string") ? mysql_real_esca pe_string($theV alue) : mysql_escape_st ring($theValue) ;

      switch ($theType) {
      case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
      case "long":
      case "int":
      $theValue = ($theValue != "") ? intval($theValu e) : "NULL";
      break;
      case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'" : "NULL";
      break;
      case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
      case "defined":
      $theValue = ($theValue != "") ? $theDefinedValu e : $theNotDefinedV alue;
      break;
      }
      return $theValue;
      }
      }

      $editFormAction = $_SERVER['PHP_SELF'];
      if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_ SERVER['QUERY_STRING']);
      }
      mysql_select_db ($database_mysq l_connect, $mysql_connect) ;
      if(isset($_POST['submit']))
      {
      //Get the input passed by the user
      $student_number =$_POST['student_number '];
      //Get the records specific to this student number
      $query_Recordse t1 = "SELECT * FROM robs_enterprise WHERE student_number= '$student_numbe r'";
      $Recordset1 = mysql_query($qu ery_Recordset1, $mysql_connect) or die(mysql_error ());
      $row_Recordset1 = mysql_fetch_ass oc($Recordset1) ;
      $totalRows_Reco rdset1 = mysql_num_rows( $Recordset1);
      }

      ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitl ed Document</title>
      </head>

      <body>
      <p>&nbsp;</p>

      <p><input type="hidden" name="MM_insert " value="form1" />
      <input type="text" name="Student number" id="Student number" />
      <input type="submit" value="Submit" />
      </p>
      </body>
      </html>[/PHP]

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        got this far, but nothing appears just blank, no results are displayed..
        Then what php errors are being reported.
        What mysql errors are being reported.
        What are the values of your variables

        Comment

        • vetrib2w
          New Member
          • Aug 2008
          • 14

          #5
          I did few changes in your code.. try this now?

          [PHP]<?php require_once('C onnections/mysql_connect.p hp'); ?>
          <?php
          if (!function_exis ts("GetSQLValue String")) {
          function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "", $theNotDefinedV alue = "")
          {
          $theValue = get_magic_quote s_gpc() ? stripslashes($t heValue) : $theValue;

          $theValue = function_exists ("mysql_real_es cape_string") ? mysql_real_esca pe_string($theV alue) : mysql_escape_st ring($theValue) ;

          switch ($theType) {
          case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
          case "long":
          case "int":
          $theValue = ($theValue != "") ? intval($theValu e) : "NULL";
          break;
          case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'" : "NULL";
          break;
          case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
          case "defined":
          $theValue = ($theValue != "") ? $theDefinedValu e : $theNotDefinedV alue;
          break;
          }
          return $theValue;
          }
          }

          $editFormAction = $_SERVER['PHP_SELF'];
          if (isset($_SERVER['QUERY_STRING'])) {
          $editFormAction .= "?" . htmlentities($_ SERVER['QUERY_STRING']);
          }
          mysql_select_db ($database_mysq l_connect, $mysql_connect) ;
          if(isset($_POST['student_number ']))
          {
          //Get the input passed by the user
          $student_number =$_POST['student_number '];
          //Get the records specific to this student number
          $query_Recordse t1 = "SELECT * FROM robs_enterprise WHERE student_number= '$student_numbe r'";
          $Recordset1 = mysql_query($qu ery_Recordset1, $mysql_connect) or die(mysql_error ());
          $row_Recordset1 = mysql_fetch_ass oc($Recordset1) ;
          $totalRows_Reco rdset1 = mysql_num_rows( $Recordset1);
          }

          ?>
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <title>Untitl ed Document</title>
          </head>

          <body>
          <p>&nbsp;</p>

          <p>
          <input type="hidden" name="MM_insert " value="form1" />
          <input type="text" name="student_n umber" id="student_num ber" />
          <input type="submit" value="submit" />
          </p>
          </body>
          </html>[/PHP]

          Comment

          Working...