0

I have SQL query.

$stylesIndex = mysql_fetch_array($stylesQuery)

is there any php function that check if $stylesIndex contain specific value?

i tried this and it's not working -

if (in_array ("3", $stylesIndex))
Roi
  • 49
  • 8
  • `if (!empty($stylesIndex))`? – Qirel Jul 16 '17 at 17:20
  • @Qirel - i wish to check if the query results contain the value "3" (or any other value...) – Roi Jul 16 '17 at 17:21
  • FYI, [you shouldn't use `mysql_*` functions in new code](http://stackoverflow.com/questions/12859942/). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [red box](http://php.net/manual/en/function.mysql-connect.php)? Learn about [*prepared statements*](https://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which one is best for you. – John Conde Jul 16 '17 at 17:22
  • @Roi If you use `empty()` there are values. If you want to check if there's a *numeric* value, you'll need to specify a column, something like `if (is_numeric($stylesIndex[0]))`. You haven't clearly described what you're after, because "3 or any other value" could be almost anything. Then just checking if its empty or not, should suffice. If it doesn't, you should explain your issue better - in a way that its clear what you mean. – Qirel Jul 16 '17 at 17:24
  • @Qirel, OK so i will correct myself - i wish to check if the results contain specific value... – Roi Jul 16 '17 at 17:26
  • @JohnConde - thank you...! – Roi Jul 16 '17 at 17:26

1 Answers1

0
$stylesIndex = ->fetch_array()

if(empty($stylesIndex('any_column_in_your_table') ){

    #nothing is in your database.....
}

i think this will help you...

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149