-2

I am trying to display some result from my database , but nothing is displayed . Please help me.

      <?php
                include_once("connect.php");
                //query the database
                $query = mysql_query("SELECT * FROM evaluation ORDER BY Matricule DESC") or die($myQuery."<br/><br/>".mysql_error());;
                //fetch the results / convert results into an array

                while($rows = mysql_fetch_array($query)):

                    $id_Matiere = $row['id_Matiere'];
                    $Td = $row['Td'];
                    $Tp = $row['Tp'];
                    $Exam = $row['Exam'];
                    echo $id_Matiere .$Td .$Tp .$Exam;
                endwhile;
            ?>

-----------note-off.php--------------
<!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" xml:lang="EN" lang="EN" dir="ltr">
<head >
<title>Département Math-Info | Note Tab</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" href="styles/layout.css" type="text/css" />
<!-- 3 Column Stylesheet Added To The Page And Not To The Layout.css -->
<link rel="stylesheet" href="styles/3_column.css" type="text/css" />
</head>
<body id="top">
<div class="wrapper row1">
  <div id="header" class="clear">
    <div class="fl_left">
      <h1><a href="index.html">Département Math-Info </a></h1>
      <p>Just pour vous</p>
    </div>
    <form action="#" method="post" id="login">
      <fieldset>
      <h6>Ensignant Login</h6>
        <legend>Ensignant Login</legend>
        <input type="password" />
        <input type="text" />
        <div id="forgot">Need <a href="#">Help ?</a> or <a href="#">Forgot Your Details ?</a></div>
        <input type="image" src="images/sign_in.gif" id="signin" alt="Sign In" />
      </fieldset>
    </form>
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row2">
  <div id="topnav">
    <ul>
      <li><a href="index.html">Homepage</a></li>
      <li><a href="contact-us.html">CONTACT US</a></li>
      <li><a href="nouveauté.html">NOUVEAUTé</a></li>

      <li class="active"><a href="note-tab.html">Note Tab</a></li>
      <li class="last"><a href="gallery.html">Gallery</a></li>
    </ul>
    <div  class="clear"></div>
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row4">
  <div id="container" class="clear">
    <!-- ####################################################################################################### -->
    <div id="left_column">
      <div class="holder">
        <h2 class="title">Quick Links</h2>
        <ul class="nostart">
          <li><a href="contact-us.html">Contact Us</a></li>
            <li><a href="#">Nouveauté</a></li>
            <li><a href="#">Spéciality</a></li>
            <li><a href="#">Math &amp; Informatique</a></li>
            <li><a href="#">2em Math</a></li>
            <li><a href="#">3em Math</a></li>
            <li><a href="#">2em Informatique</a></li>
            <li><a href="#">3em Informatique</a></li>
            <li><a href="#">Student Login</a></li>
            <li><a href="#">Ensignant Login</a></li>
            <li><a href="#">Online Courses</a></li>
            <li><a href="#">Gallery</a></li>
        </ul>
      </div>
      <div class="holder">
        <h2 class="title">Lorem ipsum dolor</h2>
        <div class="imgholder"><img src="images/demo/190x90.gif" alt="" /></div>
        <div class="imgholder last"><img src="images/demo/190x90.gif" alt="" /></div>
      </div>
    </div>
    <!-- ############ -->
    <div id="content">
        <p>You Must login to see this Content : <p>

      <table summary="Summary Here" cellpadding="0" cellspacing="0">
        <thead>
          <tr>
            <th>Header 1</th>
            <th>Header 2</th>
            <th>Header 3</th>
            <th>Header 4</th>
          </tr>
        </thead>
        <tbody>
          <tr class="light">
            <?php
                require("connect.php");
                //query the database
                $query = mysql_query("SELECT * FROM evaluation") or die($myQuery."<br/><br/>".mysql_error());
                //fetch the results / convert results into an array

                while($rows = mysql_fetch_array($query)):

                    $id_Matiere = $rows['id_Matiere'];
                    $Td = $rows['Td'];
                    $Tp = $rows['Tp'];
                    $Exam = $rows['Exam'];
                    echo "$id_Matiere $Td $Tp $Exam";
                endwhile;
            ?>
          </tr>

        </tbody>
      </table>

    </div>
    <!-- ############ -->
    <div id="right_column">
      <div class="holder">
        <h2 class="title">Definition Of The Note-Tab </h2>
        <p>This Tab is used to Display Notes of TD TP & Exam .</p>

        <p>To Be Able to see what in this tab <a href="note-off.html">NOTE-TAB</a> you must login through the login area Above ,if u are
        Ensignant you have to use your Email and Password to log-in ,or if you're a Student u can use your Matricule Thanks. </p>
        <p class="readmore"><a href="#">Continue Reading &raquo;</a></p>
      </div>
      <div class="holder">
        <h2 class="title">Publicity</h2>
        <div class="imgholder"><img src="images/demo/240x90.gif" alt="" /></div>
        <div class="imgholder"><img src="images/demo/240x90.gif" alt="" /></div>
        <div class="imgholder last"><img src="images/demo/240x90.gif" alt="" /></div>
      </div>
    </div>
    <!-- ####################################################################################################### -->
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row5">
  <div id="footer" class="clear">
    <!-- ####################################################################################################### -->
    <div class="foot_contact">
      <h2>University Name Here</h2>
      <address>
      Address Line 1<br />
      Address Line 2<br />
      Town/City<br />
      Postcode/Zip
      </address>
      <ul>
        <li><strong>Tel:</strong> xxxxx xxxxxxxxxx</li>
        <li><strong>Fax:</strong> xxxxx xxxxxxxxxx</li>
        <li class="last"><strong>Email:</strong> <a href="#">contact@mydomain.com</a></li>
      </ul>
    </div>
    <div class="footbox">
      <h2>Administration</h2>
      <ul>
        <li><a href="#">Disclaimer</a></li>
        <li><a href="#">Accessibility</a></li>
        <li><a href="#">Freedom of Information</a></li>
        <li><a href="#">Website Privacy</a></li>
        <li><a href="#">Press Release Information</a></li>
        <li><a href="#">Annual Report</a></li>
        <li><a href="#">Financial Statements</a></li>
        <li><a href="#">Job Vacancies</a></li>
        <li class="last"><a href="#">Semester Dates</a></li>
      </ul>
    </div>
    <div class="footbox">
      <h2>Link Block 2</h2>
      <ul>
        <li><a href="#">Schools and Colleges</a></li>
        <li><a href="#">Student Activities</a></li>
        <li><a href="#">Student Affairs</a></li>
        <li><a href="#">Student Development</a></li>
        <li><a href="#">Student Financial Services</a></li>
        <li><a href="#">Student Group Directory</a></li>
        <li><a href="#">Student Life</a></li>
        <li><a href="#">International Students</a></li>
        <li class="last"><a href="#">Global Learning</a></li>
      </ul>
    </div>
    <div class="footbox last">
      <h2>Link Block 3</h2>
      <ul>
        <li><a href="#">Academic Advisory</a></li>
        <li><a href="#">Academic Assistance</a></li>
        <li><a href="#">Academic Calendars</a></li>
        <li><a href="#">Academics Office</a></li>
        <li><a href="#">Administration</a></li>
        <li><a href="#">Adult Learners</a></li>
        <li><a href="#">Alumni Chapters</a></li>
        <li><a href="#">Alumni Events</a></li>
        <li class="last"><a href="#">Residential Colleges</a></li>
      </ul>
    </div>
    <!-- ####################################################################################################### -->
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper">
  <div id="copyright" class="clear">
    <p class="fl_left">Copyright &copy; 2013 - All Rights Reserved - <a href="#">Domain Name</a></p>
    <p class="fl_right">Template by <a href="http://www.os-templates.com/" title="Free Website Templates">OS Templates</a></p>
  </div>
