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 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Trouble navigating

    Hello, I am very new to programming and have been trying to learn by way of example and experimentation. About a month ago I asked for some guidance that would allow me to learn how to navigate my database by have a table like interface situated within an HTML text area, so I could look at a record, click it and have all the information of that record displayed.

    I read the advice, studied a bunch more and have been experimenting trying to achieve this goal. I set up a pretend store database for keeping track of warranties. No matter what I do I appear unable to have a formatted table displayed inside my text box.

    I also keep getting a parse error for this line: $query="SELECT lname, fname, phone FROM warrantydb";

    Isn't that line typed correctly? If someone could offer some assistance I would REALLY appreciate it!!

    Here is the latest of what I have tried:

    Code:
    <label for="dataList">Data List</label>
    <textarea name="dataList" id="dataList" cols="45" rows="5" value="
    
    <?php
    
    // Database connection
    
    mysql_connect('localhost', 'root', '')or die(mysql_error());
    
    mysql_select_db ("zdb")
    
    // query string stored in a variable
    $query="SELECT lname, fname, phone FROM warrantydb";  
    
    // query executed 
    $rt=mysql_query($query);          
    
    // if any error is there that will be printed to the screen
    or echo mysql_error();                    
    
    while($nt=mysql_fetch_array($rt))
    {
    // name class and mark will be printed with one line break at the end
    echo "$nt[lname] $nt[fname] $nt[phone]<br>";    
    }
    
    
    
    
    ?>"></textarea>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This is the line tossing you're parse error, since PHP is interpreted it cannot catch it until after:
    PHP Code:
    mysql_select_db ("zdb"
    End it with a semi colon.
    <br> won't work in a textarea, what you want is \n.
    Complex variables (arrays and objects) cannot be directly interpreted within a parsed string (""). So you'll need to expand it using {$nt['lname']} or format it - I'd go with a sprintf: vprintf("%s %s %s\n", $nt);.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    zenix (09-22-2009)

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Wow, thank you very much, I can't believe I over looked that! The page is loading well now, but there is nothing being populated into the text area. I have a small database with a couple of entries in it for testing, I am connected to it, but can't seem to get it working the way I'd like. Any thoughts? I'd really appreciate it.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Yeah, I missed this in the html:
    Code:
    <textarea name="dataList" id="dataList" cols="45" rows="5" value="
    Value is not valid in a textarea. Remove the value, and close the tag there and you're rows should display.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    zenix (09-22-2009)

  • #5
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Plus change this:

    Code:
    ?>"></textarea>
    to:

    Code:
    ?>
    </textarea>
    Textareas work in the manner of:

    Code:
    <textarea>
    [Your input is here, not in a value in the opening tag]
    </textarea>

  • Users who have thanked MattF for this post:

    zenix (09-22-2009)

  • #6
    New Coder
    Join Date
    Jun 2009
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Thumbs up

    So....is it like...obvious I am just a little new to this? You guys are AWESOME!! Thank you SO much for all your help!!


  •  

    Posting Permissions

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