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

    Quick question on printing out results from my_sql

    PHP Code:
    $list_man "SELECT Manufacturer FROM Manufacturers"
    That is my query statment which is getting all the data from under the Manufacturer column from the Manufacturers table. I'm not totally sure on how to print out the results... I'm having all sorts of problems with the while loop

    PHP Code:
        $list_man "SELECT Manufacturer FROM Manufacturers";
        
        function 
    run_query($query) {
            
    $Result mysql_query ($query) or die(mysql_error());
            
            if (
    $Result) {
                echo 
    "<select name='Category' id='Category'>";
                while (
    $Row mysql_fetch_array($Result)) {    echo "<option>$Row['Manufacturer']</option>"; }
            } else {
                echo 
    "The query could not be executed!";
            }
            
            
    mysql_close ($link);
            print (
    "</select>");
        } 
    I don't want to become a pest and keep asking simple question but I have no clue where to go to find out more indepth information on query statements and how to print out the results of them using PHP. I tried reading the mysql reference section on their site but I just get confused even more on how to convert the sql statement slightly to work in php because the syntax they are giving me is for the query statements to use in the mysql control manager.

  • #2
    New Coder
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nvm, after playing around with the coding for awhile reading my past coding and the php manual i found out i screwed up my echo statement it should have been: echo "<option>".$Row['Manufacturer']."</option>";

    but, if you still have other websites to read up on mysql query statements and php that would be greatly appreciated it will save me and you the time of reading simple questions that could be answered by myself without bugging you guys all the time.

    -thanks


  •  

    Posting Permissions

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