Page 1 of 1

a real INSERT INTO (mysql) with queryResult SAME PAGE

Posted: Tue Dec 23, 2003 3:11 pm
by poeta_eletrico
well,


for a newbie like me it s really strange see around a lot of different codes targeting to the same direction. oh! sorry...should it be...but too many people seems not to care about the others and write codes that or make nonsense or it s not a right code to study with...and this "newbie" poor boy spent a lot of time surfing around...

i would like with this with the complement of other guys really develop a page with a REAL SENSE direction so other users could make part and share with others as well.

so i will begin the first line :

// this code it s intending to INSERT data into a MYSQL database
// this database have the following fields
// -> id (autoincrement)
// -> name
// -> e-mail

// one important point to consider is : i would like to implement just one page to INSERT and after INSERTED (making use of $SERVER_PHPSELF;) // we could have LISTED the INSERTED ITEMS at the same PAGE !!!

// FIRST PART OF THE CODE : DEVELOP THE FORM - EVERYTHING INSIDE //THE CODE
// THE PAGE IS : INSERT_AND_SEE.PHP
//
/* ////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\ */


// if the block below does not make sense - please correct


echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">";
echo "<table border=\"1\" cellspacing=\"0\" cellapadding=\"0\" align=\"center\">";
echo "<tr><td>Nome</td><td><input type=\"text\" size=\"30\"></td></tr>";
echo "<tr><td>E-mail</td><td><input type=\"text\" size\"30\"></td></tr>";
echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Send This Form\"></td></tr> ";
echo "</table>";
echo "</form>";


$db_host="localhost"; // or the host you use
$db_user="you:username";
$db_pass="your:database:password";
$db_bank="your:database:name";

// connecting to the server

$db_link = mysql_pconnect($db_host, $db_user, $db_pass) or trigger_error(mysql_error(),E_USER_ERROR);

$db_select = mysql_select_db($db_bank, $db_link);

// i will stop here ... if someone have more important points to add, please // do it JUST KEEP IN TOUCH TO COPY THE PART OF THE CODE : AND //CONTINUE RIGHT FROM THE LAST STEP[/b]



-> this comments JUST TRY TO STOP AND SOLVE a CONFUSION / or FAILURE OF COMMUNICATION and this piece of comments regards the ones BELOW by : Gen-ik - thomasd1 - Bill H




guys :
--------------------------------------------------------------------


1. I did not say people that share their time to help others develop CRAP CODE...

2. My answer to mr. GEN it was not sarcastic but my point of view to answer his comments. Nothing at all...

3. About the confusion for some different codes u probably be right...but there“s differences for what is and should be.


I just intended to the code above, only to serve as reference and numbered a very simple drive code like :

-> the schema :
-----------------------------------------------
1. display a page with a form to insert records to a database.

2. The FORM must use in ACTION = "$SERVER['PHPSELF']; . so it will loop back parsing two actions:

::: 2. 1 -> inserting the form "elements" to the bank and must DISPLAY the INSERTED ITEM only identify by ID ( I think must be the right option - but I am not sure) .

::: 2. 2 -> This method is very common when you are registering on a site and when performing the form it returns the informations you send to the server. the difference is that i would like to see everything into one single page executing this actions.

I only want to develop an schema very simple that could help others as me either....but...i did not think this could bring confusion and no solution for what I intended in the begining.

Bye,

Poeta_Eletrico

Posted: Tue Dec 23, 2003 7:09 pm
by Gen-ik
When most people write there own code they normally do it in a style/format that they are either used to or can easily work with.
Expecting every single bit of PHP code you look at to make sense the first time to go through it is expecting a bit much.

Personally if I ever have a look at someone elses class() I always need to read through it a few times in order to see how it all fits together, and I've been working with PHP for a year or so now.

There are a lot of newbies out there who 'jump in at the deep end' and try to do stuff without really knowing what's going on... and there are plenty of examples of this in this forum.

