Page 1 of 1

php data fetching problem... pls help

Posted: Mon May 25, 2009 12:25 am
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
}
 

Re: php data fetching problem... pls help

Posted: Mon May 25, 2009 12:50 am
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