Got problem displaying the below picture and words, what am I doing wrong?
echo "<img src="images/<?php echo $row["image"]; ?>" class="img-responsive" /><br />";
echo "<h4 class="text-info"><?php echo $row["name"]; ?></h4>";
AS you are working in php so you have no need to echo <?php echo $row["image"]; ?> in side an echo and you have to consider about single quotes and double quotes
Do like this
echo "<img src='images/".$row["image"]."' class='img-responsive' /><br />";
echo "<h4 class='text-info'>".$row["name"]."</h4>";
At first you need to use php tag for translating echo tag after do like this..
<?php
echo '<img src="images/echo $row["image"];" class="img-responsive" /><br/>';
echo '<h4 class="text-info"> echo $row["name"]; </h4>';
?>
try this.
echo "<img src='images/'". $row['image']." class='img-responsive' /><br />";
echo "<h4 class='text-info'>".$row['name']."</h4>";
Related
I want add text just below the picture but I don't know how to do it.
<?php
include "includes/connexio_web.php";
obrirConnexioBD();
$sql = "SELECT * FROM Llistat_vies";
$sth = $conn->query($sql);
while($row=mysqli_fetch_array($sth)) {
echo "<tr>";
echo "<td>"; ?>
<img src="<?php echo $row["photo"]; ?>" height="200" width="200"><?php echo "</td>";
echo "<td>"; echo $row["text"]; echo "</td>";
echo "</tr>";
}
?>
Here your code updated.
<?php
include "includes/connexio_web.php";
obrirConnexioBD();
$sql = "SELECT * FROM Llistat_vies";
$sth = $conn->query($sql);
$table= "<table>";
while($row=mysqli_fetch_array($sth)){
$table= "<tr>
<td align='center'>
<img src=".$row["photo"] ." height='200' width='200'> <br>
$row["text"]
</td>
</tr>";
}
print $table . "</table>";
?>
try these new HTML5 tags:
<figure> and <figcaption>
Put your image and text inside these tags like this:
echo "<tr>";
echo "<td>"; ?>
<figure>
<img src="<?php echo $row["photo"]; ?>" height="200" width="200">
<figcaption>
<?php echo $row["text"];
echo "</figcaption>";
echo "</figure>";
echo "</td>";
echo "</tr>";
I am pretending that your <table> and <tr> are outside of the loop.
<table>
<tr>
while($row=mysqli_fetch_array($sth)) {
echo "<td>";
echo "<table>";
echo "<tr>";
echo "<td>";
?>
<img src="<?php echo $row["photo"]; ?>" height="200" width="200">
<?php
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo $row["text"];
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
}
</tr>
</table>
I put tables within the table an inside of a <td> so that they would be next to each other.
I don't know if this is the best way but it was similar to what you were doing and it worked for me. I hope this helps.
My code works good so far, but I want to make each table cell clickable where the real image opens by clicking on it.
How do I do that?
echo "<table>";
$res = "SELECT * FROM table1";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td>";?> <img src=" <?php echo $myRow["image"]; ?>" height="100" width="100"><?php echo "</td>";
echo "</tr>";
}
echo "</table>"
Just wrap the small image in <a> tags
<a href="http://path_to_images/<?=$myRow["image"]?>">
<img src="<?php echo $myRow["image"]; ?>" height="100" width="100">
</a>
echo "<td>";?>
"<a href=" <?=$myRow["image"]; ?>">
<img src=" <?php echo $myRow["image"]; ?>" height="100" width="100" \>"<?php echo "
<a/>
</td>";
Just put <a href=""><a> outside the img?
Having trouble calling up table names row as a Alt attribute
$Linkimg = $row['Linkimg'];
$Name = $row['Name'];
if ($i==0) {
echo "<tr>\n";
}
echo "<td align='center' width='60'>" ;
echo "<img src=\"{$row['Linkimg']}\" alt=\"{$row['Name']}\>" ."</td>";
what am I missing those darn brackets
It's safer to do this:
if($i===0) { ?>
<tr>
<?php } ?>
<td>
<img src="<?php echo $LinkImg; ?>" alt="<?php echo $Name; ?>"/>
</td>
Try this:
echo "<img src=\"{$row['Linkimg']}\" alt=\"{$row['Name']}\">" . "</td>";
Kind of stuck on this one issue, tried all the ways of outputting regular HTML in PHP which works fine, but when trying get PHP code and then making that into HTML link where everything is in PHP. Line 17 & 18 is the issue, this maybe very simple to someone, but its proven difficult for me :(
Any help is much appreciated. Thanks in advance
<?php
if($output == true) {
echo "<td>".$id."</td>";
echo "<td>".$fname."</td>";
echo "<td>".$lname."</td>";
echo "<td>".$dob."</td>";
echo "<td>".$gender."</td>";
echo "<td>".$hnumber."</td>";
echo "<td>".$mnumber."</td>";
echo "<td>".$email."</td>";
echo "<td>".$username."</td>";
echo "<td>".$address."</td>";
echo "<td>".$type."</td>";
echo "<td><a href='memberdelete.php?id=".$rows['ID']."'>Delete</a></td>"; echo "<td><a href='memberedit.php?id=".$rows['ID']."'>Edit</a></td>";
echo "</tr>";
echo "</table>";
}
?>
Change it to,
echo "<td><a href='memberdelete.php?id=".$rows['ID']."'>Delete</a></td>";
Useful: How strings work in PHP ?
Try this, I wrote it quickly, hope it work:
echo '<td>Delete</td>';
echo '<td>Edit</td>';
Horrible enclosing of quotes and multiple echo on same line was your problem.
Update to:
echo "<td><a href='memberdelete.php?id=".$rows['ID']."'>Delete</a></td>";
echo "<td><a href='memberedit.php?id=".$rows['ID']."'>Edit</a></td>";
You can do this for the above code:
<?php
if($output == true) {
echo "<td>".$id."</td>";
echo "<td>".$fname."</td>";
echo "<td>".$lname."</td>";
echo "<td>".$dob."</td>";
echo "<td>".$gender."</td>";
echo "<td>".$hnumber."</td>";
echo "<td>".$mnumber."</td>";
echo "<td>".$email."</td>";
echo "<td>".$username."</td>";
echo "<td>".$address."</td>";
echo "<td>".$type."</td>";
echo "<td><a href='memberdelete.php?id=".$rows['ID']."'>Delete</a></td>";
echo "<td><a href='memberedit.php?id=".$rows['ID']."'>Edit</a></td>";
echo "</tr>";
echo "</table>";
}
?>
You have misplaced the quotes and html tags.so
change
echo "<td>".Delete."</td>";
echo "<td>".<a href="memberedit.php<?php echo '?id='.$rows['ID']; ?>"
to
echo "<td><a href='memberdelete.php?id=$rows[ID]'>Delete</a></td>";
echo "<td><a href='memberedit.php'?id='$rows[ID]'>Edit</a></td>";
If you have problem with quotes and assigning values to parameters inside quotes try HEREDOC
You have incorrect strings.
changes those lines:
echo "<td>".Delete."</td>";
echo "<td>".<a href="memberedit.php<?php echo '?id='.$rows['ID']; ?>"
to:
echo "<td>Delete</td>";
echo "<td><a href=\"memberedit.php<?php echo '?id='.$rows['ID']; ?> </td>"
i have this code in php and it's supposed to print me the image but it isn't.
Is there any problem with this code?
Thanks!
echo "<td> <img src=foto/photo1/".$row['photo'] . "
></td>";
echo "<td> <img src=foto/photo2/".$row['photo2'] . "></td>";
You have missed the ' marks in the echo. Try this:
echo '<td> <img src="foto/photo1/'.$row['photo'].'"></td>';
echo '<td> <img src="foto/photo2/'.$row['photo2'].'"></td>';
Use single quotes ' for image src attribute.
Change your code like this
<img src='foto/photo1/".$row['photo'] ."'></td>