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
PHP code for "if something exist then show this"
Old 05-11-2008, 12:49 AM PHP code for "if something exist then show this"
Average Talker

Posts: 15
Trades: 0
I am looking for a way to put a "bullet" next to an item if it exist. For instance i have an area for 6 specs for products, but i want a bullet to show up next to the specs when they are listed. I don't want six bullets and only 3 of them have words next to them. Is there a way to make a code to show a bullet only if there is text there?

Thanks
nitinleew is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-11-2008, 01:09 AM Re: PHP code for "if something exist then show this"
Plugin-Developer's Avatar
Weightlifting CS Student

Posts: 504
Name: Nick Ohrn
Trades: 0
Have you looked at using an if conditional statement on whether you have stuff for the specific bullet item and then applying a CSS style based on whether information exists or not?
__________________

Please login or register to view this content. Registration is FREE
- Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
Plugin-Developer is offline
Reply With Quote
View Public Profile Visit Plugin-Developer's homepage!
 
Old 05-11-2008, 04:44 PM Re: PHP code for "if something exist then show this"
Defies a Status

Posts: 2,071
Name: carl
Location: UK
Trades: 0
I dont fully understnd the question your asking but may have read something recently that can help

From the little I understnad Switch statements with CSS could do this (the CSS should let you set a left border to the text with text indent or bullet point)
http://www.tizag.com/phpT/switch.php

If you output the text in a list then the bullet points should be there automatically

Hope this helps - sorry if it doesn't
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by bakerc; 05-11-2008 at 04:50 PM..
bakerc is offline
Reply With Quote
View Public Profile Visit bakerc's homepage!
 
Old 05-11-2008, 04:50 PM Re: PHP code for "if something exist then show this"
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
I guess your returning each as a variable from mysql. Then you would want something like

PHP Code:
if ($variable != 0) {
    print [
html code here]
}

if (
$variable2  != 0)) {
    print [
html code here]

joder is offline
Reply With Quote
View Public Profile
 
Old 05-11-2008, 05:38 PM Re: PHP code for "if something exist then show this"
Novice Talker

Posts: 14
Trades: 0
Quote:
Originally Posted by joder View Post
I guess your returning each as a variable from mysql. Then you would want something like

PHP Code:
if ($variable != 0) {
    print [
html code here]
}

if (
$variable2  != 0)) {
    print [
html code here]

you could also do this with arrays - put all the sql data into an array and if there is no data in that entry then ignore it


PHP Code:

for ($number 1$number 11$number++)

  if { (
$array[$number] != 0) {
    echo [
html code here]
}

[/quote]

but thats getting a bit anal, and i dont even know if you can nest an if statement inside a for loop and pass variables =|
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
localhost8080 is offline
Reply With Quote
View Public Profile
 
Old 05-12-2008, 01:44 PM Re: PHP code for "if something exist then show this"
Average Talker

Posts: 28
Trades: 0
Maybe I'm over simplifying the problem here, but why, exactly, are you not simply creating an unordered list, and each item will organiclly have a bullet next to it, regardless if there is 6, 60, or 6,000?
Cory Dee is offline
Reply With Quote
View Public Profile
 
Old 05-13-2008, 12:03 AM Re: PHP code for "if something exist then show this"
Plugin-Developer's Avatar
Weightlifting CS Student

Posts: 504
Name: Nick Ohrn
Trades: 0
Cory - I think the problem is that he wants some list items to have a bullet next to it and others to not have a bullet, or something like that. I'm not sure if he is actually creating a list or not, quite frankly.
__________________

Please login or register to view this content. Registration is FREE
- Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
Plugin-Developer is offline
Reply With Quote
View Public Profile Visit Plugin-Developer's homepage!
 
Reply     « Reply to PHP code for "if something exist then show this"
 

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 0.37087 seconds with 12 queries