</div>
</body>
</html>

i tried to output the result of the database on my site but it didn't displayed as i want it to (in table and with css desing) please what to do

and this part of the code that i refer to :

 <div id="content">
            <p>You Must login to see this Content : <p>

          <table summary="Summary Here" cellpadding="0" cellspacing="0">
            <thead>
              <tr>
                <th>Header 1</th>
                <th>Header 2</th>
                <th>Header 3</th>
                <th>Header 4</th>
              </tr>
            </thead>
            <tbody>
              <tr class="light">
                <?php
                    require("connect.php");
                    //query the database
                    $query = mysql_query("SELECT * FROM evaluation") or die($myQuery."<br/><br/>".mysql_error());
                    //fetch the results / convert results into an array

                    while($rows = mysql_fetch_array($query)):

                        $id_Matiere = $rows['id_Matiere'];
                        $Td = $rows['Td'];
                        $Tp = $rows['Tp'];
                        $Exam = $rows['Exam'];
                        echo "$id_Matiere $Td $Tp $Exam";
                    endwhile;
                ?>
              </tr>

            </tbody>
          </table>

        </div>

4 Answers4

1

Typo -

$query = mysql_query("SELECT * FROM evaluation ORDER BY Matricule DESC") 
         or die($myQuery."<br/><br/>".mysql_error());;
                                                     ^====== extra semicolon

Also change this ($row to $rows) -

while($rows = mysql_fetch_array($query)):

   $id_Matiere = $rows['id_Matiere'];
   $Td = $rows['Td'];
   $Tp = $rows['Tp'];
   $Exam = $rows['Exam'];
   echo $id_Matiere .$Td .$Tp .$Exam;

endwhile;


Solution to next problem:

