Jump to content

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

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.