donboe
November 2, 2013, 5:38pm
1
My PHP knowledge is not very good and I am already trying things for hours without any results. The problem is this. I have a echo with a hard coded url:
echo "<a class='fancybox' data-fancybox-group='gallery' href='http://diem.sothenwhat.com/museum_photos/photos/" . $row->photo . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
For certain reasons I need the href property: [B]http://diem.sothenwhat.com/museum_photos/photos/[/B] to come from the database! So in the database I created a new field called link .and placed the [B]http://diem.sothenwhat.com/museum_photos/photos/[/B] into that field and changed the echo into:
echo "<a class='fancybox' data-fancybox-group='gallery' href='$link" . $row->photo . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
but that isn’t working. Can someone please help me out with this?
Thank you in advance!!!
Where do you give $link it’s value?
If your retrieved database data is stored in $row, and assuming you updated your query to retrieve the link column as well, my guess is you’ll need to echo $row->link
donboe
November 7, 2013, 7:36pm
4
I need to change the href based on a certain id. Thi is what I have right now:
while ($row = $stmt->fetchObject()) {
$imgString .= "<a class='fancybox' data-fancybox-group='gallery' href='$row->link" . $row->photo . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
}
echo $imgString;
When the photo id is for example 10 the
href='$row->link" . $row->photo
echo should not include $row->photo but just $row->
How would I do that? Thank you in advance
donboe
November 7, 2013, 8:19pm
5
I tried this:
while ($row = $stmt->fetchObject()) {
$imgString .= "<a class='fancybox' data-fancybox-group='gallery' href='$row->link" . $row->photo . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
}
if ($photo_id == 74){
$imgString += "<a class='fancybox' data-fancybox-group='gallery' href='$row->link" . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
}
echo $imgString;
I dont get an error but it isn’t working either.
donboe
November 8, 2013, 9:05am
6
I am trying for hours but without success. Is it possible to have a if else statement within the href tag e.a.
$imgString .= <a if ($photo_id == 74) { href=‘http://www.youtube.com/watch?v=IC9wzNu-k3E ’>} else { <a href=‘$row->link" . $row->photo . "’>}
Or something similar?
Thank you in advance
while ($row = $stmt->fetchObject()) {
if ($photo_id == 74){
$imgString += "<a class='fancybox' data-fancybox-group='gallery' href='$row->link" . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
} else {
$imgString .= "<a class='fancybox' data-fancybox-group='gallery' href='$row->link" . $row->photo . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
}
}
donboe
November 8, 2013, 11:46am
8
Hi Guido. I tried your suggestion but it isn’t working. Have a look at the site . Click on the tab Porsche at the bottom. l The middle image you see is the one that should open a youtube movie instead of a larger image. But when you roll over the image you’ll see still the row photo after the actual link. What should I do to avoid that?
Thank you
I saw it for a moment, but the next time i clicked on porsche, the .jpg part disappeared. So I guess you got it to work?
donboe
November 8, 2013, 12:15pm
10
Hi Guido no it isn’t working. I made a mistake in the echo; Please have a look now. The photo extension is there again?
Are you sure $photo_id contains the value of the photo id? Maybe it should be $row->photo_id ?
donboe
November 8, 2013, 12:35pm
12
Hi Guide. You’re absolutely right. This is what I have now:
while ($row = $stmt->fetchObject()) {
if ($row->photo_id == 74){
$imgString .= "<a class='fancybox-media' href='$row->link" . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
} else {
$imgString .= "<a class='fancybox' data-fancybox-group='gallery' href='$row->link" . $row->photo . "'><img src='http://diem.sothenwhat.com/museum_photos/carousel/" . $row->photo . "' /></a>";
}
}
and it is working great. Thanks a lot!!!