di seguito il codice index.php....
Codice: Seleziona tutto
<?php
require_once 'dbconfig.php';
?>
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body>
<div class="container"><br />
<div class="row">
<?php
$stmt = $DB_con->prepare('SELECT userID, userLink, userPrice, userAddress, userPic FROM tbl_users ORDER BY userID DESC');
$stmt->execute();
if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>
<div class="col-xs-3">
<p class="page-header"> </p>
<?php echo"<a href='detail.php?userId=userID'</a>";?>
<p><img src="user_images/<?php echo $row['userPic']; ?>" class="img-rounded" width="220px" height="180px" /> </p>
<p><span class="page-header"><?php echo $userPrice." / ".$userAddress; ?></span></p>
</div>
<?php
}
}
else
{
?>
<?php
}
?>
</div>
</div>
</body>
</html>
la stringa: <?php echo"<a href='detail.php?userId=userID'</a>";?> mi indirizza all pagina detail.php, il problema e che non riesco a visualizzare i record relazionati allo userId.
qui il codice detail.php
Codice: Seleziona tutto
<?php
// conexão
require_once 'dbconfig.php';
$userID=$_GET['userId'];
$rs = $DB_con->prepare("SELECT * FROM tbl_users where userId=?");
$rs->bindParam(1, $userID);
$rs->execute();
?>
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style></head>
<body>
<?php
while($row = $rs->fetch(PDO::FETCH_OBJ)){
echo "<img src='user_images/$row->userPic'>"."<br /><br />";
echo $row->userPrice." - ";
echo $row->userAddress." - ".$row->userLink."<br /><br />";
}
?>
</body>
</html>
Ringrazio fin da adesso se qualcuno ha la soluzione per me.