I have links which is on one page and and I sent the links to the database and then on another page I am retrieving the the links from the database. I can only send four links to the database, I made it that way, but I want the four links to have different id's but the ids should be the same even if the user sends different links to the database. for example: if the links are:
<a onclick='cover'>ACCOUNTING</a>
<a onclick='cover'>maths</a>
<a onclick='cover'>english</a>
<a onclick='cover'>ict</a>
the ID's should be something like this:
<a onclick='cover' id='10'>ACCOUNTING</a>
<a onclick='cover' id='11'>maths</a>
<a onclick='cover' id='12'>english</a>
<a onclick='cover' id='13'>ict</a>
even if the links sent are different the ids of the four links should still be 10,11,12 and 13.
here is some of mycode: page1:
if(isset($_POST['English']))
{
//his is to make the categpories shows show in the maijn page
headerr("Location:layout.php?userid=${id}&name=${name}&id=1");
array_push($sub,mysqli_real_escape_string($conn,"<li><a onclick='cover'>ENGLISH</a></li>"));
$plo = implode("",$sub);
$query = "UPDATE `user` SET `sub`='$plo' WHERE `id` = '$id'"; $clicked = $clicked +1;
$result = mysqli_query($conn,$query);
if($result)
{
echo "done";
$name .= 'eng,';
}
else{
echo "not done";
echo $query;
}
}
if(isset($_POST['maths']))
{
headerr("Location:layout.php?userid=${id}&name=math&id=1");
array_push($sub,mysqli_real_escape_string($conn,"<li><a onclick='cover'>MATHEMATICS</a></li>"));
$plo = implode("",$sub);
$query = "UPDATE `user` SET `sub`='$plo' WHERE `id` = '$id'"; $clicked = $clicked +1;
$result = mysqli_query($conn,$query);
if($result)
{
echo "done";
$name .= 'math,';
}
else{
echo "not done";
echo $query;
}
}
if(isset($_POST['accounting']))
{
headerr("Location:layout.php?userid=${id}&name=accounting&id=1");
array_push($sub,mysqli_real_escape_string($conn,"<li><a onclick='cover'>ACCOUNTING</a></li>"));
$plo = implode("",$sub);
$query = "UPDATE `user` SET `sub`='$plo' WHERE `id` =$id"; $clicked = $clicked +1;
$result = mysqli_query($conn,$query);
if($result)
{
echo "done";
$name .= 'accounting,';
}
else{
echo "not done";
echo $query;
}
}
page2:
<?php
$userid = $_GET['userid'];
$name =$_GET['name'];
$cler = explode(',',$name);
$i= 0;
$dog =array_filter($cler);
$query ="SELECT sub from user where id = '$userid'";
$result = mysqli_query($conn,$query);
if($row = mysqli_fetch_assoc($result))
{
$t = $row['sub'];
echo $i;
echo $t;
//this is to change the position of the quetion
}
?>
thanks!!!