Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Junior Member Tonic's Avatar
    Join Date
    Jan 2004
    Posts
    25
    Member #
    4684
    I am creating a phone book project in php/mySQL just for some coding practices.

    I would like to know how to display an image (home, cell, work, business icons etc) upon a certain word stored, and retrieved from the datase - SO... say I have a row of information like:

    Name: Ben || Number: 1(###)###-#### || Type:[Image of phone number Type].

    I would have a form to add a phone number include a drop down box, with the selection for work, home, cell ETC and store the word into the database. Is there a way to have some code output a certain image if the word in the database matches the corresponding image?

    sorry... this is probably not the best way to do it, if not any other suggestions on doing so?

    Perhaps a boolean system for images. I dunno.

  2.  

  3. #2
    Member
    Join Date
    Jan 2005
    Posts
    97
    Member #
    8727
    I am confused, please explain further. By my understanding of what you said you have 3 columns, and each row in the column has a CHAR(1) value depending on the phone number type.

    Of course, I assume I'm wrong.

  4. #3
    Junior Member Tonic's Avatar
    Join Date
    Jan 2004
    Posts
    25
    Member #
    4684
    Quote Originally Posted by n3on
    I am confused, please explain further. By my understanding of what you said you have 3 columns, and each row in the column has a CHAR(1) value depending on the phone number type.

    Of course, I assume I'm wrong.
    That was just a vague example, I'll try to clear it up a bit more.

    I have 5 rows of data:
    numberid, which is obviously the ID
    first_name, char(60)
    last_name, which is also is a 60 character type
    phone_number (I actually have a space for country code, area code, etc)
    and the last one
    type char(12).

    when I add a phone number to my database (through the web, using forms) I will have a dropdown menu for number type (type). the values of the form drop down would be: cell, home, business, and work. Upon creation of phone listing, it will insert the designated type into the type field of the database. For example:

    If I were to add a cellular phone number, I would select appropreate information, and on the type field, I'd select cell phone. When I submit the form to execute my script, it will than insert the characters 'cell' into the 'type' field. I would like to have a system that I could use: If type='cell' display 'images/cell.gif' Like that. I just need to know the proper coding.

  5. #4
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    You can either store the HTML itself directly in the table (i.e. if the request asks for 'Ben', and he has a cell phone, then that is automatically displayed, because the 'type' cell holds all the neccessary HTML info to display a cell-phone-image. (i've used that in a thumbnail preview table).

    Else, you could withdraw a keyword (like "cell", "home", etc) from that column, and run it through a "case/switch" filter.

    Are you familiar with case/switch ?
    S. Rosland

  6. #5
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    Yep, case/switch is the easiest way.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  7. #6
    Junior Member
    Join Date
    Apr 2005
    Posts
    6
    Member #
    9663
    Hi, probably already answered but I will at my voice anyway.

    Just do an If statement. if($number_type == 'mobile') { echo "<img src="mobile.jpg"; } else if ($number_type == 'business') { echo "<img src="business.jpg"; } etc. etc. where $number_type is the value pulled of the database.

    I had a similar sort of problem when i was first doing PHP MySQL sites. I was absolutly baffled by the problem, but it really is very simple.

    Nickuss.

  8. #7
    Junior Member
    Join Date
    Apr 2005
    Posts
    6
    Member #
    9663
    excuse my sloppy code.

  9. #8
    Junior Member Tonic's Avatar
    Join Date
    Jan 2004
    Posts
    25
    Member #
    4684
    Thanks for all the help, I apprechiate everything. I've now got 3 ways to do it! !!! great stuff.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:23 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com