Jump to content

Hi from Australia, and can you point me in the right direction?


mfox

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.