• Is there a syntax to insert a tag in the fwrite( $output, $LastName . “, ” . $FirstName ); to make it bold? ie

    
    <strong>Abraskin, Jo Anne</strong> 
    (H) n/a
    (C) 845/901-0373
    409 Crystal Hill Lane
    Poughkeepsie, NY 12603
    [email protected]
    5204216
    CUNY Richmond College, BA
    Columbia Univ., MA
    $LastName = $row['LastName'];
    	$FirstName = $row['FirstName']."\n";
    	$HomePhone = "(H) " .$row['HomePhone']."\n";
    	$CellPhone = "(C) " .$row['CellPhone']."\n";
    	$Address1 = $row['Address1']."\n";
    	$City = $row['City'];
    	$State = $row['State'];
    	$Zip = $row['Zip']."\n"; 
    	$Email = $row['Email']."\n";
    	$ID = $row['ID']."\n";
    	$College1 =$row['College1']."\n";
    	$College2 =$row['College2']."\n";
    	$College3 =$row['College3']."\n";
    		
    	$output = fopen('php://output', 'w');
    	fwrite( $output, $LastName . ", " . $FirstName  );
    	fwrite( $output, $HomePhone); 
    	fwrite( $output, $CellPhone); 
    	fwrite( $output, $Address1); 
    	fwrite( $output, $City . ", " .  $State  . " " . $Zip );
    	fwrite ( $output, $Email ); 
    	fwrite ( $output, $ID ); 
    	fwrite ( $output, $College1 );
    	fwrite ( $output, $College2 );
    	fwrite ( $output, $College3 );
    

Viewing 14 replies - 1 through 14 (of 14 total)
  • fwrite( $output, . "<strong>" . $LastName . ", " . $FirstName . "</strong>" );

    Thread Starter hsysgrp

    (@hsysgrp)

    Thank you, but sorry, I had tried that. error is:
    [03-Aug-2021 15:08:59 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE option_name = 'jetpack_sync_full_status' LIMIT 1' at line 1 for query SELECT option_value FROM WHERE option_name = 'jetpack_sync_full_status' LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Automattic\Jetpack\Sync\Sender->do_full_sync, Automattic\Jetpack\Sync\Modules\Full_Sync_Immediately->get_status, Jetpack_Options::get_raw_option
    Seems a bit of overkill for one tag.

    If this works:
    $HomePhone = “(H) ” .$row[‘HomePhone’].”\n”;
    then use the same approach:

    $LastName = "<strong>" .$row['LastName']."</strong>\n";
    $FirstName = "<strong>" .$row['FirstName']."</strong>\n";
    Thread Starter hsysgrp

    (@hsysgrp)

    Result after removing first linefeed,

    $LastName = "<strong>" .$row['LastName']."</strong>;
    $FirstName = "<strong>" .$row['FirstName']."</strong>\n";

    Axxxxxx, Jo Anne
    (H) n/a
    (C) 845/xxx-0373
    666 Crystal Hill Lane

    • This reply was modified 4 years, 10 months ago by bcworkz.
    Moderator bcworkz

    (@bcworkz)

    Appears to be resolved, but FWIW…

    There is a syntax error in Corrina’s first suggested code, there should be no dot operator after $output,. That’s a very strange error message due to a syntax error! Probably due to some strange Jetpack error handling.

    Because PHP will concatenate variable values in double quoted strings, you could just do:
    fwrite( $output, "<strong>$LastName, $FirstName</strong>\n" );
    Just FYI, there’s no harm in sticking with what you have working.

    I’ll go ahead and mark this topic as resolved for you. It remains open if you have anything to add.

    Thread Starter hsysgrp

    (@hsysgrp)

    No, it’s not resolved, the output is
    `Axxxx, Jo Anne
    (H) n/a
    (C) 8xx/901-0373
    xxx Crystal Hill Lane

    the “” prints instead of executing from the following:.
    $LastName = “
    ” . $row[‘LastName’] . ““;
    $FirstName = “” . $row[‘FirstName’] . “” . “\n”;

    fwrite( $output, $LastName . “, ” . $FirstName );

    Thread Starter hsysgrp

    (@hsysgrp)

    Sorry, I see I have to put these statements in code for the strong to not execute in the message!

    $LastName = "<strong>" . $row['LastName'] . "</strong>";
    $FirstName = "<strong>" . $row['FirstName'] . "</strong>" . "\n";

    fwrite( $output, $LastName . ", " . $FirstName );

    The output is

    <strong>Axxxxx</strong>, <strong>Jo Anne</strong>
    (H) n/a
    (C) 845/xxx-0373
    888 Crystal Hill Lane
    Poughkeepsie, NY 12603
    a
    • This reply was modified 4 years, 10 months ago by bcworkz.
    Thread Starter hsysgrp

    (@hsysgrp)

    The first line in the above submission is NOT in bold. In the Notepad output file it reads in normal print Axxxxx, Jo Anne

    Moderator bcworkz

    (@bcworkz)

    OK, not resolved. I’m not sure I follow what you’re after. The output you’re getting is functionally equivalent to what you said you wanted in you OP, other than the comma isn’t bold. Aren’t you writing to the PHP output buffer? How does Notepad fit into the picture? Buffer content eventually ends up in a browser client.

    It’s not necessary to fwrite() to the output buffer. A more conventional approach is to start the buffer with ob_start(). Then your code can generate output as normal with echo and similar and it’ll go to the buffer instead of out to the client. And if buffer content is not going to be processed further, why buffer at all? Why wouldn’t you simply echo everything directly?

    Thread Starter hsysgrp

    (@hsysgrp)

    The page is https://hsysgrp.com/download-data/. Subpages download data like birthdays this month, etc. most of the data is downloaded in csv format, however this data is downloaded to directory.txt, as it gets copied into a Word template to go to the printer. I am trying to print the first line of each entry in bold. I know NotePad can do Bold if you set the Font to Bold but then it’s all Bold.
    What gets downloaded into the directory.txt file is
    Axxxxx, Jo Anne
    (H) n/a
    (C) 845/xxx-0373
    888 Crystal Hill Lane
    Poughkeepsie, NY 12603

    $LastName = "<strong>" . $row['LastName'] . "</strong>";
    $FirstName = "<strong>" . $row['FirstName'] . "</strong>" . "\n";

    fwrite( $output, $LastName . “, ” . $FirstName );

    Thread Starter hsysgrp

    (@hsysgrp)

    It did it again, my question bolds the first line, put the downloaded file does not.

    <strong>Txxxxx</strong>, <strong>Frances H</strong>
    (H) 845/xxx-8892
    (C) 845/xxx-2091
    243 Traver Road
    Pleasant Valley, NY 12569
    [email protected]
    5369070
    SUNY New Paltz BSN
    Mount St. Mary MSN
    Moderator bcworkz

    (@bcworkz)

    You cannot font weight specific content in a .txt file. You’d need to create a differently formatted document like .rtf or .docx. I don’t think Notepad will even properly display such formats, you’d need to use Wordpad, Word or similar. These formats are not trivial to manually code, but there are conversion libraries that’ll convert something that’s easier to code like Markdown.

    Dion

    (@diondesigns)

    If you want to view the HTML you’re writing out to a file, then name the file directory.html and manually load it into your browser using the Ctrl-O hotkey. (Note that you might need to add <br> tags, both to view and for the import to Word.)

    Thread Starter hsysgrp

    (@hsysgrp)

    OK, thank you.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘header using fwrite’ is closed to new replies.