Author Topic: php form displaying data correctly  (Read 184 times)

0 Members and 1 Guest are viewing this topic.

Offline darkknightgauryTopic starter

  • Irregular
    • View Profile
php form displaying data correctly
« on: September 08, 2007, 05:21:04 PM »
<?php

$trainer = $_POST['reportname'];
$workshop = $_POST['workshopname'];

$con = mysql_connect("localhost", "admin", "");
if (!$con) {
             die('Not connected : ' . mysql_error());
         }

   mysql_select_db("evaluationform",$con);

   $report = mysql_query("SELECT * FROM evaluation where trainer like '$trainer%'and workshop like '$workshop'ORDER BY q1");
   
    if (!$report)
    {
      echo("<b>Error performing query: " . mysql_error() . "</b>");
      exit();
    }
   
  print "   |q1 | &nbsp; &nbsp;q2 | &nbsp; &nbsp;q3 | &nbsp; &nbsp;q4 | &nbsp; &nbsp;q5
               |&nbsp; &nbsp;q6      | &nbsp; &nbsp;q7 | &nbsp; &nbsp;q8 | &nbsp; &nbsp;q9 
               |&nbsp; &nbsp;q10     | &nbsp; &nbsp;q11| &nbsp; &nbsp;q12| &nbsp; &nbsp;q13";
/*here is my problem question 1-11 are just numbers so they fit fine in this schema however, question 12 and 13 and textboxes therefore when people write more than a couple of characters the whole table get mess up. What I need is some way to display the data in a very elagant fashion. I been experimenting with while statements and tables but is quite difficult I just need some hints and examples if at all possible. */
      

 while ($row = mysql_fetch_array($report))
    {
        $question1 = $row["q1"];
        $question2 = $row["q2"];
        $question3 = $row["q3"];
        $question4 = $row["q4"];
        $question5 = $row["q5"];
        $question6 = $row["q6"];
      $question7 = $row["q7"];
      $question8 = $row["q8"];
      $question9 =$row["q9"];
      $question10 =$row["q10"];
      $question11 =$row["q11"];
      $question12 =$row["q12"];
      $question13 =$row["q13"];
      
      print("
      <table>
      <tr>
      <td> $question1 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question2 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question3 </td>
      <td> &nbsp; &nbsp; &nbsp; &nbsp; $question4 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question5 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question6 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question7 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question8 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question9 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question10 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question11 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question12 </td>
      <td> &nbsp; &nbsp;&nbsp; &nbsp;  $question13 </td>


      </tr>
      </table>");
      
            
   }
    print("<br><br>");
   print("
            <td> &nbsp; &nbsp;&nbsp; &nbsp;  The evaluation of this trainer:$trainer</td><br>
            <td> &nbsp; &nbsp;&nbsp; &nbsp;  Regarding this workshop: $workshop</td>");
            
   ?>      

Offline LiamProductions

  • Enthusiast
    • View Profile
Re: php form displaying data correctly
« Reply #1 on: September 08, 2007, 06:29:38 PM »
Whats the errors?
Quote
In this hour, Your going to get your hands dirty with some of the nuts and bolts in the language


Offline darkknightgauryTopic starter

  • Irregular
    • View Profile
Re: php form displaying data correctly
« Reply #2 on: September 08, 2007, 08:15:28 PM »
There isnt errors. The data is not displayed elegantly. How can i make an while statement that creats an per every field in the database that creates tables with borders?

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.