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.(我只能这样发送四个链接到数据库,但是我希望这四个链接具有不同的ID,但是即使用户向数据库发送不同的链接,ID也应该相同。) 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:(ID应该是这样的:)
<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.(即使发送的链接不同,四个链接的ID仍应为10、11、12和13。)
here is some of mycode: page1:(这是一些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:(第2页:)
<?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!!!(谢谢!!!)
ask by SMART G. translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…