Welcome! Log In Create A New Profile

Advanced

What I am finding difficult

Posted by Anonymous User 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Anonymous User
What I am finding difficult
September 28, 2012 10:37AM
Ok I am doing my first page (Student registration page), I have no problem with the SQL insert part, I think what is challenging
is actually gathering the Course names from MYSQL and displaying them exactly where I need them to be on my reg form, alongside course
name preferably next to check boxes as this would update each time a new course is created.
I don't require help as yet, as I need to figure it out on my own, but wow I am having trouble here.
Re: What I am finding difficult
September 28, 2012 11:19AM
Im also currently working on my Student Registration Page, i must say...its kicking my butt.but i found this cool book online & its really helpful (Wrox - Beggining PHP5,Apache and MySql Web Development.pdf)
Anonymous User
Re: What I am finding difficult
September 28, 2012 12:34PM
yeah 77698428Sandra I have the pdf, which is I'm sure the same handbook we were urged to purchase, I agree by purchasing it,
it would be more useful (no copying and pasting) which I learnt, and mac has corrected me on that. I am going to read it properly
this weekend as it has more exercises, the tutorial is brilliant also, it lacks depth though, a beginner would really struggle with
only this material, and no internet or the book, but it is possible to make the portfolio with just the tutorial, it will just require
immense skill in my opinion
avatar Re: What I am finding difficult
September 28, 2012 07:59PM
. . . Functions. . . in the handbook, I think Chapter 3 theres an exercise on the exact thing you're doing now Euwen. I might have given you a hint but i didnt help you. . . really smile
avatar Re: What I am finding difficult
September 28, 2012 10:29PM
by the by. . . Are we allowed to get help for the portfolio? like from each other?
Anonymous User
Re: What I am finding difficult
September 30, 2012 12:03PM
Good question Lance, I'd also like to know because it's good helping and sharing, but it's also good keeping your portfolio "unique/added functionality"
and showing what you've learnt on your own (dono if that sounds weird)
avatar
Mac
Re: What I am finding difficult
October 01, 2012 08:00AM
Help in resolving issues and sections of code and some logic yes.... which is different to group work where two or more people submit the same code throughout. No two coders will code exactly the same throughout.
Anonymous User
Re: What I am finding difficult
October 01, 2012 08:22AM
Re: What I am finding difficult
October 01, 2012 03:54PM
For me there is no specific thing so far that I'm finding difficult, but it is challenging to now have to put all of the different concepts together to make a site that works. I'm still in the early stages though. I could be coming back soon with a whole list smile
Anonymous User
Re: What I am finding difficult
October 03, 2012 08:50AM
yip lisa html plays an important role in this course, I see why UNISA mentioned it> Pre-knowledge on the development of static Web based applications (html) to put it together
Re: What I am finding difficult
October 04, 2012 12:22AM
I agree Euwen. Some pre-knowledge of HTML is certainly helfpful here, but luckily that's not an issue for me. It's just a challenge to take everything that we've learned over all of the different chapters in this course, and then apply them all to work together.
Anonymous User
Re: What I am finding difficult
October 04, 2012 08:02AM
I totally agree, the book should be a must, not optional, it's amazing how professional php developers write code like they writing a novel,
It takes alot of testing the script til it's correct, learning alot I must say, been playing around alot with my script and I am getting there slowly
avatar
Mac
Re: What I am finding difficult
October 04, 2012 10:47AM
Getting info from a db into a table

Language: PHP
echo "<table border=';1';> <tr bgcolor=';#cccccc';><td>Book title</td><td>Author name</td><td>Author surname</td><td>Price</td><td colspan=';2';>Action</td></tr>"; //put the table header column outside the loop     ……//query statement here while($row = mysql_fetch_array($result)){ // the loop part of your query   $book_id=$row[';book_id]; // I want to use this later in a hidden field   echo "<tr><td>"; //put the table rows inside the loop, and draw the information from the db into a table row, one at a time echo $row[';title';]; echo "</td><td>"; echo $row[';auth_name';]; echo "</td><td>"; echo $row[';auth_surname';]; echo "</td><td>"; echo $row[';price';]; echo "</td><td>"; echo "<a href=edit.php?book_id=$book_id&update=yes>Edit</a>"; echo "</td><td>"; echo "<a href=delete.php?book_id=$book_id&delete=yes>Delete</a>"; echo "</tr>"; } echo "</table>"; //end the table outside the loop
Re: What I am finding difficult
October 04, 2012 03:43PM
Hi guys I am struggling with this:

Dr Mac how best do you suggest we reference the keys in tables?Please help me here I am struggling and been trying to get this right for about two weeks.....
Re: What I am finding difficult
October 04, 2012 04:00PM
I think I have finally figured out how to link these tables theorectically:

1. Create all tables by insertting supplied Sql code
2. Insert courses in course table
3.Make student registration form which inserts data into student table
4.In student table insertion code just after the insert query code use mysql_insert_id() function to insert each course selected into course table using the mysql_insert_id() function by looping thourgh and inserting each into course table
5. Using Joins get data needed from tables

So essentially we do not need to alter the tables to link them we can use the above outlined method:

What is better? The Above oulined method ot altering the tables to link primary keys and foreign keys, I hope I have explained this properly. Please get back to me I am super stuck here.
Anonymous User
Re: What I am finding difficult
October 04, 2012 09:01PM
Thanks for that Mac, I have another friday question, best time to ask, ok how do I echo out a double name for eg. a course called PHP Coding,
when I try edit it on my edit form it echo's out the first word "PHP"and not both, as there is a space for the 2nd word, course name being $cname
avatar
Mac
Re: What I am finding difficult
October 05, 2012 08:20AM
@72945079... I am not with you..... are you talking about extracting data from different tables, or inserting data into two different tables? For the former join is the way to go, but you "can" use a nested PHP query (query within a query) until you are comfortable with joins. Slow steps, but you should be working towards joins.

There is a nested MySQL approach as well, but it is as bad as nested PHP queries smiling smiley http://www.selikoff.net/2008/12/10/memo-avoid-nested-queries-in-mysql-at-all-costs/

Language: PHP
//insert ..array of data sent from form (if more than one course that is selected and needs to be inserted) ..array loop start to extract data from the array ....query 1 to insert into table 1... .....get the ID generated in the last with query mysql_insert_id... .....query 2 to insert ID into table 2 ..array loop ends   //PHP nested queries to extract data (not good but just to get into the logic) ...query 1 to extract data ...while loop ...get data ......... query 2 to extract data from another table using the data above .............while loop .............get data .............end while loop ...end while loop   // nested mysql SELECT * FROM mytable WHERE ID in (SELECT ID FROM other table);


@ Euwen... generally you need to enclose it in double quotes as it is a string.

Language: PHP
<input type="text" name="cname" value="<?php echo "$cname"; ?>"> //or echo "<input type=\"text\" name=\"cname\" value="$cname">";
Re: What I am finding difficult
October 05, 2012 09:42AM
What I talking about is inserting data into two different tables? What I want to do is isert data into student registration table then store the id using
Language: PHP
$id=mysql insertid();
After that I want to isert that id/variable into student_course table, the courses are populated into checkboxes which is working, I would then like to have an array capture this data, then loop through this array inserting the student id foreach course and course id into student_course.

then using joins extract data and display, I do not have an issue with joins at all but the inserting of data, is this is good approach?
avatar
Mac
Re: What I am finding difficult
October 05, 2012 10:00AM
The insert method I suggested here above is simplest.
Re: What I am finding difficult
October 05, 2012 10:36AM
Thank you for the quick response, makes sense, I am sorted.
Anonymous User
Re: What I am finding difficult
October 09, 2012 08:16PM
Done with the course and student management page, I manually inserted students with phpmyadmin to test the student manage page.
Still struggling with student reg page tho, I get my course names on the page, from there I got no idea where and how to select them
and which table to insert them into, all my student details insert to student table fine, I need some tips confused smiley, might be alot to ask, Is anyone
else stuggling with this? any recommended sites will help
avatar Re: What I am finding difficult
October 09, 2012 09:11PM
hay Euwen, why don't you create a "process" page to handle the data from your reg page? the process page can then "sort" your data and "INSERT INTO...." your different tables. Or you can create functions and call them on the page you're passing your info to. Hope that helps you abit. . .
Re: What I am finding difficult
October 10, 2012 06:03PM
hI EUWEN PLEASE CHECK WITH www.w3schools.com
Anonymous User
Re: What I am finding difficult
October 10, 2012 08:01PM
Thx Lance for the advice, yip I have a separate process page, I was battling to populate checkboxes from the course table, now trying to figure out how courses get linked to students via keys,
lol @ 77677676... OKAY I WILL CHECK WITH www.w3schools.com
Re: What I am finding difficult
October 16, 2012 12:44PM
Im also struggling to link courses to students...so far im done with the manage courses page,im starting to panic!confused smileysad smiley
avatar Re: What I am finding difficult
October 16, 2012 06:57PM
Don't panic Sandra, its all about your id's in the "course_student" table. when your forms process they'll insert the sno and cid into the appropriate fields, when you run your functions or your method of processing the info your sno(student number) will be linked to the cid(course id)

eg: just using 2 courses
If i register for 2 courses. if my sno is 0001 and the cid's are LVJM1 and LVJM2, the sno would get inserted in the sno field with LVJM1 and in the next row the sno will get inserted with LVJM2
Student Course
0001 LVJM1
0001 LVJM2

That means i am (sno) is registered for 2 courses.
Re: What I am finding difficult
October 17, 2012 09:30AM
Thanks @Lancevjm, that makes a lot of sense...
confused smiley Re: What I am finding difficult
October 19, 2012 10:12AM
I've gone through this thread and came out even more confused. Am not sure whether to create a table with only the final mark field and then get the rest on the data from the tables in the database using JOIN?confused smiley
avatar Re: What I am finding difficult
October 19, 2012 12:51PM
dude,you're confusing me to. the final mark field wont be used, according to the tut letter. but you obviously need to display it. what you on about?
avatar
Mac
Re: What I am finding difficult
October 19, 2012 01:46PM
The final mark is just to throw a spanner in the wheels smiling smiley Your queries must cater for an empty field. Just to point out that when you insert and update a table not all fields are included in the query, and you must code accordingly.

Language: PHP
//either INSERT INTO table (fieldname1, fieldname2) VALUES.... //or INSERT INTO table values (fieldname1, fieldname1, ';';.... the latter for empty fields

You code the way you want. The whole purpose of this portfolio is for you to code according to your logic, hence a spanner here and there.
avatar Re: What I am finding difficult
October 19, 2012 03:14PM
that spanner caught Collin out. . . not mespinning smiley sticking its tongue out lol!
Re: What I am finding difficult
October 20, 2012 03:42AM
Thank you mac,

I got that part just that I was confused as to how to get it going.
avatar Re: What I am finding difficult
October 23, 2012 10:27PM
Does anyone know how to validate if a variable has numeric/integer/digit value? I've checked out numerous forums and sites and all of them gives the same info as : http://www.webdeveloper.com/forum/showthread.php?255676-is_int()-not-working-returning-false....
I've used the is_int(), is_numeric() even the preg_match() but i just can't seem to validate the data as numeric.
Re: What I am finding difficult
October 23, 2012 11:37PM
Feeling the pressure a little bit too guys, going to be a weekend full of work, deadline monday yeah?

@Lancevjm - I just tried using is_numeric and passed a string or numeric value to it and it returns true for both, so use that in your conditional perhaps? In JavaScript all variables are implied literal data-types, php is clever enough to see a number in a string though!
Sorry, only registered users may post in this forum.

Click here to login