I'm trying to do something different where i need to know if it is possible to work on. I have 2 mysql tables inside a database.
One has random numbers that will connect to another table with ID = number. On the other table I have ID , name , link , height, width.
This height, width is the starting position to a sprites image. Every image inside that sprite has 48px height and width.
So i got the information and i need to work on the data. First try i did this
echo "<img class='small' src=$row2[link] height=$row2[height] width=$row2[width]>";
with no sucess because i forgot that height and width its the actual info for height and width.
I have to do this some times . For my test i have to try 255 times. So it is possible to get the proper image?
for the html i have only this:
<small style="height:48px;width:48px;">
I need to switch the starting position to the css side no?
<?php
$dsn = "mysql:host=localhost;dbname=tournament;charset=utf8";
$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
);
$pdo = new PDO($dsn,'root','', $opt);
$stmt = $pdo->prepare("SELECT * FROM table1");
$stmt->execute();
while($row = $stmt->fetch()) {
foreach ($row as $value) {
$stmt2 = $pdo->prepare("SELECT link , height, width FROM table2 WHERE id = :id");
$stmt2->bindValue(':id', $value);
$stmt2->execute();
while($row2 = $stmt2->fetch()){
echo "<img class='small' src=$row2[link] $row2[height] $row2[width]>";
}
}
}
?>
Best Regards, Paulo