php data fetching problem... pls help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
harry786
Forum Newbie
Posts: 1
Joined: Mon May 25, 2009 12:20 am

php data fetching problem... pls help

Post by harry786 »

here in this code m trying to fetch values from database and use those in javascript function..
but here i've created an array $name but not getting any values in $name..i guess it is a data fetchin problem... please help me...
Thank you

Code: Select all

 
function valid_form()
{
    alert("hello");
    <?  
        $sql_dyn="SELECT V_attribute_name,V_element FROM D_reg_table ORDER BY I_id";
        $result_dyn=mysql_query($sql_dyn) or die('ERROR');
        $name=array();  
        
            while($row1_dyn=mysql_fetch_array($result_dyn))
            {    
                $name[]=$rowl_dyn['V_attribute_name'];
            
            }
    ?>
    <? global $name; 
    
    foreach($name as $val){?>
     if (document.getElementById('<?=$val;?>').value=="")
    {
        alert("Field cannot be left blank.");
        return false;
    }
    
    <? }?>
    return false
}
 
Last edited by Benjamin on Tue May 26, 2009 10:32 am, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: php data fetching problem... pls help

Post by mikemike »

What do you get then? If you get 'ERROR' try putting 'mysql_error()' inside your 'or die()' statement of your mysql_query to try and debug your query.

Mike
Post Reply