Welcome! Log In Create A New Profile

Advanced

The Portfolio list.php

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
The Portfolio list.php
October 06, 2013 02:37PM
I realize that this might be a very dumb question, but please bear with me.

When joining tables, are we supposed to do that in our PHP script, or in MYSQL php Admin??
Reason why I am asking is because all the tutorials and explanations I can find on this, are about joining the tables in phpMyAdmin.

If we should join tables using PHP script, can anyone point me in the right direction with regards to tutorials etc??
avatar Re: The Portfolio list.php
October 06, 2013 02:42PM
You join tables using SQL.

So, you prepare an SQL statement, and then execute it with PHP.


Look here for the SQL part -

http://www.w3schools.com/sql/sql_join.asp


Here is a very appropriate example - (Uses slightly different syntax)

http://www.sitepoint.com/understanding-sql-joins-mysql-database/



Another two, PHP / mySQL examples -

http://www.tutorialspoint.com/sql/sql-inner-joins.htm

http://www.tizag.com/mysqlTutorial/mysqljoins.php
Re: The Portfolio list.php
October 06, 2013 02:54PM
Thanks a million bigron11!

Will try immediately!
avatar Re: The Portfolio list.php
October 06, 2013 03:14PM
You can also join 2 tables using a WHERE clause.

Here is an example -

http://www.tutorialspoint.com/sql/sql-using-joins.htm
Re: The Portfolio list.php
October 07, 2013 12:32AM
You can also try the SQL website that Prof Mac pointed out : www.sqlcourse.com
Re: The Portfolio list.php
October 07, 2013 11:59AM
Hi,

I'm getting inconsistent results when loading the student_man.php from the list.php. The table of courses that the
student has taken, load if and when it feels like it. No error messages. Debugging I know!!! But a simple message box would
have helped.

Prof mac please consider designing us a php yes no cancell message box that we can take
with us when we leave the course. I cant find any, only plenty of requests for one on the web.

CharlesU
avatar Re: The Portfolio list.php
October 07, 2013 12:09PM
Inconsistent?? If you query the same student the same time after one another is the result then inconsistent? What are you getting?

The Yes/NO message box is possible with JavaScript, but rather not put that into this course.


78044545CharlesU Wrote:
-------------------------------------------------------
> Hi,
>
> I'm getting inconsistent results when loading the
> student_man.php from the list.php. The table of
> courses that the
> student has taken, load if and when it feels like
> it. No error messages. Debugging I know!!! But a
> simple message box would
> have helped.
>
> Prof mac please consider designing us a php
> yes no cancell message box
> that we can take
> with us when we leave the course. I cant find any,
> only plenty of requests for one on the web.
>
> CharlesU

___________________________________________________________________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning...
Re: The Portfolio list.php
October 07, 2013 12:36PM
One of the most annoying things about programming isn't that your program acts on its own - it does *exactly* what you told it to do hehe

From what you wrote I assume that it works fine when you load the student_man.php page but not when you navigate there from list.php?
Are you sure you are passing all the vars that's being checked for on the student_man.php page, maybe check up on the names and values of all the variables that you are in fact passing what you think you're passing.

Just for debugging you can try and print out all the variables at the beginning of the function you're calling on student_man.php, so you can see if the data in them is what you expect them to be.

Good luck
Re: The Portfolio list.php
October 07, 2013 01:11PM
Hi.

I click on the student on the list page, which navigates to the student_man page. Which should have
the all the students details including a table of the courses he is registered for. I think I've used the
incorrect JOIN in MySQL. Shouldn't take to long to Debug! There's at lest three weekends left!

Thanks CharlesU
Re: The Portfolio list.php
October 07, 2013 01:23PM
Hi,

Correction, structured the JOIN incorrectly!

CharlesU
Re: The Portfolio list.php
October 21, 2013 09:01AM
Hi

I need some help I am just not getting my SQL Query right to display the names instead of the ID in my Team list. Please see my code below and the layout of my SQL.

Language: PHP
function getSelectionPositionPlayerFullNames(){ $query = "SELECT * FROM `selections` , playerreg WHERE selection_id = ".$selection_id; $result = mysql_query($query,$connection); confirmQuery($result); return $result; } function listSelections(){ $set = getSelectionPositionPlayerFullNames(); $output = "<table><tr> <th> Loose Head Prop </th> <th> Hooker </th> <th> Tight Head Prop </th> <th> Lock 4 </th> <th> Lock 5 </th> <th> Blindside Flanker </th> <th> Openside Flanker </th> <th> Number Eight </th> <th> Scrum Half </th> <th> Fly Half </th> <th> Left Wing </th> <th> Inside Center </th> <th> Outside Center </th> <th> Right Wing </th> <th> Full Back </th> </tr><tr>"; while ($row = mysql_fetch_array($set)){ $output .= "<td>".$row[';name';]." ".$row[';surname';]."</td> <td>".$row[';hooker';]."</td> <td>".$row[';tightHeadProp';]."</td> <td>".$row[';lock4';]."</td> <td>".$row[';lock5';]."</td> <td>".$row[';blindsideFlanker';]."</td> <td>".$row[';opensideFlanker';]."</td> <td>".$row[';numberEight';]."</td> <td>".$row[';scrumHalf';]."</td> <td>".$row[';flyHalf';]."</td> <td>".$row[';leftWing';]."</td> <td>".$row[';insideCenter';]."</td> <td>".$row[';outsideCenter';]."</td> <td>".$row[';rightWing';]."</td> <td>".$row[';fullBack';]."</td>"; } $output .= "</tr></table>"; echo $output;
avatar Re: The Portfolio list.php
October 21, 2013 09:38AM
Language: PHP
$query = "SELECT * FROM `selections` , playerreg WHERE selection_id = ".$selection_id;


Try this -

Language: PHP
$query = "SELECT * FROM selections, playerreg WHERE selection_id = ';$selection_id'; ";
Re: The Portfolio list.php
October 21, 2013 01:53PM
Hi

well I got it working, but I am sure that it is not the best way.

Language: PHP
function getSelectionPositionPlayerFullNames(){ global $connection; $query = "SELECT CONCAT(f1.name,'; ';,f1.surname) as f1looseHeadProp, CONCAT(f2.name,'; ';,f2.surname) as f2hooker, CONCAT(f3.name,'; ';,f3.surname) as f3tightHeadProp, CONCAT(f4.name,'; ';,f4.surname) as f4lock4, CONCAT(f5.name,'; ';,f5.surname) as f5lock5, CONCAT(f6.name,'; ';,f6.surname) as f6blindsideFlanker, CONCAT(f7.name,'; ';,f7.surname) as f7opensideFlanker, CONCAT(f8.name,'; ';,f8.surname) as f8numberEight, CONCAT(f9.name,'; ';,f9.surname) as f9scrumHalf, CONCAT(f10.name,'; ';,f10.surname) as f10flyHalf, CONCAT(f11.name,'; ';,f11.surname) as f11leftWing, CONCAT(f12.name,'; ';,f12.surname) as f12insideCenter, CONCAT(f13.name,'; ';,f13.surname) as f13outsideCenter, CONCAT(f14.name,'; ';,f14.surname) as f14rightWing, CONCAT(f15.name,'; ';,f15.surname) as f15fullBack FROM selections INNER JOIN playerreg as f1 ON looseHeadProp = f1.player_id INNER JOIN playerreg as f2 ON hooker = f2.player_id INNER JOIN playerreg as f3 ON tightHeadProp = f3.player_id INNER JOIN playerreg as f4 ON lock4 = f4.player_id INNER JOIN playerreg as f5 ON lock5 = f5.player_id INNER JOIN playerreg as f6 ON blindsideFlanker = f6.player_id INNER JOIN playerreg as f7 ON opensideFlanker = f7.player_id INNER JOIN playerreg as f8 ON numberEight = f8.player_id INNER JOIN playerreg as f9 ON scrumHalf = f9.player_id INNER JOIN playerreg as f10 ON flyHalf = f10.player_id INNER JOIN playerreg as f11 ON leftWing = f11.player_id INNER JOIN playerreg as f12 ON insideCenter = f12.player_id INNER JOIN playerreg as f13 ON outsideCenter = f13.player_id INNER JOIN playerreg as f14 ON rightWing = f14.player_id INNER JOIN playerreg as f15 ON fullBack = f15.player_id "; $result = mysql_query($query,$connection); confirmQuery($result); return $result; } function listSelections(){ $set = getSelectionPositionPlayerFullNames(); $output = "<table><tr> <th> Loose Head Prop </th> <th> Hooker </th> <th> Tight Head Prop </th> <th> Lock 4 </th> <th> Lock 5 </th> <th> Blindside Flanker </th> <th> Openside Flanker </th> <th> Number Eight </th> <th> Scrum Half </th> <th> Fly Half </th> <th> Left Wing </th> <th> Inside Center </th> <th> Outside Center </th> <th> Right Wing </th> <th> Full Back </th> </tr><tr>"; while ($row = mysql_fetch_array($set)){ $output .= "<td>".$row[';f1looseHeadProp';]."</td> <td>".$row[';f2hooker';]."</td> <td>".$row[';f3tightHeadProp';]."</td> <td>".$row[';f4lock4';]."</td> <td>".$row[';f5lock5';]."</td> <td>".$row[';f6blindsideFlanker';]."</td> <td>".$row[';f7opensideFlanker';]."</td> <td>".$row[';f8numberEight';]."</td> <td>".$row[';f9scrumHalf';]."</td> <td>".$row[';f10flyHalf';]."</td> <td>".$row[';f11leftWing';]."</td> <td>".$row[';f12insideCenter';]."</td> <td>".$row[';f13outsideCenter';]."</td> <td>".$row[';f14rightWing';]."</td> <td>".$row[';f15fullBack';]."</td> "; } $output .= "</tr></table>"; echo $output; }
avatar
Mac
Re: The Portfolio list.php
October 21, 2013 03:12PM
Uhm..... this is not the ICT2613 forum???
Re: The Portfolio list.php
October 22, 2013 09:15AM
Hi

thanks, I was reading the post and then thought I was in ICT2613
Re: The Portfolio list.php
November 02, 2013 06:43PM
I am still not making any headway on this page.

I am no longer sure what I should be trying to join, or how. Frustrations and stress is getting the better of me!

Any advice for this page would be greatly appreciated. Specifically, is there anyone out there who tried to insert the course selected directly into the course_student table?
If not, where did you capture the info of who is taking what course?
avatar
Mac
Re: The Portfolio list.php
November 04, 2013 07:38AM
Have you had a look at the diagram in the tut letter, which explains the flow?
Re: The Portfolio list.php
November 04, 2013 06:42PM
Hello Mac,

Yes I did and am making some headway on this page.

At the moment I am just really struggling with changing the fmark for each student. I tried using the same method I used for editing my courses and student info, but it's not working.

I will keep trying but if time runs out, could I be failed just on that point?

E
Re: The Portfolio list.php
November 04, 2013 08:41PM
Hi,

The tut letter states that the fmark is not used in the table in on page 14 & 15 in
the column Extra info. Hope I've interpreted that correctly !!!

CharlesU
Re: The Portfolio list.php
November 04, 2013 10:11PM
PHEW! Thank you Charles!

Completely missed that!!

That means I am done with list.php!

Happiness!!! smiling bouncing smiley

I guess I got so caught up in trying to get everything om my page to work the way I wanted it to, that I never really realized what was unnecessary.
avatar
Mac
Re: The Portfolio list.php
November 05, 2013 07:56AM
The fmark is a dummy field.... the purpose for you to learn how to insert/update "non-existent" data.

Language: PHP
//e.g. where fmark is column 2 INSERT INTO table_name (column1, column3) //specify which columns VALUES (';$value1';, ';$value3';); //only insert those values   INSERT INTO table_name //columns not specified VALUES (value1, value2, value3) //VALUES (';$value1';, '; ';, ';$value3';); //insert all values, fmark being empty

There is also a SET syntax for doing this... which appears easiest but I myself have never used it (http://dev.mysql.com/doc/refman/5.0/en/extensions-to-ansi.html). Point is, there are many ways to do the same thing.
Re: The Portfolio list.php
November 05, 2013 08:24AM
Hi Prof mac,

To late to do anything about it now, but does that mean my interpretation was Wrong?

CharlesU
avatar
Mac
Re: The Portfolio list.php
November 05, 2013 08:42AM
Nope.... this is an introductory course so it is all about basics but hopefully learning some lessons along the way (there a way too many lessons to learn in 3.5 months).

First requirement - does it work? Not "how well" was it coded to get it to work, although we do look at your code.
Sorry, only registered users may post in this forum.

Click here to login