prolife Posted September 6, 2013 Share Posted September 6, 2013 hello people my code is displaying the last result instead of the exact result i requested for. Here is my code <table width="800" height="40" align="center"> <form action="admin-edit-room.php" method="post"> <?php $object->database(); $object->set_sqlstr(htmlspecialchars( "SELECT `cat`.*,`rooms`.* FROM `cat`,`rooms` WHERE `cat`.`id` = `rooms`.`catid` ") ); // $object->set_sqlstr("SELECT * FROM `rooms` " ); $object->querydata(); $num = $object->no_rows; if($num=0){echo "Your inbox is empty";} $i=1; while($object->data[0]!= ""){ $class = (($i%2)==0) ? 'td_colour1' : 'td_colour2'; echo'<tr class="'.$class.'">'; echo'<td width="50" height="10" class="admin-details-form" align="left">'. $object->data['room-name'] .'</td>'; echo'<td width="200" height="10" class="admin-details-form" align="left">'. $object->data['room-descript'] .'</td>'; echo'<td width="200" height="10" class="admin-details-form" align="left"><input type="hidden" name="roomid" value="'.$object->data['roomid'].'" />'.$object->data['catid'].'</td>'; echo'<td width="200" height="10" class="admin-details-form" align="left"><input type="hidden" name="catid" value="'.$object->data['catid'].'" /></td>'; echo'<td width="10" height="10" class="admin-details-form" align="center"><input type="submit" name="edit" value="Edit" /></td>'; echo'</tr>'; $object->fetchdata(); $i++; } ?> </form> </table> Now the thing is i placed "roomid" inside an hidden field and submited it to the next transaction page as you can see but instead of it submiting the specific id it keeps submiting the last roomid, please what could be the problem? thanks Quote Link to comment https://forums.phpfreaks.com/topic/281933-my-sql-query-is-giving-me-a-wrong-result/ Share on other sites More sharing options...
requinix Posted September 6, 2013 Share Posted September 6, 2013 $object->set_sqlstr(htmlspecialchars( "SELECT `cat`.*,`rooms`.* FROM `cat`,`rooms` WHERE `cat`.`id` = `rooms`.`catid` ") );There's no HTML in there. Don't use htmlspecialchars(). SELECT `cat`.*,`rooms`.* Don't SELECT * when you only want a couple columns. Specifically name the ones you want. $object->no_rowsIs it really called "no_rows"? Not, like, "num_rows"? if($num=0){Not enough =s. $object->data['room-name']Is it really named with a hyphen? If so, that better be because the $object thing added it and not because your column is actually named "room-name". it keeps submiting the last roomidAre you sure that is what's happening? Have you verified that the HTML you've outputted has the wrong ID there? Quote Link to comment https://forums.phpfreaks.com/topic/281933-my-sql-query-is-giving-me-a-wrong-result/#findComment-1448496 Share on other sites More sharing options...
prolife Posted September 6, 2013 Author Share Posted September 6, 2013 its been sorted out already, i have been able to get it fixed. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/281933-my-sql-query-is-giving-me-a-wrong-result/#findComment-1448525 Share on other sites More sharing options...
Solution prolife Posted September 6, 2013 Author Solution Share Posted September 6, 2013 @ requinix thanks for your responce Quote Link to comment https://forums.phpfreaks.com/topic/281933-my-sql-query-is-giving-me-a-wrong-result/#findComment-1448526 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.