The more you work with PHP the more you get to know and the easier it becomes to read and write, just like any other programming language.

I don't know anything about C++ but I want to learn it at some point. What I won't be doing though is expecting to be able to create the next generation Quake engine the first time I try and use it.

Posted: Wed Dec 24, 2003 3:38 am
by poeta_eletrico
Gen-ik wrote:When most people write there own code they normally do it in a style/format that they are either used to or can easily work with.
Expecting every single bit of PHP code you look at to make sense the first time to go through it is expecting a bit much.

Personally if I ever have a look at someone elses class() I always need to read through it a few times in order to see how it all fits together, and I've been working with PHP for a year or so now.

There are a lot of newbies out there who 'jump in at the deep end' and try to do stuff without really knowing what's going on... and there are plenty of examples of this in this forum.

The more you work with PHP the more you get to know and the easier it becomes to read and write, just like any other programming language.

I don't know anything about C++ but I want to learn it at some point. What I won't be doing though is expecting to be able to create the next generation Quake engine the first time I try and use it.

Mr. Gen-ik
-------------------------------------------------------------------


I think you completly did not understand the point. Yes, I am a newbie cos I love webdesign and I have to confess that a LOGICAL mind to me it s not a easier thing to deal with but as a person that everything I learned, I won t say : ALONE. Because I have the help of others like you that spent time to advice someone like me or share opinions and knowledge or even inform a site that I never plenty my browser before...that s what makes INTERNET a great LABAROTARY. When I develop this BRIEFING piece of code, it was just to help others to get a logical way to do what it s intending to do...you have to agree with me that THERE S A LOT OF CODE that intends to the same as I am thinking but no one gives a way to do it differently...got it? That s only the point ... I did not intend to ofend anyone here, and I understood what u wrote...



Kind Regards
Merry Christmas!

Posted: Wed Dec 24, 2003 5:24 am
by thomasd1
poeta_eletrico wrote:
Gen-ik wrote:When most people write there own code they normally do it in a style/format that they are either used to or can easily work with.
Expecting every single bit of PHP code you look at to make sense the first time to go through it is expecting a bit much.

Personally if I ever have a look at someone elses class() I always need to read through it a few times in order to see how it all fits together, and I've been working with PHP for a year or so now.

There are a lot of newbies out there who 'jump in at the deep end' and try to do stuff without really knowing what's going on... and there are plenty of examples of this in this forum.

The more you work with PHP the more you get to know and the easier it becomes to read and write, just like any other programming language.

I don't know anything about C++ but I want to learn it at some point. What I won't be doing though is expecting to be able to create the next generation Quake engine the first time I try and use it.

Mr. Gen-ik
-------------------------------------------------------------------


I think you completly did not understand the point. Yes, I am a newbie cos I love webdesign and I have to confess that a LOGICAL mind to me it s not a easier thing to deal with but as a person that everything I learned, I won t say : ALONE. Because I have the help of others like you that spent time to advice someone like me or share opinions and knowledge or even inform a site that I never plenty my browser before...that s what makes INTERNET a great LABAROTARY. When I develop this BRIEFING piece of code, it was just to help others to get a logical way to do what it s intending to do...you have to agree with me that THERE S A LOT OF CODE that intends to the same as I am thinking but no one gives a way to do it differently...got it? That s only the point ... I did not intend to ofend anyone here, and I understood what u wrote...



Kind Regards
Merry Christmas!
was that sarcastic?

Posted: Wed Dec 24, 2003 8:31 am
by Bill H
was that sarcastic?
No, I think he's telling us we write crappy code.
(Why he feels the need to do that is not clear.)

Posted: Wed Dec 24, 2003 8:49 am
by Gen-ik
He just seems very confused about why people write the same code in different ways... ie one email class() doesn't look like another one which does the same job.

But I think I answered that in the first sentence of my last replay up there.

Posted: Wed Dec 24, 2003 4:42 pm
by thomasd1
anyways, the stuff he said, made absolutely no sense to me ... :o 8O