php: Simple War script for your website

Forum for anything hard- or software related.

Moderator: Moderators

keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

one more thingie,

Code: Select all


          if ($list->report == " ") {  

            echo " none "; }  

          else {  

        echo "<a href='?id=$list->id'><img src='img/report.gif' border='0'></a>";  

          } 


this code, what does it do? cause i want it like this.. if there is a report

written it shall display the pic, if $report ( or $list->report ) is empty the picture shall be replaced by a no or something, and there shouldnt be a link
Eg har blitt norrbagge :<
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

i dont get ur post :P first u ask something, then u xplain it :P (im not so sober)
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

thats a part of teh cw script and i wonder what i does?



talk later, gotta go
Eg har blitt norrbagge :<
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

Code: Select all


if ($list->report == " ") {  

  echo " none "; }  

else {  

  echo "<a href='?id=$list->id'><img src='img/report.gif' border='0'></a>";  

} 



if $list->report is empty then it will echo the text none. If its not empty then its will display the image report with the hyperlink.
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

ok, that was what i thought about.. but its not working ;<
Eg har blitt norrbagge :<
keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

even if there is no report the picture comes up ;<



i tried to remove the picture and type yes and no

but its still not w0rking ;<
Eg har blitt norrbagge :<
Clement
Master of the Universe
Posts: 743
Joined: Fri Jul 25, 2003 10:27 pm
Location: dk
Contact:

Post by Clement »

instead of


Code: Select all


if ($list->report == " ")



try:


Code: Select all


if ($list->report != "")



and then of course switch the content of the if and the else thingie..
keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

ye it work! but! now all the "non reports" is yes and have a link ;)

it should be the other way.. heh


Code: Select all

          if ($list->report != "") {  

            echo " nop "; }  

          else {  

        echo "<a href='?id=$list->id'>yes</a>";  

          } 
Eg har blitt norrbagge :<
Clement
Master of the Universe
Posts: 743
Joined: Fri Jul 25, 2003 10:27 pm
Location: dk
Contact:

Post by Clement »

Morpher wrote:
and then of course switch the content of the if and the else thingie..


:)



It would look like this then:


Code: Select all


if ($list->report != "") 

            {  echo "<a href='?id=$list->id'><img src='img/report.gif' border='0'></a>"; 

            }  

  else 

            {  

        echo " none "; 

            }

keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

goode ;) you're teh king.. thx
Eg har blitt norrbagge :<
keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

elo again, i have one more question.. i was about to add in the report stuffs, something like "homepage: http://domain.com/clan" or something

but i need to know if there is something i need to make it to a link, or is it

just to write the domain in the fields?





sorry for bad explaniation, ask if you dont uinderstand
Eg har blitt norrbagge :<
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

well diddnt get everything what u said but here goes:



echo "<a href='?id=$list->homepage'>$list->homepage</a>";



i think u mean this ?

or make a replace function
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

nah, i mean more like.. if i want to add the opponents homepage to the report site, and i just write the url.. does it make it as a link automaticlly? then?
Eg har blitt norrbagge :<
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

no it doesnt, but a replace function would do that.



[php]<?php

function auto_link($text) {

RETURN eregi_replace("(http://([a-zA-z0-9_-]+[\.]{1})*[\.]{0,1}[a-z]{2,3})","<a href=\"\\1\" target=\"_BLANK\">\\1</a>",$text);

}

?>[/php]



This will change every link in ur text, other option is that u write the html tag. (<a href='link'>link</a>)
Last edited by Den on Sat Dec 27, 2003 12:51 pm, edited 2 times in total.
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
keffo
hit the ground hard, real hard
Posts: 80
Joined: Sun Dec 21, 2003 9:10 pm
Location: se

Post by keffo »

yess, but i will use it on a form field.. so i dont know how i shall bake it in :(



if you understand.. can you give me some example?
Eg har blitt norrbagge :<
Post Reply