Last active
March 2, 2021 23:11
-
-
Save estudijoanpuig/730de05f51b2795abb5ef9544c3d1c46 to your computer and use it in GitHub Desktop.
varis arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//array card no filter | |
<?php | |
include_once("conexio.php"); | |
?> | |
<?php | |
$sql = "SELECT * FROM `eines_web` order by id asc"; | |
$result = $conn->query($sql); | |
if ($result->num_rows > 0) { | |
// output data of each row | |
while($row = $result->fetch_assoc()) { | |
?> | |
<div class="col-md-4"> | |
<div class="card"> | |
<div class="card-body pb-5"> | |
<div class="pt-4 pb-5"> | |
<img src="<?php echo "$row[url_img]";?>" class="img-fluid img-center" style="height: 150px;" /> | |
</div> | |
<a href="<?php echo "$row[url]";?>"> <i class="fas fa-external-link-alt"></i> <h5 class="h4 lh-130 mb-3"><?php echo "$row[titol]";?></h5></a> | |
<a href="<?php echo "$row[url_git]";?>"> <p class="text-muted mb-0"><i class="fab fa-github-alt"></i> <?php echo "$row[descripcio]";?></p></a> | |
</div> | |
</div> | |
</div> | |
<?php } | |
} else { | |
echo "0 results"; | |
} | |
$conn->close(); | |
?> | |
// array | |
<?php | |
$servername = "localhost"; | |
$username = "usuari"; | |
$password = "password"; | |
$dbname = "nom bbdd"; | |
// Create connection | |
$conn = new mysqli($servername, $username, $password, $dbname); | |
// Check connection | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
} | |
$sql = "SELECT * FROM `links_inici_localhost` order by id asc"; | |
$result = $conn->query($sql); | |
if ($result->num_rows > 0) { | |
// output data of each row | |
while($row = $result->fetch_assoc()) { | |
?> | |
element que vull repètir<?php echo "$row[url_img]";?> | |
<?php } | |
} else { | |
echo "0 results"; | |
} | |
$conn->close(); | |
?> | |
// conexio | |
<?php | |
$mysqli = new mysqli("localhost", "usuario", "contraseña", "basedatos"); | |
if ($mysqli->connect_errno) { | |
echo "ERROR al conectar a MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; | |
} | |
echo $mysqli->host_info . "\n"; | |
?> | |
// TAULA | |
<?php | |
$con=mysqli_connect("servidor","usuari","pasword","bbdd"); | |
// Check connection | |
if (mysqli_connect_errno()) { | |
echo "Failed to connect to MySQL: " . mysqli_connect_error(); | |
} | |
$result = mysqli_query($con,"SELECT * FROM producte"); | |
while($row = mysqli_fetch_array($result)) { | |
echo "<tr>"; | |
echo "<td>" . $row['nom_producte'] . "</td>"; | |
echo "<td>" . $row['descripcio_producte'] . "</td>"; | |
echo "<td>" . $row['categoria'] . "</td>"; | |
echo "<td>" . $row['preu'] . "</td>"; | |
echo "<td>" . $row['url_imatge'] . "</td>"; | |
echo "<td>" . $row['url_link'] . "</td>"; | |
echo "<td>" . $row['existencias'] . "</td>"; | |
echo "<td>" . $row['etiquetes'] . "</td>"; | |
echo "<td>" . $row['paypal'] . "</td>"; | |
echo "</tr>"; | |
} | |
mysqli_close($con); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment