Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    possible to use functions with: mysql_query()?

    PHP Code:
    <?PHP
        
    include 'dbconnect-include.php';

        
    $TableName maxforcepc;

        
    $link mysql_connect ($Host$User$Password);  
        
    mysql_select_db($DBName$link);
        
        
    $id_query "SELECT ID FROM products";
        
    $list_query "SELECT $col FROM $table";
        
        
    $id_result mysql_query ($query) or die(mysql_error());
            
        function 
    results($results) {
            
    $list_results mysql_query ($results);
        }
        
        function 
    run_query($col$table) {                
            if (
    $list_results) {
                echo 
    "<select name='$col' id='$col'><option></option>";
                while (
    $Row mysql_fetch_array(results($list_query)) {    echo "<option>".$Row[$col]."</option>"; }
            } else {
                echo 
    "The query could not be executed!";
            }
            
            
    mysql_close ($link);
            print (
    "</select>");
        }
    ?>
    I'm getting syntax errors and i think it has to do with this line: while ($Row = mysql_fetch_array(results($list_query)) I'm not really sure on how to use a function with doing that... Can any one help me out?
    -peace

  • #2
    New Coder
    Join Date
    Dec 2003
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by DiarYofaMadmaN
    PHP Code:
    <?PHP
                                           
    //.......
                
    while ($Row mysql_fetch_array(results($list_query)) {    echo "<option>".$Row[$col]."</option>"; }
            }
        }
    /.....
    ?>
    I'm getting syntax errors and i think it has to do with this line: while ($Row = mysql_fetch_array(results($list_query)) I'm not really sure on how to use a function with doing that... Can any one help me out?
    -peace
    you missed: you opend 3 brackets and you only closed 2:
    while ($Row = mysql_fetch_array(results($list_query)) )
    |Tip: Use a template engine to separate your PHP code from HTML [Smarty]
    |Helpful: Follow the forum rules and posting guidelines, they apply to all of us [Rules] - [Posting Guidelines]
    |Me: [MSN][Y!][AIM][@] - fimi


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •