I am trying to display certain row of my SQL table on a page using $_GET['id'].
So I will briefly go over my setup:
I have a listing page that lists all of the vehicles I have in my SQL table (one row equals one car) and the block of code is looped to print all rows to the page.
There is an 'a' tag attached to the H1
of my listing page that lists a url id dynamically, here is an example:
<a href="carview.php?id='.$row["FullRegistration"].'">
So this is basically pulling the registration of the vehicle from my SQL table and giving the carview.php
an ID based on the row that has been looped in the table.
So now to the actual page that will be displaying the dynamic content.
At the moment I am using <?php $carId = $_GET['id']; ?>
to retrieve the ID that the <a href="carview.php?id='.$row["FullRegistration"].'">
code block prints.
So if I echo $carId
it will print the ID out onto the page which is identical to the "FullRegistration"
column of my SQL database.
The Actual Question
I am now wondering how I could query the row that has the same ID, in my case the ID is the full "FullRegistration"
column of my SQL table.
How can I now print out the row that matches the ID in the URL? Let's say one of my rows have a "FullRegistration"
column value of TT05QVC I then want it to display the data for that row if the url id matches.
I'm guessing I should be using a WHERE clause however after trial and error I cant seem to find a way to do this.
Any ideas how I could possibly do this?