Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    98
    Thanks
    12
    Thanked 3 Times in 3 Posts

    How to display specific variables on a page?

    I am categorizing comic book issues through a PHP variable, and I need to know how to display a specific variable on a page:
    PHP Code:
    $bp '<p><b>Black Panther</b></p><p>
    Black Panther #18<br><br>
    Black Panther #22<br><br>
    Black Panther #31</p>'
    ;
    $cd '<p><b>Cable & Deadpool</b></p>
    <p>Cable & Deadpool #6<br><br>
    Cable & Deadpool #7<br><br>
    Cable & Deadpool #8<br><br>
    Cable & Deadpool #9</p>' 
    Now, I'd like to then create a new page and split B from C and also display only the variable $cd and vice versa...how would I do that? I am a complete n00b at PHP so please talk in baby talk. I would like to also "categorize" these variables such as $cd would be 'ongoing' and let's say $bp would be a mini-series. Then I could display only a certain variable such as 'ongoing' and it'd only show the variables categorized as 'ongoing.' Is there such a way?

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    you would need to use the command echo.

    PHP Code:
    $bp '<p><b>Black Panther</b></p><p> 
    Black Panther #18<br><br> 
    Black Panther #22<br><br> 
    Black Panther #31</p>'

    $cd '<p><b>Cable & Deadpool</b></p> 
    <p>Cable & Deadpool #6<br><br> 
    Cable & Deadpool #7<br><br> 
    Cable & Deadpool #8<br><br> 
    Cable & Deadpool #9</p>'
    ;

    echo 
    $bp;

    echo 
    $cb
    Merry Christmas

  • Users who have thanked mic2100 for this post:

    aimerzz4 (12-28-2007)

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by aimerzz4 View Post
    I am categorizing comic book issues through a PHP variable, and I need to know how to display a specific variable on a page:
    how mic2100 allready say, use echo

    PHP Code:
    $bp '<p><b>Black Panther</b></p><p>
    Black Panther #18<br><br>
    Black Panther #22<br><br>
    Black Panther #31</p>'
    ;
    $cd '<p><b>Cable & Deadpool</b></p>
    <p>Cable & Deadpool #6<br><br>
    Cable & Deadpool #7<br><br>
    Cable & Deadpool #8<br><br>
    Cable & Deadpool #9</p>' 
    Now, I'd like to then create a new page and split B from C and also display only the variable $cd and vice versa...how would I do that? I am a complete n00b at PHP so please talk in baby talk. I would like to also "categorize" these variables such as $cd would be 'ongoing' and let's say $bp would be a mini-series. Then I could display only a certain variable such as 'ongoing' and it'd only show the variables categorized as 'ongoing.' Is there such a way?
    I don't understand what do you want to do, what do you mean by "split B from C", "categorize", what is "ongoing", maybe if you give an example of what do you want I could help you.

    happy holydays.

  • #4
    New Coder
    Join Date
    Jun 2007
    Posts
    98
    Thanks
    12
    Thanked 3 Times in 3 Posts
    Thanks guys. I'll try this out right now. I'll get back to you, oesxyl, so I can explain it better. Lol

  • #5
    New Coder
    Join Date
    Jun 2007
    Posts
    98
    Thanks
    12
    Thanked 3 Times in 3 Posts
    Yeah, Okay, I used the echo command and see, I have a whole ton of variables on this PHP file.

    You can see it here:
    http://emmafrostfiles.com/appearancesa.php

    I only want to display $axm ....when I use the echo command, it not only displays $axm but it also displays all the rest of the variables. How do I get it so that it only displays $axm ?

  • #6
    Regular Coder
    Join Date
    Apr 2003
    Location
    Montreal, QC
    Posts
    340
    Thanks
    3
    Thanked 2 Times in 2 Posts
    What's the line of the code that does the echoing? Do display $axm it should read:
    PHP Code:
    echo $axm
    Also, can you show us the variable $axm? I'm wondering if there's a problem with quotation marks.
    Search for Laughter or Just Search?
    GiggleSearch.org
    Blog: www.johnbeales.com
    All About Ballet: www.the-ballet.com

  • #7
    New Coder
    Join Date
    Jun 2007
    Posts
    98
    Thanks
    12
    Thanked 3 Times in 3 Posts
    PHP Code:
    $axm '<p><b>Astonishing X-Men</b></p>
         <p>Astonishing X-Men #1<br><br>
          Astonishing X-Men #2<br><br>
          Astonishing X-Men #3<br><br>
          Astonishing X-Men #4<br><br>
          Astonishing X-Men #5<br><br>
          Astonishing X-Men #6<br><br>
          Astonishing X-Men #7<br><br>
          Astonishing X-Men #8<br><br>
          Astonishing X-Men #9<br><br>
          Astonishing X-Men #10<br><br>
          Astonishing X-Men #11<br><br>
          Astonishing X-Men #12<br><br>
          Astonishing X-Men #13<br><br>
          Astonishing X-Men #14<br><br>
          Astonishing X-Men #15<br><br>
          Astonishing X-Men #16<br><br>
          Astonishing X-Men #17<br><br>
          Astonishing X-Men #18<br><br>
          Astonishing X-Men #19<br><br>
          Astonishing X-Men #20<br><br>
          Astonishing X-Men #21<br><br>
          Astonishing X-Men #22<br><br>
          Astonishing X-Men #23<br><br>
          Astonishing X-Men #24<br><br>Giant Sized Astonishing X-Men #1</p>'
    ;
    $bp '<p><b>Black Panther</b></p><p>
    Black Panther #18<br><br>
    Black Panther #22<br><br>
    Black Panther #31</p>'
    ;
    $cd '<p><b>Cable & Deadpool</b></p>
    <p>Cable & Deadpool #6<br><br>
    Cable & Deadpool #7<br><br>
    Cable & Deadpool #8<br><br>
    Cable & Deadpool #9</p>'

    That's part of the file ^^^. I'd like to use this
    PHP Code:
    <?php include 'allapp.php';
    echo 
    $axm ?>
    And display just the $axm variable, not all the others.

  • #8
    Regular Coder
    Join Date
    Apr 2003
    Location
    Montreal, QC
    Posts
    340
    Thanks
    3
    Thanked 2 Times in 2 Posts
    I took another look at the link you posted, and it looks like the whole allapp.php file is getting echoed, then $axm is getting echoed again at the end.

    I'm thinking that there must be something in allapp.php echoing all of the variables, then your 'echo $axm;' is doing its job properly, making the "Astonishing X-men" section appear twice.

    Look at the end of allapp.php and see what else is there. I'm guessing you'll find some sort of echo or print command.

    If you want to try removing stuff without messing around with the file too much just comment the sections out:
    PHP Code:
    // the two slashes comment out a single line
    /*  the slash then * comment out several lines
    this is still part of the same comment
    end the comment with a * then a slash, like this:  */ 
    Search for Laughter or Just Search?
    GiggleSearch.org
    Blog: www.johnbeales.com
    All About Ballet: www.the-ballet.com

  • #9
    New Coder
    Join Date
    Jun 2007
    Posts
    98
    Thanks
    12
    Thanked 3 Times in 3 Posts
    Oh, you know what...I fixed it guys. I had a whole bunch of echos in the allapp.php

    As for the other question I had, is there a way I can...hmm...

    Like

    $axm, $bp, $cd = $ongoing

    So if echoed the variable $ongoing, it would display $axm, $bp, and $cd. Know what I mean?

    ETA: That was exactly the problem jonny, thanks!

  • #10
    Regular Coder
    Join Date
    Apr 2003
    Location
    Montreal, QC
    Posts
    340
    Thanks
    3
    Thanked 2 Times in 2 Posts
    For your new question:
    PHP Code:
    $ongoing $axm $bp $cd (etc...); 
    The . combines strings. You don't need the spaces like I've shown above, but it makes it easier to read.
    Search for Laughter or Just Search?
    GiggleSearch.org
    Blog: www.johnbeales.com
    All About Ballet: www.the-ballet.com

  • #11
    New Coder
    Join Date
    Jun 2007
    Posts
    98
    Thanks
    12
    Thanked 3 Times in 3 Posts
    Thank you!

    ...And another dumb question, I completely forgot to center the allapp.php ....is there a way I can do this thru

    PHP Code:
    <?php include 'allapp.php';
    echo 
    '<p class="center">$axm</p>' ?>
    Now that obviously doesn't work, but is there way I can center thru that code?

  • #12
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    try to use data structure as that:
    PHP Code:
    $baxm = array('Astonishing X-Men' => array ('#1''#2', ...),
        
    'Giant Sized Astonishing X-Men' => array( '#1'),
        
    'Black Panther' => array('#18''#22''#31'),
        
    'Cable & Deadpool' => array('#6''#7''#8''#9')
    );

    echo 
    $baxm['Black Panter'][2]; 
    or maybe a database, that's depend of your abillity to work with php,

    that's could be 'categorize'?

    best regards

  • Users who have thanked oesxyl for this post:

    aimerzz4 (12-28-2007)

  • #13
    New Coder
    Join Date
    Jun 2007
    Posts
    98
    Thanks
    12
    Thanked 3 Times in 3 Posts
    That's confusing, but I have to go now. I'll get back to you. Thanks a lot guys!

  • #14
    Regular Coder
    Join Date
    Apr 2003
    Location
    Montreal, QC
    Posts
    340
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by aimerzz4 View Post
    Thank you!

    PHP Code:
    <?php include 'allapp.php';
    echo 
    '<p class="center">$axm</p>' ?>
    Now that obviously doesn't work, but is there way I can center thru that code?
    Do it like this:
    PHP Code:
    echo '<p class="center">'.$axm.'</p>'


    oesxyl is suggesting that having everything in big variables in a PHP file is not the most convenient way to store your data. It'll be a real pain to change things later on and it's much more flexible to store it in an Array or a Database. If you want to learn more about Arrays check out the PHP Manual Array Page.
    Search for Laughter or Just Search?
    GiggleSearch.org
    Blog: www.johnbeales.com
    All About Ballet: www.the-ballet.com

  • #15
    New Coder
    Join Date
    Jun 2007
    Posts
    98
    Thanks
    12
    Thanked 3 Times in 3 Posts
    You know with something like that, I might as well just hire someone! Thanks!


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •