Hello:

I'm trying to print two variables next to each other and I'm running into a problem.

When I run the script, the result should appear as:

text 28%

Instead, I'm getting the following:

28%text

Can someone help me out? I don't understand why it is printing the second variable before the first variable.

Thank you very much.

<font size="2" face="Verdana"><?PHP echo $row['name'] . printf("%d%%",$percent); ?></font> 

    Echo must have a ; as well

    <font size="2" face="Verdana"><?php
       echo $row['name'];
       printf("%d%%",$percent);
    ?></font>

      Thanks for the reply.

      The ; did the trick.

      How do I put blank spaces between the two variables so the result will look like:

      text 28%

      Thanks.

        the reson the original thing did not work, is because when you use a . (dot) it concats the strings that are returned by the functions. whoever printf does not return a string, it outputs it... thus before the starting string was output the second screen was allready pushed to the buffer... what you can do is

        <font size="2" face="Verdana"><?PHP echo $row['name'] , printf("%d%%",$percent); ?></font>
        

        noticed I used a comma instead of a dot
        to put a space in there, you can :

        <font size="2" face="Verdana"><?PHP echo $row['name'] , " " , printf("%d%%",$percent); ?></font>
        

          Thanks for the reply.

          The ," ", for a blank space worked fine.

          What would one do if they wanted more than one blank space? A gap between the two variables.

          Thanks again.

            assuming you are using HTML you can use a non breaking space
            , "&nbsp;&nbsp;" ,

            however often times when you are trying to do formatting you might want to play with tables or other nifty things!

              lol..... it displayed my post instead of displaying what I mean...
              let me try :

              &nbsp;&nbsp

                okay, try the following, but remove the spaces!!!!

                , "& n b s p ; & n b s p ;",
                get it?

                  Hi,

                  The script works as it should.

                  Thank you for all your help. Greatly appreciated.

                  🙂 🙂

                    Write a Reply...