Am incercat sa fac select-ul id-ului din primul tabel al utilizatorului si sa selectez numarul de servicii din al doilea tabel, dar nu functioneaza.
Cod: Selectaţi tot
<?php
$user=$_SESSION['username'];
$servername = "localhost";
$username = "";
$password = "";
$dbname = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql2 = "SELECT memberID FROM members where username = $user";
$result = $conn->query($sql2);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$member2ID=$row["memberID"];
}
} else {
echo "0 results";
}
$conn->close();
$servername = "localhost";
$username = "";
$password = "";
$dbname = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT nr FROM servicii where idu = $member2ID";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$numar=$row["nr"];
}
} else {
echo "0 results";
}
$conn->close();
?>