Jump to content

array! fetch!complication!


asmith

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/80158-array-fetchcomplication/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

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