Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying data from a linked table and displaying it as a list with HTML/PHP/MySQL
    primarykey
    data
    text
    <p>I have three tables. </p> <pre><code>students studentID | FirstName | LastName | Email | Form course CCode | Title courseenrolement courseenrolementid | studentID | ccode | complete | scode </code></pre> <p>With the website, I have a page where I can view all the current <code>enrolements</code> and I wish to be able to view the list displaying the <code>first name, surname and course title</code>. I know I could do it with the following SQL (for the names):</p> <pre><code>SELECT FirstName, LastName FROM student, courseenrolement WHERE courseenrolement.studentID = student.studentID </code></pre> <p>But I am unsure how to get this to work using HTML/PHP. At present I only know how to display the <code>studentID and CCode</code> from the <code>courseenrolement</code> table using the following code:</p> <pre><code>&lt;ul&gt; &lt;?php foreach ($courseenrolements as $ce): ?&gt; &lt;li&gt; &lt;form action="" method="post"&gt; &lt;div&gt; &lt;?php htmlout($ce['studentID']); ?&gt; &lt;?php htmlout($ce['CCode']); ?&gt; &lt;input type="hidden" name="courseenrolementid" value="&lt;?php echo $ce['courseenrolementid']; ?&gt;"&gt; &lt;input type="submit" name="action" value="Edit"&gt; &lt;input type="submit" name="action" value="Delete"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; </code></pre> <p>which displays this:</p> <p><img src="https://i.stack.imgur.com/aeJOP.jpg" alt="output"></p> <p>But I would like the <code>names and course title</code>. I managed to get it to show the <code>names</code> etc in the dropdown on the 'Add new' form, so I would assume it will be similar, but just unsure on how exactly. Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload