Jump to content

[SOLVED] selecting one 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]}'>Warranty:".$arr3[$iqid][$userid]."months</td>";
    }
    else echo "<td></td>";    
  }
  echo "</tr>";
}
echo '</table>';
echo '<input type="submit" name="checkb" />';
echo'</form>';    

}
?> 

I need to select one warranty only in every userid since it is the same.

the warranty of iqid1 posted by userid1 is the same as the warranty of iqid2 posted by userid1

the warranty of iqid2 posted by userid1 is the same as the warranty of iqid3 posted by userid1

 

the warranty of iqid1 posted by userid2 is the same as the warranty of iqid2 posted by userid2

and so on..

 

              userid1        userid2          userid3

iqid1        cost            cost              cost 

iqid2        cost            cost              cost

iqid3        cost            cost              cost

              warranty      warranty        warranty

 

could you please help me?

Link to comment
https://forums.phpfreaks.com/topic/122043-solved-selecting-one-warranty/
Share on other sites

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.