php/mysql table

  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

Okay I am using 2 different tables in the db to make this table

I got this table. where you see crown,profile,crown,profile,mazak 650 -> all of that is pulled from one table in the DB
while the 7037542 stuff is listed under a different table and has a row listed for a particular machine.

so how you see it it is listed like

7037542 - crown
7038561 - mazak

and each order will need to go to its correct row.

I am drawling a brain fart as to how to do the while statements on this issue.

Image
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

PHP Code: [ Select ]
<?
$m =  "SELECT  * FROM bob";
$stored_machines = mysql_query($m);
echo"<table><tr>";
while ($mch = mysql_fetch_array($stored_machines)) {
   echo "<td>".$mch['machine']."<td>";
   $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
   while ($ord = mysql_fetch_array($stored_orders)) {
      echo "<tr><td>".$ord['serial']."</td></tr>";
   }
}
echo"</tr></table>";
  ?>
  1. <?
  2. $m =  "SELECT  * FROM bob";
  3. $stored_machines = mysql_query($m);
  4. echo"<table><tr>";
  5. while ($mch = mysql_fetch_array($stored_machines)) {
  6.    echo "<td>".$mch['machine']."<td>";
  7.    $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
  8.    while ($ord = mysql_fetch_array($stored_orders)) {
  9.       echo "<tr><td>".$ord['serial']."</td></tr>";
  10.    }
  11. }
  12. echo"</tr></table>";
  13.   ?>


It works now but the issue is it only displays the info going down. I want the $mch['machine'] to go sideways like it is in the picture above.

This is how it looks right now
Quote:
Mazak 650
T7040960
T7040963
DMG1
T7040961
6300 #2
T7040962


This is how it should look
Code: [ Select ]
Mazak 650  DMG1   6300 #2 
T7040960  T7040961 T7040962
T7040963
  1. Mazak 650  DMG1   6300 #2 
  2. T7040960  T7040961 T7040962
  3. T7040963
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

a little confusing but i think i know what your talking about.

I would use a one to many relationship join

to Pseudocode this out to see if this works for you or gives you an idea

table one I'll call brands and table two called products

in the brands table you have crown, profile, and mazak

| id | name |
|--------------|
|1 | Crown |
|2 | Profile |
|3 | Mazak |
|--------------|

in products table

| parent_id | name |
|---------------------|
|1 | 7037542 |
|3 | 7037543 |
|1 | 7037544 |
|2 | 7037545 |
|2 | 7037546 |
|2 | 7037547 |
|1 | 7037548 |
|3 | 7037549 |
|1 | 7037550 |
|3 | 7037551 |
|3 | 7037552 |
|1 | 7037553 |
|---------------------|

MYSQL Code: [ Select ]
SELECT `brands`.`name`, `products`.`name` AS `machine`
FROM `brands`, `products`
WHERE `brands`.`id` = `products`.`parent_id`
 
  1. SELECT `brands`.`name`, `products`.`name` AS `machine`
  2. FROM `brands`, `products`
  3. WHERE `brands`.`id` = `products`.`parent_id`
  4.  


output should be something like

| name | machine |
|------------------|
|Crown | 7037542 |
|Mazak | 7037543 |
|Crown | 7037544 |
|Profile | 7037545 |
|Profile | 7037546 |
|Profile | 7037547 |
|Crown | 7037548 |
|Mazak | 7037549 |
|Crown | 7037550 |
|Mazak | 7037551 |
|Mazak | 7037552 |
|Crown | 7037553 |
|------------------|

Based On what you've stated this is how i assume your result to show up as If this is correct you could then you an array or object based on what language you're using to pre build your table.

My PHP example
PHP Code: [ Select ]
<?php
 
$table = array();
$ii = 0;
 
while($row = mysql_fetch_assoc($result)) {
    $table[$ii][$row['name']][] = $row['machine'];
    $ii++;
}
 
$table_keys = array_keys($table[0]);
$ii = 0;
 
