Jump to content

Next step?


eduard

Recommended Posts

That's the spirit!!! :) - When you click the text of a label, a form element will "gain focus" (for a text field, this means a blinking marker will appear on it, allowing you to type). In the "for" attribute, you specify the "id" of the element you want focused.- In the context of the "input" element, "fName" is the "id" of the input and "firstName" is the "name" of the input. These are the values of two different attributes that have nothing to do with each other.- The "name" attribute.- Literally, the type (as in "kind") of form field. Depending on the type, the browser will show a different way the user can fill the form in. You can see what the browser does for each type on this part of the HTML tutorial.- The "id" has no effect in PHP. Only the "name" does. A little theory (don't skip this!!! Read it in full!!! You'll need it!!!): The IDs have nothing to do with the whole form submission process. When you "submit" a form, what the browser does is to send PHP a collection of "name and value pairs". Each input element represents a pair, the name attribute reflects the name in the pair, and whatever the user fills in reflects the value in the pair. PHP puts all pairs in either the $_POST array or the $_GET array, depending on the form's "method" attribute. At this point, each pair is turned into an array "key and value pair". Another word for "key" is "index". The terms are slightly different in some other languages, but in PHP, they're synonymous. The IDs only have an effect on the page they're on. In it, they allow you to target a specific element for some purpose, such as (in the case of the label's "for" attribute) putting a focus to the element. IDs can appear on any element, whereas names can only appear on form elements.
Do you have a label and next to it its input field?
Link to comment
Share on other sites

  • Replies 118
  • Created
  • Last Reply

Top Posters In This Topic

Do you have a label and next to it its input field?
You don't have to have the label next to its input field. Both the label and the input can be anywhere on the page, as long as the "id" attribute on the input and the "for" attribute on the label match.You could (in theory) click a label at the top of the page to focus a form element that's at the bottom. In practice, why would you?
Link to comment
Share on other sites

So, my insert.php is functioning now because it gets its data from the form.html?
Yes.When you clicked the submit button in "form.html", the browser sent the data in your form to insert.php, where PHP took that data, and placed it into the $_POST array that insert.php then relies on.
Link to comment
Share on other sites

Yes. When you clicked the submit button in "form.html", the browser sent the data in your form to insert.php, where PHP took that data, and placed it into the $_POST array that insert.php then relies on.
Ok, thanks!
Link to comment
Share on other sites

My next question is What do I write on my database(select).html? Database(select).php: <?php$con = mysql_connect("localhost", "root", "usbw");mysql_select_db("website", $con);// sending query$result = mysql_query("SELECT * FROM links");echo "<h1>Table: links</h1>";echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<0; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?>

Edited by eduardlid
Link to comment
Share on other sites

well, first it has to be a php page. Then you could write it to execute an SQL SELECT query against the database and table you've been inserting data into. The tutorials has examples.http://www.w3schools.com/php/php_mysql_select.asp

Link to comment
Share on other sites

well, first it has to be a php page. Then you could write it to execute an SQL SELECT query against the database and table you've been inserting data into. The tutorials has examples.http://www.w3schools...ysql_select.asp
I understand your reply!I´ve a select.php script: (see also above!) <?php $con = mysql_connect("localhost", "root", "usbw"); mysql_select_db("website", $con); // sending query$result = mysql_query("SELECT * FROM links"); echo "<h1>Table: links</h1>";echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<0; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?>But the question was and is: How do I write the associated questions and how do I intergrate them within my website? Edited by eduardlid
Link to comment
Share on other sites

Could you be a little more specific?What kind of an application are you making, and how do you want it to function (from a user's point of view)?

Link to comment
Share on other sites

Could you be a little more specific? What kind of an application are you making, and how do you want it to function (from a user's point of view)?
I want to show on the homepage of my website a (small) database, what you can do with it (examples) and that I can make it functioning!
Link to comment
Share on other sites

displaying those links already is an example. if you want to create a demonstration, then you should give the option (carefully) to allow users to add (INSERT) links, and then when they submit, the page could be refreshed, and their link would then be displayed. again, you can't really show a database (not sure if you get that yet), but you can create an application, that uses a database, to highlight the features and benefits that it offers for those who are curious, or don't understand the concept. like in this case, adding records and then displaying them. the next step, is to allow a user to edit links (as opposed to add). That should more or less cover CRUD.http://en.wikipedia.org/wiki/Create,_read,_update_and_delete

Edited by thescientist
Link to comment
Share on other sites

displaying those links already is an example. if you want to create a demonstration, then you should give the option (carefully) to allow users to add (INSERT) links, and then when they submit, the page could be refreshed, and their link would then be displayed. again, you can't really show a database (not sure if you get that yet), but you can create an application, that uses a database, to highlight the features and benefits that it offers for those who are curious, or don't understand the concept. like in this case, adding records and then displaying them. the next step, is to allow a user to edit links (as opposed to add). That should more or less cover CRUD.http://en.wikipedia....date_and_delete
Very good reply!Ok, maybe I´m confused between a database and a table! But at least a table you can show! Can´t you?Shouldn´t it be in my case: RUD (C can do only I, RUD I can develop the aplications?)Very good link, by the way! Edited by eduardlid
Link to comment
Share on other sites

A table in a database is not the same thing as a <table> in HTML.

Edited by thescientist
Link to comment
Share on other sites

A table in a database is not the same thing as a <table> in HTML.
Therefore, a table of a database you can show neither? Edited by eduardlid
Link to comment
Share on other sites

You can show a table, that's in a database. You can run a query that displays the whole table: SELECT * FROM tableName;Then you can take the results from that and 'show' it on your website. You can even put(format) it inside a HTML <table>.

Link to comment
Share on other sites

You can show a table, that's in a database. You can run a query that displays the whole table: SELECT * FROM tableName; Then you can take the results from that and 'show' it on your website. You can even put(format) it inside a HTML <table>.
It´s a very good example! But how? (homepage, portfolio?) The php scripts do I have to insert in .html? Do I have to use html forms?Where?
Link to comment
Share on other sites

Unsurprisingly, you've lost the plot. You've already demonstrated in the last few posts how to use a SELECT query to output information to a browser. Essentially, you've just output the content of a table in a database. I don't get what you don't understand anymore. I swear it's like you just restarted this entire thread all over again.... :facepalm:

Edited by thescientist
Link to comment
Share on other sites

You can show a table, that's in a database. You can run a query that displays the whole table: SELECT * FROM tableName; Then you can take the results from that and 'show' it on your website. You can even put(format) it inside a HTML <table>.
I´ve a insert.php <?php$Site_Name = $_POST['site_name'];$Site_URL = $_POST['site_url'];$Description = $_POST['Description'];$con = mysql_connect("localhost","root","usbw") or die(mysql_error());mysql_select_db("website", $con);$sql="INSERT INTO links (Site_Name, Site_URL, Description)VALUES ('$_POST[site_name]','$_POST[site_url]','$_POST[Description]')";if (!mysql_query($sql,$con)){ die('Error: ' . mysql_error());}echo "1 record added";mysql_close($con);?> And a select.php <?php$con = mysql_connect("localhost", "root", "usbw");mysql_select_db("website", $con);// sending query$result = mysql_query("SELECT * FROM links");echo "<h1>Table: links</h1>";echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<0; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?>But now?
Link to comment
Share on other sites

Unsurprisingly, you've lost the plot. You've already demonstrated in the last few posts how to use a SELECT query to output information to a browser. Essentially, you've just output the content of a table in a database. I don't get what you don't understand anymore. I swear it's like you just restarted this entire thread all over again.... :facepalm:
Very simple! How do I imtegrate the mysql queries into my website?
Link to comment
Share on other sites

Let me say it for you 1, 2, 3 AAAAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH.
I didn´t know that you can count until 3!
Link to comment
Share on other sites

All of you deserve a facepalm. Some of you deserve a double facepalm.

Very simple! How do I imtegrate the mysql queries into my website?
Have you even tried to upload the select file and run it? That would be the first step. The next step would be changing the code to fit the look of the rest of your site, however you want that to look. That's your decision.
Link to comment
Share on other sites

All of you deserve a facepalm. Some of you deserve a double facepalm. Have you even tried to upload the select file and run it? That would be the first step. The next step would be changing the code to fit the look of the rest of your site, however you want that to look. That's your decision.
Question: Many times (it works!)Explanation: That I know! But how?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...