Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/296731-how-to-handle-certain-mysql-data/
Share on other sites

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.

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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