Jump to content

ankur0101

Members
  • Posts

    242
  • Joined

  • Last visited

Posts posted by ankur0101

  1. I have re-written the whole code

     

    index.php - The page where student will search for his result by entering roll number in text box

     

    <?php
    // Connection to database
    //require_once ("includes/settings.php")
    $hostname = "localhost";
    $database = "phpresult";
    $username = "root";
    $password = "demojoomla";   
    $conn = mysql_connect($hostname, $username, $password);
    mysql_select_db($database,$conn);
    
    if(isset($_POST['submit'])) {
       $roll_number = $_POST['roll_no_textbox'];
       
       $sql1 = mysql_query("SELECT roll_no FROM result-table WHERE roll_no = $roll_number");
       $row1 = mysql_num_rows($sql1);
       
       if($row1 == 0) {
          echo 'Error, ID does not exist';
       } else {
          header('Location: result.php?roll_no='.$roll_number);
       }   
    }
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    </head>
    
    <body>
    <table width="664" height="260" border="0">
      <tr>
        <td height="88"> </td>
      </tr>
      <tr>
        <td><p> </p>
          <form id="form1" name="form1" method="post" action="result.php">
            <div align="center">
              <label>Roll Number :
              <input type="text" name="roll_no_textbox" id="roll_no_textbox" />
              </label>
              <label>
              <input type="submit" name="button" id="button" value="search" />
              </label>
            </div>
          </form>
          <p align="center"> </p>
        <p> </p></td>
      </tr>
      <tr>
        <td> </td>
      </tr>
    </table>
    </body>
    </html>
    

     

    result.php - The page of result

     

    <?php
    $hostname = "localhost";
    $database = "phpresult";
    $username = "root";
    $password = "demojoomla";   
    $conn = mysql_connect($hostname, $username, $password);
    mysql_select_db($database,$conn);
    $roll_number = $_GET['roll_no_textbox'];
    
    $sql1 = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_number");
    $row1 = mysql_fetch_array($sql1);
    //$exam1 = $row1['exam1'];
    //$exam2 = $row1['exam2'];
    $result_name = $row1['name'];
    $result_roll_number = $row1['roll_no'];
    $result_accounts_l = $row1['accounts-l'];
    $result_accounts_ll = $row1['accounts-ll'];
    $result_accounts_lll = $row1['accounts-lll'];
    $result_mpp = $row1['mpp'];
    $result_economy = $row1['economy'];
    $result_taxation = $row1['taxation'];
    $result_computer = $row1['computer'];
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <table width="664" height="260" border="0">
      <tr>
        <td height="88"> </td>
      </tr>
      <tr>
        <td><p align="center">Your Result is here ...</p>
          
          <table width="649" height="189" border="0">
            <tr>
              <td colspan="4">Name : <?php echo $result_name ?></td>
            </tr>
            <tr>
              <td colspan="2">Roll Number : <?php echo $result_roll_number ?></td>
              <td colspan="2"> </td>
            </tr>
            <tr>
              <td width="156"><div align="right">Accounts I : </div></td>
              <td width="160"><?php echo $result_accounts_l ?></td>
              <td width="160"><div align="right">Economics : </div></td>
              <td width="155"><?php echo $result_economics ?></td>
            </tr>
            <tr>
              <td><div align="right">Accounts II : </div></td>
              <td><?php echo $result_accounts_ll ?></td>
              <td><div align="right">MPP : </div></td>
              <td><?php echo $result_mpp ?></td>
            </tr>
            <tr>
              <td><div align="right">Accounts III : </div></td>
              <td><?php echo $result_accounts_lll ?></td>
              <td><div align="right">Taxation : </div></td>
              <td><?php echo $result_taxation ?></td>
            </tr>
            <tr>
              <td colspan="2"> </td>
              <td colspan="2"> </td>
            </tr>
          </table>
          <div align="center"></div>
          <p align="center"> </p>
          <p align="center"> </p>
          <p> </p></td>
      </tr>
      <tr>
        <td> </td>
      </tr>
    </table>
    </body>
    </html>
    

     

    When I search for roll number 1 , its giving error on top of result.php

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\PHPresult\result.php on line 11

     

     

    Whats the problem ? I think its there in

     

    $row1 = mysql_fetch_array($sql1);

     

    I am confused .. :-[ :-[ :-[

  2. Hi friends,

    I am a PHP student. Yesterday night, i came with an idea that how to create a search engine like www.torrentz.com

     

    Actually on this site, there are no files, but it searches files from other torrent sites and shows like

     

    Same with http://rapidshare-search-engine.com/

    this website doesn't contains files but it shows files from rapidshare.com

     

    How can i do that for www.download.com or softpedia.com ?? ???

     

    Can anybody help me ? :) :)

  3. Code of search.php

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php
    $hostname_php_result_conn = "localhost";
    $database_php_result_conn = "phpresult";
    $username_php_result_conn = "root";
    $password_php_result_conn = "demoxampp";   
    $php_result_conn = mysql_connect($hostname_php_result_conn, $username_php_result_conn, $password_php_result_conn);
    mysql_select_db($database_php_result_conn,$php_result_conn);
    
    if(isset($_POST['submit'])) {
       $roll_no = $_POST['roll_no'];
       
       $sql1 = mysql_query("SELECT roll_no FROM result_table WHERE roll_no = $roll_no");
       $row1 = mysql_num_rows($sql1);
       
       if($row1 == 0) {
          echo 'Error, ID does not exist';
       } else {
          header('Location: show_result.php?roll_no='.$roll_no);
       }   
    }
    ?>
    
    <html>
    <head>
    <title>Search</title>
    </head>
    <body>
    
    <form action="search.php" method="post">
    <input name="roll_no" type="text" id="roll_no" />
    <input type="submit" name="submit" value="search" />
    </form>
    </body>
    </html>
    

     

    Code of show_result.php

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php
    $hostname_php_result_conn = "localhost";
    $database_php_result_conn = "phpresult";
    $username_php_result_conn = "root";
    $password_php_result_conn = "demoxampp";   
    $php_result_conn = mysql_connect($hostname_php_result_conn, $username_php_result_conn, $password_php_result_conn);
    mysql_select_db($database_php_result_conn,$php_result_conn);
    
    $roll_no = $_GET['roll_no'];
    
    $sql1 = mysql_query("SELECT * FROM result_table WHERE roll_no = $roll_no");
    $row1 = mysql_fetch_array($sql1);
    $name = $row1['name'];
    $marks = $row1['marks'];
    ?>
    
    <html>
    <head>
    <title>Show Results</title>
    </head>
    <body>
    
    <?php
    echo 'Name = '.$name.'<br />
    Marks = '.$marks;
    ?>
    
    </body>
    </html>
    

     

     

    That's it...

  4. Hello John Sir,

    Its working fine but 1 error

     

    Error in search.php

    I am using Dreamweaver 8

    Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\phpresult\search.php:2) in D:\xampp\htdocs\phpresult\search.php on line 19

     

    I am using show_result.php instead of showresult.php

    So i modified my code

     

    if(isset($_POST['submit'])) {

      $roll_no = $_POST['roll_no'];

     

      $sql1 = mysql_query("SELECT roll_no FROM result_table WHERE roll_no = $roll_no");

      $row1 = mysql_num_rows($sql1);

     

      if($row1 == 0) {

          echo 'Error, ID does not exist';

      } else {

          header('Location: show_result.php?roll_no='.$roll_no);

     

    But show_result.php is working fine.

  5. Hi friends,

    I am new in PHP MySQL.

    I am making one script of php exam results.

     

    I have following pages

     

    register.php

    search.php

    showresult.php

     

    Register.php - > A form where marks will be entered in database.

    I have done that.

     

    Search.php -> A search box with "Search" button where students will enter their roll number.

    showresult.php - > A page where results will be displayed according to the roll number entered in search.php page.

     

    The page showresult.php should work as follows .....

    showresult.php?id=56

     

    That means this will show the result of that student who's roll number is 56

    ,,

    How can i do that ?

     

×
×
  • 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.