View Full Version : Trouble navigating

09-22-2009, 04:33 PM
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:

<label for="dataList">Data List</label>
<textarea name="dataList" id="dataList" cols="45" rows="5" value="


// 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

// if any error is there that will be printed to the screen
or echo mysql_error();

// name class and mark will be printed with one line break at the end
echo "$nt[lname] $nt[fname] $nt[phone]<br>";


09-22-2009, 04:38 PM
This is the line tossing you're parse error, since PHP is interpreted it cannot catch it until after:

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);.

09-22-2009, 06:09 PM
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.

09-22-2009, 06:19 PM
Yeah, I missed this in the html:

<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.

09-22-2009, 06:23 PM
Plus change this:




Textareas work in the manner of:

[Your input is here, not in a value in the opening tag]

09-22-2009, 09:52 PM
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!!