abs0lut Posted August 30, 2008 Share Posted August 30, 2008 <?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? Quote Link to comment https://forums.phpfreaks.com/topic/122043-solved-selecting-one-warranty/ Share on other sites More sharing options...
.josh Posted August 31, 2008 Share Posted August 31, 2008 perhaps a SELECT DISTINCT could be of use? Quote Link to comment https://forums.phpfreaks.com/topic/122043-solved-selecting-one-warranty/#findComment-630052 Share on other sites More sharing options...
abs0lut Posted August 31, 2008 Author Share Posted August 31, 2008 perhaps a SELECT DISTINCT could be of use? did you mean I will add DISTINCT before warranty? $result = mysql_query("SELECT cid, iqid, cost, usersid, DISTINCT warranty, othmsg FROM ctable WHERE postid=$post ORDER BY warranty"); Quote Link to comment https://forums.phpfreaks.com/topic/122043-solved-selecting-one-warranty/#findComment-630072 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.