<table summary="Summary Here" cellpadding="0" cellspacing="0">
<thead>
<tr>
   <th>Header 1</th>
   <th>Header 2</th>
   <th>Header 3</th>
   <th>Header 4</th>
</tr>
</thead>

<tbody>

<?php
require("connect.php");
//query the database
$query = mysql_query("SELECT * FROM evaluation") or die($myQuery."<br/> <br/>".mysql_error());
//fetch the results / convert results into an array

while($rows = mysql_fetch_array($query)):

    echo "<tr class='light'>";
    echo "<td>".$rows['id_Matiere']."</td>";
    echo "<td>".$rows['Td']."</td>";
    echo "<td>".$rows['Tp']."</td>";
    echo "<td>".$rows['Exam']."</td>";
    echo "</tr>";

endwhile;

?>

</tbody>
</table>
Parag Tyagi
  • 8,780
  • 3
  • 42
  • 47
0

You are referencing "row" and in the loop you have named the variable "rows".

Steve Parish
  • 1,824
  • 2
  • 14
  • 12
0

Try this:

 <?php
            include_once("connect.php");
            //query the database
            $query = mysql_query("SELECT * FROM evaluation ORDER BY Matricule DESC") or die($myQuery."<br/><br/>".mysql_error());;
            //fetch the results / convert results into an array

            while($row = mysql_fetch_array($query)):

                $id_Matiere = $row['id_Matiere'];
                $Td = $row['Td'];
                $Tp = $row['Tp'];
                $Exam = $row['Exam'];
                echo $id_Matiere .$Td .$Tp .$Exam;
            endwhile;
        ?>
almo
  • 6,107
  • 6
  • 43
  • 86
  • Guys to make it easier for you to understand what i want check this image :http://www4.0zz0.com/2014/04/23/17/998260063.png i want them to be by order and every note in his column thanks – user3558634 Apr 23 '14 at 17:32
0

One thing I am noticing is you are using $rows and $row ... which seems to be a typo.

This tells me you probably don't have all error reporting enabled for testing. You would have gotten a notice about the typo if all errors had been enabled. ;) You should consider doing that and then report back with the results if fixing the typo doesn't resolve your issue.


Enable all errors for development:

// Add this to *the very top* of your test script

error_all();


// Add this to your functions file

function error_all ()
{
    // Guaranteed to show all error levels in all versions
    error_reporting(-1);

    // Guaranteed to show everything on screen
    ini_set('display_errors', 1);

    // Show errors that occur during PHP's startup sequence
    ini_set('display_startup_errors', 1);
}


Update:

Regarding your question update and comment...

It's unclear if you still have data issue (no data all) or simply a display issue (data, but not displayed how you like). I think the latter... in which case it probably should have been a separate question. Anyway...

If you still are not getting data from your database to the screen...

Glad to help... once you enable all errors as shown and report back. ;) Otherwise, it really could be anything at all and everyone is flying blind. Seeing the errors or lack thereof will likely solve your problem quite easily or at least rule most things out. Be sure to put error_all() at the very top before anything else in your test script.

If you are getting data from your database to the screen, but it's simply not displayed how you want...

It looks like you're trying to echo several rows of fields into the middle of a single <tr> tag. Pretty sure you want <tr></tr> tags inside your loop around all your fields and <td></td> around each of those fields as well... in which case your CSS should start working correctly.

If none of those things solves your issue...

Comment back or update your question and be explicitly clear on what problems are solved and what problems you are still having. This is an important skill to develop when trying to get help.

Michael X
  • 21
  • 1
  • 4
  • thanks buddy ,but the problem solved the problem was on the row i forget to add the s ,please help me with my other problem thanks ! – user3558634 Apr 23 '14 at 17:13
  • @user3558634 For alternating row color... have you tried a pure CSS solution using nth-child? Or Javascript / jQuery? Check this http://stackoverflow.com/questions/3084261/alternate-table-row-color-using-css it shows both in the first answer. – Michael X Apr 23 '14 at 21:12
  • Hey My Friend ,can u help me through Skype :Serious.Gamer thanks – user3558634 Apr 23 '14 at 21:36
  • @user3558634 I think this has evolved well beyond the scope of the original problem / question. Remove the `class="light"` from your code and implement a _pure CSS solution_ for alternating row colors using nth-child. PHP is the wrong tool for the job IMO. That said, if you insist on causing yourself future pain... search StackOverflow or Google for "alternating table row color PHP" and you'll find solutions to this problem. Godspeed! PS You should select an answer that solved the original problem... which seems to be any of them more or less. – Michael X Apr 24 '14 at 01:19
  • thanks for all of your helps ,all of u help me with my issues ,even that i don't have a plan of problems , but i can't update them all in here ,i am very amateur in php so if any body coukd help me in skype it will be very kind of him thanks all for your help and waiting for your reply ! – user3558634 Apr 24 '14 at 02:03