Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 30th, 2006, 5:13 AM   #1
seaminem
Newbie
 
Join Date: Jan 2006
Posts: 4
Rep Power: 0 seaminem is on a distinguished road
I'm a beginner. Need help!

What I'm trying to do is that... there are 4 letters on the screen : B M T P... and all of them are links. If I click 'B', the 'B' will be displayed with font size=7 and color = 'red'. The other characters will be displayed in font size = 3 and color = black. ((I'm trying to do an address book.)) But when I click B, seems like there's nothing happen. Please help!

Thank you.

Here is my code:

$FriendName = array (Pink, Bun, Tae, Patty, Tee, Minnie, Pan, Manaw);
$ChooseList = array (B, M, T, P);

print "<BR><BR>";

for ($i=0; $i<count($ChooseList); $i++)

{
if($List == $ChooseList[$i])
print "<a href='Exercise3_3Feb06.php3?List=$ChooseList[$i]&NewerList=$List[$i]'><font size=7 color = red>$ChooseList[$i]</font></a>";
else
if($NewerList == $ChooseList[$i])
print "<a href='Exercise3_3Feb06.php3?List=$ChooseList[$i]&NerwerList=$List[$i]'><font size=3 color = black>$ChooseList[$i]</font></a>";

print " ";
}

Something wrong with this?
seaminem is offline   Reply With Quote
Old Jan 30th, 2006, 8:31 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Please read the forum's rules/FAQ and a "How to Post..." thread. One should check out a community's practices in order to avoid rudeness. These are HTML pages: they eat whitespace. Code not enclosed in tags is an eyesore.

That said, the internet is a client/server paradigm. One should not attempt to achieve true, timely interactions with the server-side PHP code. I recommend you review HTML and CSS. Many (not all) client-side interactions can be achieved in that way. Javascript (often pooh-poohed) can be used for those that can't, although you may have clients with JS disabled.

Incidentally, the font tag has been deprecated. Again, review your CSS.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jan 30th, 2006, 5:58 PM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
As DaWei said, please use [ CODE ] or [ PHP ] tags.

Quote:
Originally Posted by seaminem
[php]print "<a href='Exercise3_3Feb06.php3?List=$ChooseList[$i]&NewerList=$List[$i]'><font size=7 color = red>$ChooseList[$i]</font></a>";[/php]
Here's your problem. when putting array elements or object members in a double-quoted string to be parsed, we have to put braces around them:
[php]$word = 'moo';
$numbers = array(1, 2, 3);
// note it's $word, but {$numbers[1]}:
print "$word {$numbers[1]}"; // prints "moo 2"[/php]
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 30th, 2006, 10:38 PM   #4
Mocker
Hobbyist Programmer
 
Mocker's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 224
Rep Power: 0 Mocker is an unknown quantity at this point
Send a message via AIM to Mocker
Couple more things, this only works if you have register_globals ON , which is usually off for good reason

you would need to change
$List
to
$_GET['List']

Also you mispelled Newer in the second if statement.

Also.. you NewerList doesn't really make sense. To make every other letter agree with that condition you can just use
else {  //print letter in black here
}

NewerList is getting set to List[$i] , but List is set to a single character

which brings me to another thing, you should set the characters in your array in quotations to mark they are characters
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi
freelance scripts - http://ryanguthrie.com/index.html
Mocker is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:30 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC