im not sure i understand this part in the prac.pdf:
"Please provide a single configuration page with your database and user information which you can include in pages that require so."
I'm not sure if i understand this correctly... are we suppose to write our own
basic config.inc.php containing the logon details and mac will just copy our file into the phpMyAdmin on his server and then run our prac or am i on a total wrong track here...
I think it refers to the database and table details for connecting to the database. The database is already there only the user details will have to be changed so that macs machine will be able to connect to them.
$host = "localhost";
$user = "yourusername";
$pass = "yourpassword";
$db = "yourdb";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"
// select database
mysql_select_db($db) or die ("Unable to select database!"
That section should be part of your config file so 1 change will change all your tables and database configuration settings.
Thanks for the help. I have been reading stax of web page on the header command. So from what I understand from all the reading is that you cannot output any data before you issue the header command. It seems that as soon as you output something to the screen a header is sent and when the header command is issued it complains since a header is already sent to the client. If I remember correctly, th page said that the header command should be as high up in your page as possible.
I remove a echo statement (for debugging) I had before the header statement, removed any spaces and ran my code again. It is now working. Thank goodness.
Here is another question I hope anyone can help with. The dob field in the student table. What is the format of the field. it could be ddmmyyyy or dd/mm/yy or mm/dd/yy or even start with the year. Does anyone know how to create a display mask for data. ie:in the dob field dta is store as ddmmyyyy and I would like to dissplay it as dd/mm/yyyy or even dd-mm/yyyy. Hope anyone can help.
So far, so good with the prac. It just seems if it has a life of its own. Growing with each new thing I discover on the net and want to try out. Hope the rest of you are also having fun.
Mac =>> Is it possible that we could get copies of the other pracs at the end of the course, so we could see how others tackled certain tasks. It could be posted as a single or multiple download(s) on the PHP unisa site and downloaded by us, the same as the prac and tut letters.
Glad to be of help. Yeah the header is very fragile as it needs to be sent out early in the processing of your code.
I think,the dob field should be in what ever format you choose for your users to use. The best way to do this for me is use 3 selection boxes.Date, Month and Year. You can name them dd, mm, yyyy respectively. The only thing you need to do is when writing it to your database table is to format it into one variable so it can be written as one.
Before writing to the database i added the follwowing,
I agree with you that the 3 selection boxes are the best approach. I had started coding in that direction and just needed to clear up some things before the codimg became to involved. Doing a rewrite afterwards would be a real pain in the butt.
I am going to store the date as ddmmyyyy. This will keep it in the 8 char limit. I just need to figure out if php has a substring function so that i can cut it up at display time to make it readable.
Thanks for all the help sofar.
Have qa great weekend, and don't let php keep you up to late.
With ref to the substring. I am storing the date as ddmmyyyy (ie 01032008). Thus when I am ready to display it I want to cut it up into 01 (for dd) 03 (for mm) and 2008 (for year) and store each in its own vartiable. I have discovered a php function called substr which will do it for me.
$date = "01032008";
$dd = substr ($date,0,2); //returns 01
$mm = substr ($date,2,2); //erturns 03
$yy = substr ($date,4,4); //returns 2008
echo "date is : $dd-$mm-$yy"; //displays date as 01-03-2008
echo "date is : $yy/$mm/$dd"; //displays date as 2008/03/01
I now just need to go and test it in my setup. So instead of displaying $date I can now display the date in the way I want it.
Hope it is of use to you as well.
"What is this I hear calling my name...... It must be the voice of PHP calling me to work" <grin>
It is Monday morning, and its back to the labour camps again. <grin> Had a great weekend, just wish it was longer.
Glad I could help with the substr function. Am having "fun" with the data validation rules for the student data. Am trying to make it break proof. Maybe I should think of just keeping it simple. Oh well, I am half way through the form, I can just as well complete it. Am now busy with the id number. Have decided to make it a standard that it must be 13 char long and all must be numeric.
Registered: 14 years ago
ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 means the auto increment should start at 9, then increase by one.
This is simply because we have populated the datatbase with 9 records, and then created a dump. You can remove that line from the dump. Its really irrelevent where it starts - 1, 9 or 1254 makes no difference.
Also thought in the beginning that it should increment in steps of 9, but just left it for later to investigate.
Have done the course table and the add, delete and update course pages. Now busy with the student registration page, and next is the delete student and update student pages. Will do the reporting last.
I decided to do the student registration and managing first.
I picked up a 'possible error' in the Table structure for table `student`
No course field exists when a student registers for the 1st time...
Is this wrong or am i looking at it from the wrong angle?
When we register a student, should we also include the course he wants to register
for on the data entry form?
Do we add the student 1st to the student table and then later on after selecting a course from the course table, add both the student and course to the course_student table...?
If we have to include the course, then it means you'll have to retrieve it from the course table and present the available courses to the student...
Am i just confusing the whole requirement here? im not too sure anymore...
FROM THE PRAC:
3. You should have a function to add course information and student information to the course_student table, as well as a function to edit and delete associations between a student and the course he/she registered for.
I am not too sure what problem you experiencing, but from what i understand is that you are trying to write the course the user is registering for into the student table. the course field doesn't exist in the student table, the course field must be written to course_student together with the student no. so in this way the admin can still pick up what course a specific student is registered for.
So in the registeration you need to write to 2 places. The tables have the same 'sno' so it should link in that way.
RichardSanders >>> Thanks, I will remember that titbit of info. Am sure it will become handy very soon.
Mac >>> Have heard people mention asp. Is it like php.
MuhammadA >>> Hope you are well. Am busy with the student update/delete section. It is taking longer than I had hoped for. Plan to finish this part by the end of the week. Then its the reoprt section and I should be finished.
Thats good, you still have some time so take your time and perfect it. I have completed all the sections of the site but still going to test and test and test and modify lol.
I started as a web designer here at this company but had to learn a little of asp because this company loves asp . What i know from php really helped me with learning the basics of asp. They are very similar but what sets them apart is the syntax and commands. Personally I find Php 100 times better and easier to use. The language syntax isn't as strict as asp. Here is an example.
ASP:<%Response.Write "This is a test!" %>
PHp:<?php echo "This is a test";?>
What can be done in asp can be done is php as well and i love php. The difference is peoples preferences.
Hope you having a great time with the prac. Enjoy.