asmith Posted December 4, 2007 Share Posted December 4, 2007 i have use mysql_fetch_array , to get some varilable fields in mysql . some time 1 ,sometime 10 fileds. what i need to know is wether this fileds are recorded or they are not (NULL in mysql filed). if they were all filed, so i show form a . if only one of them is not filed. it show form b. how can i achive this ? i have an array from fetch comtaining the values of this fileds, if all of the fileds are empty, and mysql shows them NULL , (i havn't used NOT NULL when creating table) i can use if (empty($fetcharray)) ... and it works, but if one of them have something in it , i can't use empty either ! thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/80158-array-fetchcomplication/ Share on other sites More sharing options...
Barand Posted December 4, 2007 Share Posted December 4, 2007 you could do something like this <?php $row = mysql_fetch_assoc($result); // NOTE not fetch array as it gets values twice $count = 0; foreach ($row as $value) { if (empty($value)) $count++; } if ($count == 0) // form a else // form b ?> Quote Link to comment https://forums.phpfreaks.com/topic/80158-array-fetchcomplication/#findComment-406295 Share on other sites More sharing options...
bibby Posted December 5, 2007 Share Posted December 5, 2007 if $result is a valid resource, you can also use mysql_num_rows($result) to get the count (looping takes time and memory, and the resource technically already knows). Quote Link to comment https://forums.phpfreaks.com/topic/80158-array-fetchcomplication/#findComment-406597 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.