adrianle Posted June 9, 2015 Share Posted June 9, 2015 So I'm requesting a set of records from the DB via mysqli... and I get two rows returned, each with a particular committee ID. I have PHP on my page saying essentially: <?php if($TableName->getColumnVal("CommitteeID") == 1 ) { ?> SHow some data here <?php } ?> In this case, the records I get back include committee IDs 31, and 1. Because the row where the ID is 31 occurs in the table BEFORE the row where ID is 1, then the statement fails! What do I need to do so that this statement will be honored, regardless of how many rows are retrieved, or where in the order of the rows this statement is true?? Thanks all... Quote Link to comment https://forums.phpfreaks.com/topic/296731-how-to-handle-certain-mysql-data/ Share on other sites More sharing options...
ginerjm Posted June 9, 2015 Share Posted June 9, 2015 Because the 31 row occurs first, the statement fails? Is that what you really mean? If committeeid is 31 and 1 in your two rows, why would the 31 even be selected? Is your getcolumnval method flawed in some way? PS - you have way too many php tags in this snippet. You don't need to turn it on and turn it off all the time. Quote Link to comment https://forums.phpfreaks.com/topic/296731-how-to-handle-certain-mysql-data/#findComment-1513573 Share on other sites More sharing options...
Psycho Posted June 9, 2015 Share Posted June 9, 2015 To add to ginerjm's response: What is the purpose of selecting the record with an ID of 31 if you don't want to use it? If you don't need that value then don't select it, by adding criteria to your WHERE clause. WHERE id = 1 Then you would only have the record(s) for ID 1 Or if you do need those records and only want to ensure the ID of 1 is first, then order the records so it will be first ORDER BY id = 1 Quote Link to comment https://forums.phpfreaks.com/topic/296731-how-to-handle-certain-mysql-data/#findComment-1513576 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.