mfox Posted February 7, 2012 Share Posted February 7, 2012 Dear pHpFreaks I am very excited to join the board and hoping to learn about php/mySQL. My reason for joining is I wish to develop a simple website, where a select group of users can enter data into an online form each week, and which can be reviewed at a weekly meeting. I have good experience in html/css for static webpage design. Can you please point me in the right direction, is php/msql what Im after, and can you recommend me any books to start off with particular to this matter? Thank you MFox Quote Link to comment https://forums.phpfreaks.com/topic/256597-hi-from-australia-and-can-you-point-me-in-the-right-direction/ Share on other sites More sharing options...
digibucc Posted February 7, 2012 Share Posted February 7, 2012 Welcome, i'm new here myself from US, but a fan of down under luckily, that's pretty basic what you want to do. you would create an html form and style it with css as you know how, then make it's action "submit.php" or whatever you name the php file. then you make the php script, it would get all of the submitted info via POST and put it in a mysql insert statement. something like: <?php $con = mysql_connect("address","username","password"); // connect to mysql if (!$con) { die('Could not connect: ' . mysql_error()); // or die } mysql_select_db("dbname", $con); // select database to work with foreach ($_POST as $key=>$value){ // for EACH posted variable if ($value != '' && $value != 'Submit'){ // if it's not empty OR the submit button $cols .= mysql_real_escape_string($key). ', '; // escape the key and add it to the cols string $vals .= '\''. mysql_real_escape_string($value). '\', '; //escape the value and add it to the vals string } $columns = substr($cols,0,-2); // clean trailing chars $values = substr($vals,0,-2); // clean trailing chars $sql="INSERT INTO table ( $columns )VALUES ( $values )"; // prepare the sql statement, table is your table name if (!mysql_query($sql,$con)) // attempt to insert { die('Error: ' . mysql_error()); // if it fails, the script dies, otherwise it continues after the bracket. } ?> that will handle saving it to the mysql db. then i would make a separate page called view.php, to pull the db entries and display them, like: <?php $con = mysql_connect("address","username","password"); // connect to mysql if (!$con) { die('Could not connect: ' . mysql_error()); // or die } mysql_select_db("dbname", $con); // select database to work with $qry = "SELECT * FROM table"; // select everything from the "table" table $data = mysql_query($qry) or die(mysql_error()); // save the table into $data, or die $entries = mysql_num_rows( $data ); // count the number of rows , if you need to know for display purposes while ($info = mysql_fetch_assoc( $data )) { // this is a loop, that takes each row and saves it to the info variable. so you can call your field names (eg 'address') as $info['address'] //whatever you put here will happen for each row. so you can echo out each column, you can make an html table and lay them out, etc. up to you. } ?> Quote Link to comment https://forums.phpfreaks.com/topic/256597-hi-from-australia-and-can-you-point-me-in-the-right-direction/#findComment-1315440 Share on other sites More sharing options...
floridaflatlander Posted February 7, 2012 Share Posted February 7, 2012 I think it depends on where your at in your coding experience, to give you an idea of where I'm coming from I'm over 50, messed around with stuff like debase II, debase III and debase III+ and paradox in the late 80's and very early 90's. Then dropped out of any kind of coding for twenty years. I think the brain changes when you use it different ways so when I started back last year to playing with code I had a very hard time. I first bought Ullman's php6mysql5 and went what? I then bought ullmans very beginner PHP book and learned from that and then went to Ullmans php6mysql5. I have several other books that I got and that come in handy for reference but time will tell. When you start building things that's when you really learn. If you can code a little I'd suggest Ullman's php6mysql5 or Welling & Thomson's Php & Mysql. Also go to amazon and read the reviews. Now there are people that are on here that say they have never used a book to learn php, I have and idea it has to do with smarts, social environment and age(some generations just play with this more than others). Quote Link to comment https://forums.phpfreaks.com/topic/256597-hi-from-australia-and-can-you-point-me-in-the-right-direction/#findComment-1315442 Share on other sites More sharing options...
digibucc Posted February 7, 2012 Share Posted February 7, 2012 i am the type that learned without books and it's a double-edged sword. I immerse myself in things i like, and figure out how they work. i did it with html, css, php, etc. doesn't work so wel once you get out of those languages though that being said, i KNOW that i don't have as complete an understanding as someone who read and comprehended those books - though many people will read and not comprehend but once i get to the point where my own experience gives me a solid base (where i am now with php), it makes it much easier to expand my knowledge. i tend to only really ever use the PHP man pages, as that is exactly the kind of info i want. concise, to the point, etc. books and tuts are longwinded and tend to explain concepts i already understand, when i just want one specific piece of information. that being said, from time to time i go through all levels of tuts, just to be sure it falls in line with my experience, because if something very basic is different from how i'd do it, i have to reconsider Quote Link to comment https://forums.phpfreaks.com/topic/256597-hi-from-australia-and-can-you-point-me-in-the-right-direction/#findComment-1315447 Share on other sites More sharing options...
JacobCMarshall Posted February 7, 2012 Share Posted February 7, 2012 Hey, welcome to PHPFreaks! I'm also pretty new, and I'm from New Zealand I'm sure you'll find exactly what you're looking for on this forum! Already I have found a lot of stuff that I've learned from, and I've only been a member for like 2 days. If you need any help, PM me! Quote Link to comment https://forums.phpfreaks.com/topic/256597-hi-from-australia-and-can-you-point-me-in-the-right-direction/#findComment-1315544 Share on other sites More sharing options...
mfox Posted February 8, 2012 Author Share Posted February 8, 2012 Thank you for your replies. I am really grateful for your quick responses and replies. I am amazed about how quick digibucc could create some code for what I am aiming to achieve. Thank you. Although I don't understand it yet, I will come to understand it with time. Flatlander: thanks for the recommendations: you've confirmed Ullman's book is the one for me to start with. the Reviews on Amazon are quite good. I don't come from any computer programming background. HTML/CSS I've learnt from scratch and mainly through going over source code. The type of logical coding that is php/mysql frightens me. I thought initally, why not just jump straight into it, learn from the tutorials on the web. But I think something like this, I need the fundamentals first and books look like the way to go! Many thanks all MFox Quote Link to comment https://forums.phpfreaks.com/topic/256597-hi-from-australia-and-can-you-point-me-in-the-right-direction/#findComment-1315693 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.