// Then build the final output ?>
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php echo implode('</td><td>', $table_keys); ?></td>
  </tr>
  <?php foreach($table as $key => $table_row) { ?>
  <tr>
    <?php foreach($table_keys as $value) {
        echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
    ?>
  </tr>
  <?php $ii++; } ?>
 
  1. <?php
  2.  
  3. $table = array();
  4. $ii = 0;
  5.  
  6. while($row = mysql_fetch_assoc($result)) {
  7.     $table[$ii][$row['name']][] = $row['machine'];
  8.     $ii++;
  9. }
  10.  
  11. $table_keys = array_keys($table[0]);
  12. $ii = 0;
  13.  
  14. // Then build the final output ?>
  15. <table border="0" cellspacing="0" cellpadding="0">
  16.   <tr>
  17.     <td><?php echo implode('</td><td>', $table_keys); ?></td>
  18.   </tr>
  19.   <?php foreach($table as $key => $table_row) { ?>
  20.   <tr>
  21.     <?php foreach($table_keys as $value) {
  22.         echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
  23.     ?>
  24.   </tr>
  25.   <?php $ii++; } ?>
  26.  


PS. I just saw you added info
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

From your example get rid of the trs
PHP Code: [ Select ]
    <?
    $m =  "SELECT  * FROM bob";
    $stored_machines = mysql_query($m);
    echo"<table><tr>";
    while ($mch = mysql_fetch_array($stored_machines)) {
       echo "<td>".$mch['machine']."<td>";
       $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
       while ($ord = mysql_fetch_array($stored_orders)) {
          echo "<td>".$ord['serial']."</td>"; //////// RIGHT HERE
       }
    }
    echo"</tr></table>";
      ?>
 
  1.     <?
  2.     $m =  "SELECT  * FROM bob";
  3.     $stored_machines = mysql_query($m);
  4.     echo"<table><tr>";
  5.     while ($mch = mysql_fetch_array($stored_machines)) {
  6.        echo "<td>".$mch['machine']."<td>";
  7.        $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
  8.        while ($ord = mysql_fetch_array($stored_orders)) {
  9.           echo "<td>".$ord['serial']."</td>"; //////// RIGHT HERE
  10.        }
  11.     }
  12.     echo"</tr></table>";
  13.       ?>
  14.  


EDIT:: Never mind that won't work i just looked at the code again
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

Mix my first post in

PHP Code: [ Select ]
<?
 
$table      = array();
$table_keys = array();
$ii=0;
 
$m =  "SELECT  * FROM bob";
$stored_machines = mysql_query($m);
while ($mch = mysql_fetch_array($stored_machines)) {
    $table_keys[] = $mch['machine']
    $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
    while ($ord = mysql_fetch_array($stored_orders)) {
         
        $table[$ii][$mch['machine']][] = $ord['serial'];
 
    }
}
 
// Reset counter
$ii = 0;
 
// Then build the final output
 
?>
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php echo implode('</td><td>', $table_keys); ?></td>
  </tr>
  <?php foreach($table as $key => $table_row) { ?>
  <tr>
    <?php foreach($table_keys as $value) {
        echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
    ?>
  </tr>
  <?php $ii++; } ?>
 
  1. <?
  2.  
  3. $table      = array();
  4. $table_keys = array();
  5. $ii=0;
  6.  
  7. $m =  "SELECT  * FROM bob";
  8. $stored_machines = mysql_query($m);
  9. while ($mch = mysql_fetch_array($stored_machines)) {
  10.     $table_keys[] = $mch['machine']
  11.     $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
  12.     while ($ord = mysql_fetch_array($stored_orders)) {
  13.          
  14.         $table[$ii][$mch['machine']][] = $ord['serial'];
  15.  
  16.     }
  17. }
  18.  
  19. // Reset counter
  20. $ii = 0;
  21.  
  22. // Then build the final output
  23.  
  24. ?>
  25. <table border="0" cellspacing="0" cellpadding="0">
  26.   <tr>
  27.     <td><?php echo implode('</td><td>', $table_keys); ?></td>
  28.   </tr>
  29.   <?php foreach($table as $key => $table_row) { ?>
  30.   <tr>
  31.     <?php foreach($table_keys as $value) {
  32.         echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
  33.     ?>
  34.   </tr>
  35.   <?php $ii++; } ?>
  36.  


NOT PERFECT OR TESTED but the idea/concept is there
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

I am getting this
Code: [ Select ]
Parse error: syntax error, unexpected end of file in temp2.php on line 36


|-Mazak 650-|-DMG1-----|-6300 #2--|
|-T7040960--|-T7040961-|-T7040962-|
|-T7040963--|
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

This is how i want it to look
demonmaestro wrote:
Image
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

$table_keys[] = $mch['machine']; missing ;

EDIT:: Also there is a missing }
PHP Code: [ Select ]
<?php foreach($table_keys as $value) {
        echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
   } ?> // right here
 
  1. <?php foreach($table_keys as $value) {
  2.         echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
  3.    } ?> // right here
  4.  
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

ScottG wrote:
$table_keys[] = $mch['machine']; missing ;


Yea i found the first ; one but is there a second one i am missing? still coming up with same error,

never mind found it. Was missing a }
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

Array is not array.. array has gone array.. there is data that is not showing...

Quote:

Mazak 650 DMG1 6300 #2 6300 #3
Array
Array
Array
Array
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

check the edit above also in the first while loop remove the inner array

$table[$ii][$mch['machine']][] = $ord['serial']; this to $table[$ii][$mch['machine']] = $ord['serial'];
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

The data shows but not under the correct machine.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

Could you var_dump($table); also what is the HTML output showing up as?
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

OK i think i figured it out in the database area i forgot to the add the $ii increments

PHP Code: [ Select ]
    <?
     
    $table      = array();
    $table_keys = array();
    $ii=0;
     
    $m =  "SELECT  * FROM bob";
    $stored_machines = mysql_query($m);
    while ($mch = mysql_fetch_array($stored_machines)) {
        $table_keys[] = $mch['machine']; // Fixed the ;
        $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
        while ($ord = mysql_fetch_array($stored_orders)) {
             
            $table[$ii][$mch['machine']][] = $ord['serial'];
            $ii++; // Added the $ii++
        }
        $ii=0; // Reset the counter
    }
     
    // Reset counter
    $ii = 0;
     
    // Then build the final output
     
    ?>
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><?php echo implode('</td><td>', $table_keys); ?></td>
      </tr>
      <?php foreach($table as $key => $table_row) { ?>
      <tr>
        <?php foreach($table_keys as $value) {
            echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
        } // Fixed the missing }
        ?>
      </tr>
      <?php $ii++; } ?>
     
 
 
  1.     <?
  2.      
  3.     $table      = array();
  4.     $table_keys = array();
  5.     $ii=0;
  6.      
  7.     $m =  "SELECT  * FROM bob";
  8.     $stored_machines = mysql_query($m);
  9.     while ($mch = mysql_fetch_array($stored_machines)) {
  10.         $table_keys[] = $mch['machine']; // Fixed the ;
  11.         $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
  12.         while ($ord = mysql_fetch_array($stored_orders)) {
  13.              
  14.             $table[$ii][$mch['machine']][] = $ord['serial'];
  15.             $ii++; // Added the $ii++
  16.         }
  17.         $ii=0; // Reset the counter
  18.     }
  19.      
  20.     // Reset counter
  21.     $ii = 0;
  22.      
  23.     // Then build the final output
  24.      
  25.     ?>
  26.     <table border="0" cellspacing="0" cellpadding="0">
  27.       <tr>
  28.         <td><?php echo implode('</td><td>', $table_keys); ?></td>
  29.       </tr>
  30.       <?php foreach($table as $key => $table_row) { ?>
  31.       <tr>
  32.         <?php foreach($table_keys as $value) {
  33.             echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
  34.         } // Fixed the missing }
  35.         ?>
  36.       </tr>
  37.       <?php $ii++; } ?>
  38.      
  39.  
  40.  
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

Close but no cigar. still getting "array"
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

damn lol i forgot one thing that was fixed before $table[$ii][$mch['machine']][] = $ord['serial']; this to $table[$ii][$mch['machine']] = $ord['serial'];
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

Its a cluster but i can figure it out from here..
Thank you sir. You are a life saver. :bouncingsmile:
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

I'll post my test code it's different since i don't have a database but it does work the same as having a database.

PHP Code: [ Select ]
    <?php
   $db1 = array(
      array('machine' => 'Mazak 650'),
      array('machine' => 'DMG1'),
      array('machine' => '6300 #2')
      );
   
   $db2 = array(
      "Mazak 650" => array(array('serial' => 'T7040960'), array('serial' => 'T7040963')),
      "DMG1" => array(array('serial' => 'T7040961')),
      "6300 #2" => array(array('serial' => 'T7040962'))  
      );
     
    $table      = array();
    $table_keys = array();
    $ii=0;
     
 
    foreach($db1 as $mch) {
        $table_keys[] = $mch['machine'];
//var_dump($db2[$mch['machine']]);
        foreach ($db2[$mch['machine']] as $ord) {
             
            $table[$ii][$mch['machine']] = $ord['serial'];
     $ii++;
        }
      $ii=0;
    }
     
   //var_dump($table);
    // Reset counter
    $ii = 0;
     
    // Then build the final output
     
    ?>
    <table border="2" cellspacing="0" cellpadding="0">
      <tr>
        <td><?php echo implode('</td><td>', $table_keys); ?></td>
      </tr>
      <?php foreach($table as $key => $table_row) { ?>
      <tr>
        <?php foreach($table_keys as $value) {
            echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
      } ?>
      </tr>
      <?php $ii++; } ?>
 
 
  1.     <?php
  2.    $db1 = array(
  3.       array('machine' => 'Mazak 650'),
  4.       array('machine' => 'DMG1'),
  5.       array('machine' => '6300 #2')
  6.       );
  7.    
  8.    $db2 = array(
  9.       "Mazak 650" => array(array('serial' => 'T7040960'), array('serial' => 'T7040963')),
  10.       "DMG1" => array(array('serial' => 'T7040961')),
  11.       "6300 #2" => array(array('serial' => 'T7040962'))  
  12.       );
  13.      
  14.     $table      = array();
  15.     $table_keys = array();
  16.     $ii=0;
  17.      
  18.  
  19.     foreach($db1 as $mch) {
  20.         $table_keys[] = $mch['machine'];
  21. //var_dump($db2[$mch['machine']]);
  22.         foreach ($db2[$mch['machine']] as $ord) {
  23.              
  24.             $table[$ii][$mch['machine']] = $ord['serial'];
  25.      $ii++;
  26.         }
  27.       $ii=0;
  28.     }
  29.      
  30.    //var_dump($table);
  31.     // Reset counter
  32.     $ii = 0;
  33.      
  34.     // Then build the final output
  35.      
  36.     ?>
  37.     <table border="2" cellspacing="0" cellpadding="0">
  38.       <tr>
  39.         <td><?php echo implode('</td><td>', $table_keys); ?></td>
  40.       </tr>
  41.       <?php foreach($table as $key => $table_row) { ?>
  42.       <tr>
  43.         <?php foreach($table_keys as $value) {
  44.             echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value] : '&nbsp;') .'</td>';
  45.       } ?>
  46.       </tr>
  47.       <?php $ii++; } ?>
  48.  
  49.  


output on this code is
HTML Code: [ Select ]
<table border="2" cellspacing="0" cellpadding="0">
      <tr>
        <td>Mazak 650</td><td>DMG1</td><td>6300 #2</td>
      </tr>
            <tr>
        <td>T7040960</td><td>T7040961</td><td>T7040962</td>      </tr>
            <tr>
        <td>T7040963</td><td>&nbsp;</td><td>&nbsp;</td>      </tr>
      </table>
 
  1. <table border="2" cellspacing="0" cellpadding="0">
  2.       <tr>
  3.         <td>Mazak 650</td><td>DMG1</td><td>6300 #2</td>
  4.       </tr>
  5.             <tr>
  6.         <td>T7040960</td><td>T7040961</td><td>T7040962</td>      </tr>
  7.             <tr>
  8.         <td>T7040963</td><td>&nbsp;</td><td>&nbsp;</td>      </tr>
  9.       </table>
  10.  
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

erm hang on captin.
How can i go about pulling more info from the table as tom.
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

serial = 70323432
week = 5
part = x19541
size = 12.5

I dont care about the colors. That part is easy.
demonmaestro wrote:
This is how i want it to look
demonmaestro wrote:
Image
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

use the whole database row instead of $ord['serial'] and on the output declare what you what to output
PHP Code: [ Select ]
        <?
         
        $table      = array();
        $table_keys = array();
        $ii=0;
         
        $m =  "SELECT  * FROM bob";
        $stored_machines = mysql_query($m);
        while ($mch = mysql_fetch_array($stored_machines)) {
            $table_keys[] = $mch['machine']; // Fixed the ;
            $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
            while ($ord = mysql_fetch_array($stored_orders)) {
                 
                $table[$ii][$mch['machine']] = $ord; // Use the whole Database row here
                $ii++; // Added the $ii++
            }
            $ii=0; // Reset the counter
        }
         
// Then build the final output
     
    ?>
    option one
    <table border="2" cellspacing="0" cellpadding="0">
      <tr>
        <td><?php echo implode('</td><td>', $table_keys); ?></td>
      </tr>
      <?php foreach($table as $key => $table_row) { ?>
      <tr>
        <?php foreach($table_keys as $value) {
            echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'<br />'. $table_row[$value]['part'] .'<br />'. $table_row[$value]['size'] : '&nbsp;') .'</td>';
      } ?>
      </tr>
      <?php } ?>
</table>
    option Two
    <table border="2" cellspacing="0" cellpadding="0">
      <tr>
        <td><?php echo implode('</td><td>', $table_keys); ?></td>
      </tr>
      <?php foreach($table as $key => $table_row) { ?>
      <tr>
        <?php foreach($table_keys as $value) {
            echo '<td>';
         if(is_array($table_row[$value])) {
            echo '
                  <table border="1" cellspacing="0" cellpadding="0">
                     <tr>
                        <td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'</td>
                     </tr>
                     <tr>
                        <td>'. $table_row[$value]['part'] .'</td>
                     </tr>
                     <tr>
                        <td>'. $table_row[$value]['size'] : '&nbsp;') .'</td>
                     </tr>
                  </table>';
         }
         echo '</td>';
      } ?>
      </tr>
      <?php } ?>
</table>
 
  1.         <?
  2.          
  3.         $table      = array();
  4.         $table_keys = array();
  5.         $ii=0;
  6.          
  7.         $m =  "SELECT  * FROM bob";
  8.         $stored_machines = mysql_query($m);
  9.         while ($mch = mysql_fetch_array($stored_machines)) {
  10.             $table_keys[] = $mch['machine']; // Fixed the ;
  11.             $stored_orders = mysql_query("SELECT  * FROM tom WHERE status = ('".$mch['machine']."')");      
  12.             while ($ord = mysql_fetch_array($stored_orders)) {
  13.                  
  14.                 $table[$ii][$mch['machine']] = $ord; // Use the whole Database row here
  15.                 $ii++; // Added the $ii++
  16.             }
  17.             $ii=0; // Reset the counter
  18.         }
  19.          
  20. // Then build the final output
  21.      
  22.     ?>
  23.     option one
  24.     <table border="2" cellspacing="0" cellpadding="0">
  25.       <tr>
  26.         <td><?php echo implode('</td><td>', $table_keys); ?></td>
  27.       </tr>
  28.       <?php foreach($table as $key => $table_row) { ?>
  29.       <tr>
  30.         <?php foreach($table_keys as $value) {
  31.             echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'<br />'. $table_row[$value]['part'] .'<br />'. $table_row[$value]['size'] : '&nbsp;') .'</td>';
  32.       } ?>
  33.       </tr>
  34.       <?php } ?>
  35. </table>
  36.     option Two
  37.     <table border="2" cellspacing="0" cellpadding="0">
  38.       <tr>
  39.         <td><?php echo implode('</td><td>', $table_keys); ?></td>
  40.       </tr>
  41.       <?php foreach($table as $key => $table_row) { ?>
  42.       <tr>
  43.         <?php foreach($table_keys as $value) {
  44.             echo '<td>';
  45.          if(is_array($table_row[$value])) {
  46.             echo '
  47.                   <table border="1" cellspacing="0" cellpadding="0">
  48.                      <tr>
  49.                         <td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'</td>
  50.                      </tr>
  51.                      <tr>
  52.                         <td>'. $table_row[$value]['part'] .'</td>
  53.                      </tr>
  54.                      <tr>
  55.                         <td>'. $table_row[$value]['size'] : '&nbsp;') .'</td>
  56.                      </tr>
  57.                   </table>';
  58.          }
  59.          echo '</td>';
  60.       } ?>
  61.       </tr>
  62.       <?php } ?>
  63. </table>
  64.  


my test code
PHP Code: [ Select ]
    <?php
   $db1 = array(
      array('machine' => 'Mazak 650'),
      array('machine' => 'DMG1'),
      array('machine' => '6300 #2')
      );
   
   $db2 = array(
      "Mazak 650" => array(array('serial' => 'T7040960', 'week' => '5', 'part' => 'x19541', 'size' => '12.5'), array('serial' => 'T7040963', 'week' => '6', 'part' => 'x19552', 'size' => '13')),
      "DMG1" => array(array('serial' => 'T7040961', 'week' => '7', 'part' => 'x19563', 'size' => '13.5')),
      "6300 #2" => array(array('serial' => 'T7040962', 'week' => '8', 'part' => 'x19574', 'size' => '14'))   
      );
     
    $table      = array();
    $table_keys = array();
    $ii=0;
     
 
    foreach($db1 as $mch) {
        $table_keys[] = $mch['machine'];
//var_dump($db2[$mch['machine']]);
        foreach ($db2[$mch['machine']] as $ord) {
             
            $table[$ii][$mch['machine']] = $ord;
     $ii++;
        }
      $ii=0;
    }
     
    // Then build the final output
     
    ?>
    option one
    <table border="2" cellspacing="0" cellpadding="0">
      <tr>
        <td><?php echo implode('</td><td>', $table_keys); ?></td>
      </tr>
      <?php foreach($table as $key => $table_row) { ?>
      <tr>
        <?php foreach($table_keys as $value) {
            echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'<br />'. $table_row[$value]['part'] .'<br />'. $table_row[$value]['size'] : '&nbsp;') .'</td>';
      } ?>
      </tr>
      <?php } ?>
