Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. <?php
  2.  
  3. $mysqli=new mysqli("localhost","root","mysqlpassword","MarcTextOldBib");
  4. if (mysqli_connect_errno()) {echo "Failed to connect to MySQL: " . mysqli_connect_error();}
  5. $db_abfrage = "SELECT `cid` , `field_data` FROM T1xx";
  6. $j=0;
  7. $db_ausgabe = $mysqli->query($db_abfrage);
  8. while($row = $db_ausgabe->fetch_object()){
  9.     $names[$j] = array( "cid"           => $row->cid,
  10.                         "field_data"    => $row->field_data,
  11.                      );
  12.     $j++;
  13. }
  14.  
  15.  
  16. $mysqli->close();
  17.  
  18. echo"
  19. <table border='1'>
  20. <thead><tr>
  21. <th>ID</th> <th>Name</th>
  22. </tr></thead>";
  23.  
  24. //3203
  25. $ID=1;
  26. for ( $i = 0; $i <= 20; $i++ ){
  27.     $cid = $names[$i][cid];
  28.     echo "<tr>";
  29.  
  30.     if( ($ID) == $names[$i][cid] ){
  31.         echo "<td>".($ID)."</td>";
  32.         echo "<td>". $names[$i][field_data] ."</td>";
  33.         echo "</tr>";
  34.         $ID++;
  35.     } else {
  36.         while( $ID != $names[$i][cid] ){
  37.             echo "<td>".($ID)."</td>";
  38.             echo "<td></td>";
  39.             echo "</tr>";
  40.             ++$ID;
  41.         }
  42.         $i--;
  43.     }
  44.  
  45. }
  46.  
  47. for ( $i = 20; $i <= 40; $i++ ){
  48.     $cid = $names[$i][cid];
  49.     echo "<tr>";
  50.  
  51.     if( ($ID) == $names[$i][cid] ){
  52.         echo "<td>".($ID)."</td>";
  53.         echo "<td>". $names[$i][field_data] ."</td>";
  54.         echo "</tr>";
  55.         $ID++;
  56.     } else {
  57.         while( $ID != $names[$i][cid] ){
  58.             echo "<td>".($ID)."</td>";
  59.             echo "<td></td>";
  60.             echo "</tr>";
  61.             ++$ID;
  62.         }
  63.         $i--;
  64.     }
  65.  
  66. }
  67.  
  68. echo "</table>";
  69.  
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement