I have a table that has the columns
GroupID | GroupName | GroupDesc | Overs |
-----------------------------------------
1 | Test Group|Description| Yes |
I have a page called list.php and it currently creates the URL for each row in the DB in the groups table(above).
The code is not the prettiest but I think it works this is he code
list.php
<?php
$result = mysql_query("SELECT * FROM groups");
while($row = mysql_fetch_array($result))
{
echo "<div class=\"divider\">";
echo "<a href=\"group.php?id=";
echo $row['GroupID'];
echo "\">";
echo $row['GroupName'];
echo "</a>";
echo "<br><br>";
echo $row['GroupDesc'];
echo "<br>";
echo "Over 18's: ";
echo $row['AgeRes'];
echo "</div>";
}
?>
This then creates a URL such as this http://domainname.com/group/group.php?id=1
This is where my questions are - how would I select the relevant row from the DB above using the ID section in the URL?
My second question would be how would we stop this being SQL injectable?
I am kind of new to all this so I would love an answer on this and any good reading sources so I can develop my skills further.
Thanks