Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
HREF-Link in a "for-loop" doesn't work
Old 06-08-2010, 04:10 AM HREF-Link in a "for-loop" doesn't work
Junior Talker

Posts: 2
Name: Gregor Koch
Trades: 0
Hi,

I have a problem, first I will show you the code, then I will explain, what the code should do, finally I tell what it does .

Code:
<?php

for ($loop = 1; $loop <=2; $loop+=1)
{
$hammer = '.jpg';
echo $loop;
echo "<br>";
$sigma = $loop.$hammer;
echo "<a href src='$sigma' target='new'><img src='$sigma' width='200'></a>";
echo "<br><br>";
}
?>

It should do:
I want to create a column of thumbs, where each of those opens the according picture. So the pro would be, that for a lot of pictures we do not have to write every time "<a href...></a>", instead we just write "loop<=1000".

It does:
This code opens every time you click on a thumb the whole php-data again (blabla.php) in a new window, not only the picture itself.

So... can you please tell me where the mistake is???

THANKS A LOT!
Gregor
Gregor is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-08-2010, 05:30 AM Re: HREF-Link in a "for-loop" doesn't work
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Don't anything strike you as wrong here?
HTML Code:
<a href src='$sigma' target='new'>
What happens is that the browser see that the link do not have a valid href value, so it opens the same page again.

It was the 1st thing to check, and you missed it.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-08-2010, 06:09 AM Re: HREF-Link in a "for-loop" doesn't work
Junior Talker

Posts: 2
Name: Gregor Koch
Trades: 0
Hey Tripy,

thank you. I guess you'd not believe, but I check the code for about two hours before I posted it today. So stupid... THANKS A LOT!
Gregor is offline
Reply With Quote
View Public Profile
 
Old 06-08-2010, 06:11 AM Re: HREF-Link in a "for-loop" doesn't work
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Oh yeah, I believe it.
Sometime I too need another brain to see where the errors are...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to HREF-Link in a "for-loop" doesn't work
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.23640 seconds with 12 queries