so basicaly my conundrum is folowing:
I have a database like this:
Word | imgUrl | imgSize
volvo | C:\Users\..| 15
And I have an array like this:
$cars = array("Volvo", "BMW", "Toyota");
I need PHP to compare what in the array with whats in the database column Word , then retrieve a corresponding value of imgURL for the column value and store it in a variable $img
.
Then I have this functionality prepared to run the rest of my program:
$size = 100;
$lines = file_get_contents(basename($_FILES["fileToUpload"]["name"]), FILE_USE_INCLUDE_PATH);
$words = explode(" ", $lines);
$words = array_splice($words, 0, count($words));
$img = Database entry
foreach ($words as $x => $word) {
print '<div class="result" style="position: relative; float: left;
width:' . $size . 'px; margin: 5px; height:' . $size . 'px;
background-image:url('. $img .'); background-size: 100% 100%;">
<a id="word' . $x . '">' . $words[$x] . '</a></div>';
}
As you can see, I am trying to put each word of an array into a separate <div>
and then display it. All works well, I just need to show the corresponding img to the word as the background of the <div>
Anyone has any idea ? Any and all suggestions appreciated!
Cheers