doctorbill
asked on
Using $wpdb to execute queries in mysqli
This code is working perfectly (Thanks Julian)
I was just wondering how I could use the $wpdb class as an alternative to run the code
I was just wondering how I could use the $wpdb class as an alternative to run the code
<style>
#myDiv {
border: thin solid blue;
}
</style>
<script>
function myFunction() {
document.getElementById("myDiv").style.borderColor = "red";
}
</script>
<?php
$servername = "localhost";
$username = "xxxx";
$password = "xxxx^";
$dbname = "xxxx";
$search= $_POST['xxx'];
//Create Connection
$conn = new mysqli($servername, $username, $password, $dbname);
//Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// $sql = "SELECT id, image FROM MV0vqu9WQ_nextend2_image_storage WHERE( ( id >= 3 ) AND ( id <= 20 ) )";
$sql = "SELECT id, image FROM MV0vqu9WQ_nextend2_image_storage WHERE( id IN (3,4,5) )";
$result = $conn->query($sql);
if($result->num_rows > 0) {
//output data of each row
while($row = $result->fetch_assoc()) {
$imagePath = str_replace('$upload$', 'https://www.alibema.com/wp-content/uploads/', $row['image']);
echo <<< HTML
<div id="myDiv"><img src="{$imagePath}" ><button type="button" onclick="myFunction()">Change color of the four borders</button></div>
HTML;
echo "<hr>";
echo "Image ID : ". $row['id'];
}
} else {
echo "0 results";
}
$conn->close();
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window