Sorry for my spelling... Im trying to print a list of internets forfeit from my database and then when I click on the hyperlink, it send the id of the forfeit to the page.I have tried to put the id in a hidden value but nothing works, im truck there...
include_once "DataBase/db.php";
if($internet->num_rows != 0){
while($rows = $internet->fetch_assoc()){
$nom = $rows["nom"];
$id = $rows["id"];
$tech = $rows["technologie"];
$telechargement = $rows["telechargement"];
$televersement = $rows["televersement"];
$utilisation = $rows["utilisation"];
$prix= $rows["prix"];
echo '
<form name="form2" method="POST" action="Fournisseurs/Videotron.php">
<div class="boxes">
<div class="[ price-option price-option--high ]">
<div class="price-option__detail">
<span class="price-option__cost">'.$nom.'<br>$'.$prix.'</span>
</div>
**<input type="hidden" name="id" value="'.$id.'"></input>
<a href="Fournisseurs/Videotron.php" onclick="document.forms["form2"].submit(); class="price-option__purchase">Voir</a>**
</div>
</div>
</form>';
}
}
then on the second page, i would take the forfeit id to get the rest of data... if its not clear, you guys can see what im talking about here : http://fournisseursquebec.com/Forfaits.php提交 然后选择互联网...... 谢谢!
答案 0 :(得分:0)
这可能是也可能不是最佳解决方案,但您可以使用会话。 把它放在你的while循环中。
<?php
session_start();
$_SESSION['id'] = $id;
?>
在你的第二张表格上做同样的事情,但要反过来。
<?php
session_start();
$id = $_SESSION['id'];
?>
答案 1 :(得分:0)
我只需将链接转换为按钮即可正常提交。您可能会因为在PHP中连接字符串而遇到html的错误信息。您需要在场景中进行一些转义。这就是你所拥有的:
<!-- wrong--v-----v missing---v -->
<a href="Fournisseurs/Videotron.php" onclick="document.forms["form2"].submit(); class="price-option__purchase">Voir</a>
只需将其更改为按钮或以这种方式提交和设置样式:
include_once("DataBase/db.php");
if($internet->num_rows != 0){
while($rows = $internet->fetch_assoc()){
$nom = $rows["nom"];
$id = $rows["id"];
$tech = $rows["technologie"];
$telechargement = $rows["telechargement"];
$televersement = $rows["televersement"];
$utilisation = $rows["utilisation"];
$prix= $rows["prix"];
?>
<form name="form2" method="POST" action="Fournisseurs/Videotron.php">
<div class="boxes">
<div class="[ price-option price-option--high ]">
<div class="price-option__detail">
<span class="price-option__cost"><?php echo $nom; ?><br>$<?php echo $prix; ?></span>
</div>
<input type="hidden" name="action" value="delete_id" />
<input type="hidden" name="id" value="<?php echo $id; ?>" />
**<div class="price-option__purchase">
<input type="submit" value="Voir" />
</div>**
</div>
</div>
</form>
<?php
}
}
将您的CSS应用于提交按钮。
price-option__purchase input {
background-color: red;
color: #fff;
display: block;
width: 200px;
height: 200px;
}