Jump to content

border between different warranty


abs0lut

Recommended Posts

<?php 
include 'conn.php';
$post = $_GET['post'];
?>   
<form method="post" name="formk" action="<?= $_SERVER['PHP_SELF']. '?' . $_SERVER['QUERY_STRING'] ?>">
<?php
$result = mysql_query("SELECT cid, iqid, cost, usersid, warranty, othmsg FROM ctable WHERE postid=$post ORDER BY warranty");
while ($row = mysql_fetch_array($result))
{
  $arr[$row['iqid']][$row['usersid']] = $row['cost'];
  $arr2[$row['iqid']][$row['usersid']] = $row['cid'];
  $arr3[$row['iqid']][$row['usersid']] = $row['warranty'];
  $uid[] = $row['usersid'];
}
$uid = array_unique($uid);
$qid = array_keys($arr);

echo '<table><tr><td></td>';
foreach($uid as $userid) echo "<td>$userid</td>";
echo '</tr>';
foreach($qid as $iqid)
{
  echo "<tr><td>$iqid</td>";
  foreach($uid as $userid)
  {
    if (isset($arr[$iqid][$userid]))
    {       
        echo "<td width='10%'>".$arr[$iqid][$userid]."<input type='radio'  name='iqid[$iqid]' value='{$arr2[$iqid][$userid]}'></td>";
    }
    else echo "<td></td>";    
  }
  echo "</tr>";
}
echo '<tr><td>Warranty:</td>';
foreach($uid as $userid)
  {
echo '<td width=10%>';
  echo $arr3[$iqid][$userid];
  echo '</td>';
  }
echo '</tr>';
echo '</table>';
echo '<input type="submit" name="checkb" />';
echo'</form>';    

}
?> 

I used order by to sort warranty, so that same warranty will be grouped together

I need to put a border between different warranty, could you please help me?

 

for example

              userid1        userid2    |    userid3

iqid          cost            cost        |    cost 

iqid2        cost            cost        |    cost

iqid3        cost            cost        |    cost

              1year          1year      |    2years

 

Link to comment
https://forums.phpfreaks.com/topic/122318-border-between-different-warranty/
Share on other sites

add an AND `warranty`='1year' to your clause and get rid of the order by and do more than one query.

 

OR

 

use an if statement to sort the warranties, put each type in a separate array and then print these arrays off.

 

Sorry if these solutions are confusing in wording, I'm too tired right now to write out the code. If you still need help, when i get the time i'll sample the code.

Archived

This topic is now archived and is closed to further replies.

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