Jump to content

How to tab text when displaying in php


tipjones

Recommended Posts

Hello,

I am new to php and wanted to know how to tab text when displaying in php! For example, I want to output the following: Hello World    !. After World I want to tab and then print !.  I know in html this can be done by putying \t, I have tired this in php and it didn't work. ANY ADVICE WILL BE A GREAT HELP!!

 

Thanks In Advance

 

Link to comment
Share on other sites

Thanks, 

This helps but when using \t it only allow me to tab once, how do I tab multiple of times. Or is it possile to include multiple spaces. I know in html you can include   how may times you want a space and it will include a space. Also, I know you can inculde" " in php and it will give you one space but if you include "          "it will also give one space which should be about four spaces.

I am trying to output the following but with several spaces in between each heading:

Name:                          Phone:                                      Address:

 

Any help will be a great help!!

Link to comment
Share on other sites

bobleny,

Thanks for the input!! However, I don't understand fully what you mean. Could you give me a in detail example. When I did the following in my code: echo "The big brown\t\t\t\t\t\t\t\t\t\tdog!";

It printed The big brown dog. For some reason it is not printing the multiple tabs I have. What can I do to make it print ALL of the tabs. I really need for this to print with the multiple tabs. PLEASE HELP!

Link to comment
Share on other sites

thorpe,

Thanks for the prompt response. I am looking in my php file b/c there is where I want to echo the statement so in my php file I have echo "The big brown\t\t\t\t\t\t\t\t\t\tdog!"; and only on tab is printing. I have this code between  <?php and ?>.

Link to comment
Share on other sites

thrope,

I am new to this forum and don't know about view source. Hope you can view the source code.

<code>

<body bgcolor="#CCCCCC" text="#000000">

<p align="center"> </p>

<p align="center"><strong><font size="3" face="Georgia"><em><font size="5">GEORGIA</font></em></strong></p>

<p align="center"><strong><font size="3" face="Georgia"><em><font size="5">UNIFORM TRAFFIC CITATION, SUMMONS AND ACCUSATION</font></em></strong></p>

</body>

<?php

 

 

    $dbcnx = @mysql_connect("localhost", "tiffanie",

  "272420");

 

 

if (!$dbcnx) {

    echo( "<p>Unable to connect to the " .

          "database server at this time.</p>"

  );

    exit();

  }

 

 

 

 

  if (! @mysql_select_db("AMDU") ) {

    echo( "<p>Unable to locate " .

          "database at this time.</p>" );

    exit();

  }

 

 

echo('<br>');

//Retrieving values for sect3 of ticket

 

$weather = $_REQUEST['weather'];

$traffic = $_REQUEST['traffic'];

$lighting = $_REQUEST['lighting'];

$road_cond= $_REQUEST['rdcond'];

$road_type = $_REQUEST['rdtype'];

$comvecinfo = $_REQUEST['comvecinfo'];

/*

echo $weather;

echo '<br>';

echo $traffic;

echo '<br>';

echo $lighting;

echo '<br>';

echo $road_cond;

echo '<br>';

echo $road_type;

echo '<br>';

echo $comvecinfo;

echo '<br>';

*/

$sql="SELECT Lic FROM tickets";

$r = mysql_query($sql);

$val = mysql_fetch_assoc($r);

$tempval = $val['Lic'];

 

 

//Entering data from sect3 of ticket into database

$result = mysql_query("UPDATE tickets SET weather = '$weather', traffic = '$traffic', lighting = '$lighting', road_cond = '$road_cond', road_type =

 

'$road_type', comvecinfo = '$comvecinfo' WHERE Lic ='$tempval'");

 

$sql1="SELECT State FROM tickets";

$test = mysql_query($sql1);

$value = mysql_fetch_assoc($test);

$tempval1 = $value['State'];

 

 

$result1 = mysql_query("SELECT Lic,LicClass_Type, Lic_Endorsements, Lic_Expiration,First_Name, Middle_Name,Last_Name FROM $tempval1 WHERE Lic ='$tempval'"); 

//$val1 = mysql_fetch_assoc($result1);

 

 

while ($row = mysql_fetch_array($result1,MYSQL_ASSOC))

{

 

echo 'Name: ' . $row['First_Name'] ."\t".$row['Middle_Name'] ."\t".$row['Last_Name'] ."\t

\t\t\t\t".'License Class: ' .$row['LicClass_Type']. '<br/>' ;

 

 

}//while

 

 

?>

</code>

The output is:Name: Tiffanie Nicole Jones License Class: C

 

Link to comment
Share on other sites

I am new to this forum and don't know about view source.

 

Thats exactly what I am saying. \t affects the outputed source only, not how your output is displayed within your browser. If (when viewing your page within your browser) you right click and go to view source you will see the html output. There you will notice the tabs are in affect.

Link to comment
Share on other sites

tourpe,

This is my view source code:

 

<body bgcolor="#CCCCCC" text="#000000">

<p align="center"> </p>

<p align="center"><strong><font size="3" face="Georgia"><em><font size="5">GEORGIA</font></em></strong></p>

<p align="center"><strong><font size="3" face="Georgia"><em><font size="5">UNIFORM TRAFFIC CITATION, SUMMONS AND ACCUSATION</font></em></strong></p>

</body>

<br>Name: Tiffanie Nicole Jones  Jones<br/>

 

Is there any way to make the multiple tabs show?

Link to comment
Share on other sites

Oh shoot, I screwed up...

 

Thorpes right. That will only effect the source output's display.

 

I just checked the HTML entities, and I don't think there is a way to do tabs. However, you can still use this:

echo "stuf           !";

 

That should do what you want it to do.

 

Mind you, I still think you need to use a different method of displaying data. Such as tables, or css.....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.