</table>
    option Two
    <table border="2" cellspacing="0" cellpadding="0">
      <tr>
        <td><?php echo implode('</td><td>', $table_keys); ?></td>
      </tr>
      <?php foreach($table as $key => $table_row) { ?>
      <tr>
        <?php foreach($table_keys as $value) {
            echo '<td>';
         if(is_array($table_row[$value])) {
            echo '
                  <table border="1" cellspacing="0" cellpadding="0">
                     <tr>
                        <td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'</td>
                     </tr>
                     <tr>
                        <td>'. $table_row[$value]['part'] .'</td>
                     </tr>
                     <tr>
                        <td>'. $table_row[$value]['size'] : '&nbsp;') .'</td>
                     </tr>
                  </table>';
         }
         echo '</td>';
      } ?>
      </tr>
      <?php } ?>
</table>
 
  1.     <?php
  2.    $db1 = array(
  3.       array('machine' => 'Mazak 650'),
  4.       array('machine' => 'DMG1'),
  5.       array('machine' => '6300 #2')
  6.       );
  7.    
  8.    $db2 = array(
  9.       "Mazak 650" => array(array('serial' => 'T7040960', 'week' => '5', 'part' => 'x19541', 'size' => '12.5'), array('serial' => 'T7040963', 'week' => '6', 'part' => 'x19552', 'size' => '13')),
  10.       "DMG1" => array(array('serial' => 'T7040961', 'week' => '7', 'part' => 'x19563', 'size' => '13.5')),
  11.       "6300 #2" => array(array('serial' => 'T7040962', 'week' => '8', 'part' => 'x19574', 'size' => '14'))   
  12.       );
  13.      
  14.     $table      = array();
  15.     $table_keys = array();
  16.     $ii=0;
  17.      
  18.  
  19.     foreach($db1 as $mch) {
  20.         $table_keys[] = $mch['machine'];
  21. //var_dump($db2[$mch['machine']]);
  22.         foreach ($db2[$mch['machine']] as $ord) {
  23.              
  24.             $table[$ii][$mch['machine']] = $ord;
  25.      $ii++;
  26.         }
  27.       $ii=0;
  28.     }
  29.      
  30.     // Then build the final output
  31.      
  32.     ?>
  33.     option one
  34.     <table border="2" cellspacing="0" cellpadding="0">
  35.       <tr>
  36.         <td><?php echo implode('</td><td>', $table_keys); ?></td>
  37.       </tr>
  38.       <?php foreach($table as $key => $table_row) { ?>
  39.       <tr>
  40.         <?php foreach($table_keys as $value) {
  41.             echo '<td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'<br />'. $table_row[$value]['part'] .'<br />'. $table_row[$value]['size'] : '&nbsp;') .'</td>';
  42.       } ?>
  43.       </tr>
  44.       <?php } ?>
  45. </table>
  46.     option Two
  47.     <table border="2" cellspacing="0" cellpadding="0">
  48.       <tr>
  49.         <td><?php echo implode('</td><td>', $table_keys); ?></td>
  50.       </tr>
  51.       <?php foreach($table as $key => $table_row) { ?>
  52.       <tr>
  53.         <?php foreach($table_keys as $value) {
  54.             echo '<td>';
  55.          if(is_array($table_row[$value])) {
  56.             echo '
  57.                   <table border="1" cellspacing="0" cellpadding="0">
  58.                      <tr>
  59.                         <td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'</td>
  60.                      </tr>
  61.                      <tr>
  62.                         <td>'. $table_row[$value]['part'] .'</td>
  63.                      </tr>
  64.                      <tr>
  65.                         <td>'. $table_row[$value]['size'] : '&nbsp;') .'</td>
  66.                      </tr>
  67.                   </table>';
  68.          }
  69.          echo '</td>';
  70.       } ?>
  71.       </tr>
  72.       <?php } ?>
  73. </table>
  74.  


Output
HTML Code: [ Select ]
        option one
    <table border="2" cellspacing="0" cellpadding="0">
      <tr>
        <td>Mazak 650</td><td>DMG1</td><td>6300 #2</td>
      </tr>
            <tr>
        <td>T7040960&nbsp;5<br />x19541<br />12.5</td><td>T7040961&nbsp;7<br />x19563<br />13.5</td><td>T7040962&nbsp;8<br />x19574<br />14</td>      </tr>
            <tr>
        <td>T7040963&nbsp;6<br />x19552<br />13</td><td>&nbsp;</td><td>&nbsp;</td>      </tr>
      </table>
    option Two
    <table border="2" cellspacing="0" cellpadding="0">
      <tr>
        <td>Mazak 650</td><td>DMG1</td><td>6300 #2</td>
      </tr>
            <tr>
        <td>
                  <table border="1" cellspacing="0" cellpadding="0">
                     <tr>
                        <td>T7040960&nbsp;5</td>
                     </tr>
                     <tr>
                        <td>x19541</td>
                     </tr>
                     <tr>
                        <td>12.5</td>
                     </tr>
                  </table></td><td>
                  <table border="1" cellspacing="0" cellpadding="0">
                     <tr>
                        <td>T7040961&nbsp;7</td>
                     </tr>
                     <tr>
                        <td>x19563</td>
                     </tr>
                     <tr>
                        <td>13.5</td>
                     </tr>
                  </table></td><td>
                  <table border="1" cellspacing="0" cellpadding="0">
                     <tr>
                        <td>T7040962&nbsp;8</td>
                     </tr>
                     <tr>
                        <td>x19574</td>
                     </tr>
                     <tr>
                        <td>14</td>
                     </tr>
                  </table></td>      </tr>
            <tr>
        <td>
                  <table border="1" cellspacing="0" cellpadding="0">
                     <tr>
                        <td>T7040963&nbsp;6</td>
                     </tr>
                     <tr>
                        <td>x19552</td>
                     </tr>
                     <tr>
                        <td>13</td>
                     </tr>
                  </table></td><td></td><td></td>      </tr>
      </table>
 
  1.         option one
  2.     <table border="2" cellspacing="0" cellpadding="0">
  3.       <tr>
  4.         <td>Mazak 650</td><td>DMG1</td><td>6300 #2</td>
  5.       </tr>
  6.             <tr>
  7.         <td>T7040960&nbsp;5<br />x19541<br />12.5</td><td>T7040961&nbsp;7<br />x19563<br />13.5</td><td>T7040962&nbsp;8<br />x19574<br />14</td>      </tr>
  8.             <tr>
  9.         <td>T7040963&nbsp;6<br />x19552<br />13</td><td>&nbsp;</td><td>&nbsp;</td>      </tr>
  10.       </table>
  11.     option Two
  12.     <table border="2" cellspacing="0" cellpadding="0">
  13.       <tr>
  14.         <td>Mazak 650</td><td>DMG1</td><td>6300 #2</td>
  15.       </tr>
  16.             <tr>
  17.         <td>
  18.                   <table border="1" cellspacing="0" cellpadding="0">
  19.                      <tr>
  20.                         <td>T7040960&nbsp;5</td>
  21.                      </tr>
  22.                      <tr>
  23.                         <td>x19541</td>
  24.                      </tr>
  25.                      <tr>
  26.                         <td>12.5</td>
  27.                      </tr>
  28.                   </table></td><td>
  29.                   <table border="1" cellspacing="0" cellpadding="0">
  30.                      <tr>
  31.                         <td>T7040961&nbsp;7</td>
  32.                      </tr>
  33.                      <tr>
  34.                         <td>x19563</td>
  35.                      </tr>
  36.                      <tr>
  37.                         <td>13.5</td>
  38.                      </tr>
  39.                   </table></td><td>
  40.                   <table border="1" cellspacing="0" cellpadding="0">
  41.                      <tr>
  42.                         <td>T7040962&nbsp;8</td>
  43.                      </tr>
  44.                      <tr>
  45.                         <td>x19574</td>
  46.                      </tr>
  47.                      <tr>
  48.                         <td>14</td>
  49.                      </tr>
  50.                   </table></td>      </tr>
  51.             <tr>
  52.         <td>
  53.                   <table border="1" cellspacing="0" cellpadding="0">
  54.                      <tr>
  55.                         <td>T7040963&nbsp;6</td>
  56.                      </tr>
  57.                      <tr>
  58.                         <td>x19552</td>
  59.                      </tr>
  60.                      <tr>
  61.                         <td>13</td>
  62.                      </tr>
  63.                   </table></td><td></td><td></td>      </tr>
  64.       </table>
  65.  
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

That was it. You are the man. I also got it currently where the whole thing scrolls but i am unable to figure out how to make each machine need to scroll if too long. I need it both. So if get too many machines to fit on the page only it will scroll side to side but if a particular machine has more orders than the other only that machine will have a scroll for those orders.

PHP Code: [ Select ]
<div style="overflow:auto; height:200px;">
 <table border="0" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
      <tr>
        <td><?php echo implode('</td><td>', $table_keys); ?></td>
      </tr>
      <?php foreach($table as $key => $table_row) { ?>
      <tr>
        <?php foreach($table_keys as $value) {
            echo '<td>';
         if(is_array($table_row[$value])) {
            echo '
                 <table border="1" cellspacing="0" cellpadding="0">
                    <tr>
                       <td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'</td>
                    </tr>
                    <tr>
                       <td>'. $table_row[$value]['part'] .'</td>
                    </tr>
                    <tr>
                       <td>'. $table_row[$value]['size'] : '&nbsp;') .'</td>
                    </tr>
                 </table>';
         }
         echo '</td>';
      } ?>
      </tr>
      <?php } ?>
</table>
      </div>
 
  1. <div style="overflow:auto; height:200px;">
  2.  <table border="0" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
  3.       <tr>
  4.         <td><?php echo implode('</td><td>', $table_keys); ?></td>
  5.       </tr>
  6.       <?php foreach($table as $key => $table_row) { ?>
  7.       <tr>
  8.         <?php foreach($table_keys as $value) {
  9.             echo '<td>';
  10.          if(is_array($table_row[$value])) {
  11.             echo '
  12.                  <table border="1" cellspacing="0" cellpadding="0">
  13.                     <tr>
  14.                        <td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'</td>
  15.                     </tr>
  16.                     <tr>
  17.                        <td>'. $table_row[$value]['part'] .'</td>
  18.                     </tr>
  19.                     <tr>
  20.                        <td>'. $table_row[$value]['size'] : '&nbsp;') .'</td>
  21.                     </tr>
  22.                  </table>';
  23.          }
  24.          echo '</td>';
  25.       } ?>
  26.       </tr>
  27.       <?php } ?>
  28. </table>
  29.       </div>
  30.  
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

How were you thinking on displaying it?

Option 1 on the div tag you could set the width and it should result in something like
Attachments:
dis1.jpg


or

Option 2 would require a different table setup
Attachments:
dis2.jpg
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

option 2 is what i am looking for.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 475

Post 3+ Months Ago

this might work for you

EDIT:: NOPE lol

RE-EDIT:: This does however
PHP Code: [ Select ]
    <div style="overflow:auto; width:800px;">
     <table border="0" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
          <tr>
            <td><?php echo implode('</td><td>', $table_keys); ?></td>
          </tr>
          <tr>
          <?php foreach($table_keys as $value) {
              echo '<td><div style="overflow:auto; height:200px;">';
              foreach($table as $key => $table_row) {
           
               
             if(is_array($table_row[$value])) {
                echo '
                    <table border="1" cellspacing="0" cellpadding="0">
                       <tr>
                          <td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'</td>
                       </tr>
                       <tr>
                          <td>'. $table_row[$value]['part'] .'</td>
                       </tr>
                       <tr>
                          <td>'. $table_row[$value]['size'] : '&nbsp;') .'</td>
                       </tr>
                    </table>';
             }
             
          } echo '</div></td>';?>
         
          <?php } ?>
       </tr>
    </table>
          </div>
 
  1.     <div style="overflow:auto; width:800px;">
  2.      <table border="0" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
  3.           <tr>
  4.             <td><?php echo implode('</td><td>', $table_keys); ?></td>
  5.           </tr>
  6.           <tr>
  7.           <?php foreach($table_keys as $value) {
  8.               echo '<td><div style="overflow:auto; height:200px;">';
  9.               foreach($table as $key => $table_row) {
  10.            
  11.                
  12.              if(is_array($table_row[$value])) {
  13.                 echo '
  14.                     <table border="1" cellspacing="0" cellpadding="0">
  15.                        <tr>
  16.                           <td>'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'&nbsp;'. $table_row[$value]['week'] .'</td>
  17.                        </tr>
  18.                        <tr>
  19.                           <td>'. $table_row[$value]['part'] .'</td>
  20.                        </tr>
  21.                        <tr>
  22.                           <td>'. $table_row[$value]['size'] : '&nbsp;') .'</td>
  23.                        </tr>
  24.                     </table>';
  25.              }
  26.              
  27.           } echo '</div></td>';?>
  28.          
  29.           <?php } ?>
  30.        </tr>
  31.     </table>
  32.           </div>
  33.  
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

That works I am missing something though and cannot figure it out.
I am trying to make it where there is an area below each machine number that will say "In Machine" and will have what ever bit that is in the machine. while having whats lined up for the machines under "Machine Que"

I got the "Machine Que" where i want it but the issue is getting the in machine part to show up correctly.
there is a row under bits that will say yes/no if its in the machine or not.

Also trying to get the bits that are "hot" and Ultra Hot" to go on top of all orders under that machine.
So like its saying ultra hot is above hot. but both need to be on top of the other orders.
Hot and UltraHot has there own row in the table (0/1)

Like this on layout
Image

PHP Code: [ Select ]
       
        $table      = array();
        $table_keys = array();
        $ii=0;
         
        $m =  "SELECT  * FROM BitMachine";
        $stored_machines = mysql_query($m);
        while ($mch = mysql_fetch_array($stored_machines)) {
            $table_keys[] = $mch['machine']; // Fixed the ;
            $stored_orders = mysql_query("SELECT  * FROM bits WHERE status = ('".$mch['machine']."')");      
            while ($ord = mysql_fetch_array($stored_orders)) {
                 
                $table[$ii][$mch['machine']] = $ord; // Use the whole Database row here
                $ii++; // Added the $ii++
            }
            $ii=0; // Reset the counter
        }
         
// Then build the final output
     
    ?>
<style>
a:link {color:#000000; text-decoration:none;}    /* unvisited link */
a:visited {color:#000000; text-decoration:none;} /* visited link */
a:hover {color:#000000; text-decoration:none;}   /* mouse over link */
a:active {color:#000000; text-decoration:none;}  /* selected link */
</style>    
   
    <div style="overflow:auto; width:100%; height:100%">
     <table border="1" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center"><?php echo implode('</td><td>', $table_keys); ?></td>
          </tr>
          <tr>
          <?php foreach($table_keys as $value) {
              echo '<td align="center">Machine Que<div style="overflow:auto; height:200px; width:110px;">';
              foreach($table as $key => $table_row) {
             if(is_array($table_row[$value])) {
                  if($table_row[$value]['type']=='STEEL'){ echo '<div style="background-color:#FF9999;">';}
          else if($table_row[$value]['type']=='SLIM'){ echo '<div style="background-color:#9999FF;">';}
          else if($table_row[$value]['type']=='KYMERA'){ echo '<div style="background-color:#FF2626;">';}
          else if($table_row[$value]['type']=='HYBRID'){ echo '<div style="background-color:#FF2626;">';}
          else if($table_row[$value]['type']=='EZC'){ echo '<div style="background-color:#FFFF26;">';}
          else if($table_row[$value]['type']=='RWD'){ echo '<div style="background-color:#FF9326;">';}
          else if($table_row[$value]['type']=='EZR'){ echo '<div style="background-color:#FFFF26;">';}
          else if($table_row[$value]['type']=='EZB'){ echo '<div style="background-color:#FFFF26;">';}
            echo '<a href="operator.php?id='.$table_row[$value]['serial'].'"><div style="border:solid; border-color:#000000;">
                   <table border="0" cellspacing="0" cellpadding="0" width="100%">';
                  if($table_row[$value]['ultrahot']=='1'){echo'<tr><td><div style="background-color:#FF0000;">*Ultra Hot*</div></td></tr>';}
                  if($table_row[$value]['hot']=='1'){echo'<tr><td><div style="background-color:#FF0000;">*HOT*</div></td></tr>';}
                  echo '<tr>
                         <td><a href="operator.php?id='.$table_row[$value]['serial'].'">'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'</a>&nbsp;<a href="operator.php?id='.$table_row[$value]['serial'].'">'. $table_row[$value]['load wk'] .'</a></td>
                      </tr>
                      <tr>
                         <td><a href="operator.php?id='.$table_row[$value]['serial'].'">'. $table_row[$value]['crown'] .'</a></td>
                      </tr>
                      <tr>
                         <td><a href="operator.php?id='.$table_row[$value]['serial'].'">'. $table_row[$value]['size'] : '&nbsp;') .'</a></td>
                      </tr>
                   </table></div></a>';
             }
             
          } echo '</div></td>';?>
         
          <?php } ?>
       </tr>
    </table>
          </div>
 
  1.        
  2.         $table      = array();
  3.         $table_keys = array();
  4.         $ii=0;
  5.          
  6.         $m =  "SELECT  * FROM BitMachine";
  7.         $stored_machines = mysql_query($m);
  8.         while ($mch = mysql_fetch_array($stored_machines)) {
  9.             $table_keys[] = $mch['machine']; // Fixed the ;
  10.             $stored_orders = mysql_query("SELECT  * FROM bits WHERE status = ('".$mch['machine']."')");      
  11.             while ($ord = mysql_fetch_array($stored_orders)) {
  12.                  
  13.                 $table[$ii][$mch['machine']] = $ord; // Use the whole Database row here
  14.                 $ii++; // Added the $ii++
  15.             }
  16.             $ii=0; // Reset the counter
  17.         }
  18.          
  19. // Then build the final output
  20.      
  21.     ?>
  22. <style>
  23. a:link {color:#000000; text-decoration:none;}    /* unvisited link */
  24. a:visited {color:#000000; text-decoration:none;} /* visited link */
  25. a:hover {color:#000000; text-decoration:none;}   /* mouse over link */
  26. a:active {color:#000000; text-decoration:none;}  /* selected link */
  27. </style>    
  28.    
  29.     <div style="overflow:auto; width:100%; height:100%">
  30.      <table border="1" bordercolor="#F1090D" cellspacing="0" cellpadding="0">
  31.           <tr>
  32.             <td align="center"><?php echo implode('</td><td>', $table_keys); ?></td>
  33.           </tr>
  34.           <tr>
  35.           <?php foreach($table_keys as $value) {
  36.               echo '<td align="center">Machine Que<div style="overflow:auto; height:200px; width:110px;">';
  37.               foreach($table as $key => $table_row) {
  38.              if(is_array($table_row[$value])) {
  39.                   if($table_row[$value]['type']=='STEEL'){ echo '<div style="background-color:#FF9999;">';}
  40.           else if($table_row[$value]['type']=='SLIM'){ echo '<div style="background-color:#9999FF;">';}
  41.           else if($table_row[$value]['type']=='KYMERA'){ echo '<div style="background-color:#FF2626;">';}
  42.           else if($table_row[$value]['type']=='HYBRID'){ echo '<div style="background-color:#FF2626;">';}
  43.           else if($table_row[$value]['type']=='EZC'){ echo '<div style="background-color:#FFFF26;">';}
  44.           else if($table_row[$value]['type']=='RWD'){ echo '<div style="background-color:#FF9326;">';}
  45.           else if($table_row[$value]['type']=='EZR'){ echo '<div style="background-color:#FFFF26;">';}
  46.           else if($table_row[$value]['type']=='EZB'){ echo '<div style="background-color:#FFFF26;">';}
  47.             echo '<a href="operator.php?id='.$table_row[$value]['serial'].'"><div style="border:solid; border-color:#000000;">
  48.                    <table border="0" cellspacing="0" cellpadding="0" width="100%">';
  49.                   if($table_row[$value]['ultrahot']=='1'){echo'<tr><td><div style="background-color:#FF0000;">*Ultra Hot*</div></td></tr>';}
  50.                   if($table_row[$value]['hot']=='1'){echo'<tr><td><div style="background-color:#FF0000;">*HOT*</div></td></tr>';}
  51.                   echo '<tr>
  52.                          <td><a href="operator.php?id='.$table_row[$value]['serial'].'">'. (!empty($table_row[$value]) ? $table_row[$value]['serial'] .'</a>&nbsp;<a href="operator.php?id='.$table_row[$value]['serial'].'">'. $table_row[$value]['load wk'] .'</a></td>
  53.                       </tr>
  54.                       <tr>
  55.                          <td><a href="operator.php?id='.$table_row[$value]['serial'].'">'. $table_row[$value]['crown'] .'</a></td>
  56.                       </tr>
  57.                       <tr>
  58.                          <td><a href="operator.php?id='.$table_row[$value]['serial'].'">'. $table_row[$value]['size'] : '&nbsp;') .'</a></td>
  59.                       </tr>
  60.                    </table></div></a>';
  61.              }
  62.              
  63.           } echo '</div></td>';?>
  64.          
  65.           <?php } ?>
  66.        </tr>
  67.     </table>
  68.           </div>
  69.  



Side note: You are probably like :hmm: "Look at this guy." If you give me your PayPal address or BTC address I will give a "Thank you for the help donation". :mrgreen:
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Hi Josh,

I am looking at the PHP code you just posted, and there is one thing I see that I want to mention before addressing your issue. That is the fact that you are doing a MySQL query in a loop. When I write scripts I always, always avoid ever putting queries into loops as it can add tons of extra queries to the database when probably not needed. A better way to go would be on your initial query to do a join on the bits table where 'status' is equal to 'machine'. That way all you need is that one query, and then when you loop through everything you will still have what you needed, but one MySQL query to do all of this. The way it is right now there could be N number of queries, depending on the number of results in bitmachine. So if you had 1000 things in bitmachine, then you would have 1000 additional MySQL queries. Extremely inefficient, and could slow things down.

So whenever you write a script, if you see a MySQL query inside of a loop, immediately a red flag should go off that things could probably be done differently (probably just with a JOIN).

As far as to your actual question, looks like in your code you don't have any of the "In Machine" stuff yet. What I would do way above where you even start your HTML is to create one array for your Machine Que if the item should fall in there, and then another array for your "In Machine" for if your item should fall in that instead. Then down in your HTML you could just loop through how you are doing it for the Machine Que for the In Machine with the other array in another table row right before it.
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

but the info for the machine que and in machine is all in the same table.
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

What i am saying is this

Ultra hot orders need to be on the very top of the list
Hot orders need to be at the top of the list
then you got regular orders that will show up in the list in order as they were put in
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

It is okay if they are in the same table, as long as you can differentiate them in your loop where you build your $table array, you could then add another array to separate them out, and only add to the appropriate array in the loop. Then below in your HTML you can go through each one for your separate areas.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 104 posts
  • Users browsing this forum: No registered users and 66 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.