How can I bold HTML text in an array using PHP? [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have this small piece of code
<?php
foreach ($options['attributes_info'] as $attribute) :
?>
<?php
echo '<br/> ' .
$this->getPdfHelper()->fixEncoding(
$attribute['label'] . ': ' . $attribute['value']
)
?>
<?php
endforeach;
?>
How can I bold (HTML tag <b>) the 'value' that is echoed?

<?php foreach ($options['attributes_info'] as $attribute) : ?>
<?= $this->getPdfHelper()->fixEncoding($attribute['label']) ?> : <b><?= $this->getPdfHelper($attribute['value']) ?></b>
<?php endforeach; ?>

You can wrap the text with the tag.
<p><b>This text is bold</b>.</p>
http://www.w3schools.com/html/html_formatting.asp

You can simply surround it with the tag:
'<b>' . $attribute['value'] . '</b>'

Related

Cannot load a base64 encoded image from mysql database using php [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 months ago.
Improve this question
I have a longblob field in mysql database that stores a binary value for a image that i uploaded through my webpage.
I am trying to get the image using
<?php while( $record = mysqli_fetch_assoc( $result ) ): ?>
<div>
<?php echo '<img src="data:image/jpeg;base64,'.base64_encode($record['image']).'"height="300" width="300"/>'?>
<br/>
<?php echo "Title:".htmlentities( $record['title'] ); ?>
<br/>
<?php echo "Genre:".htmlentities($record['genre']); ?>
<br/>
<?php echo "Author:".htmlentities( $record['author'] ); ?>
<br/>
Edit</i>
<br/>
<a href="books.php?delete=<?php echo $record['id']; ?>"
onclick="javascript:confirm('Are you sure you want to delete this project?');" style="color:#1217b3">Delete</i></a>
</div>
<?php endwhile; ?>
and img tag looks like this in html
<img src="data:image/jpeg;base64,MlN0YXRlLmpwZw==" height="300" width="300">
You have base64 encoded the image file name not the file contents
MlN0YXRlLmpwZw==
actually outputs:
2State.jpg
When storing it in the database you need to do
$imageContent = base64_encode(file_get_contents($file));

Show image only if jsonObj has a value [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
If <?php echo $jsonObj->data->image; ?> has a value, like 1234.jpg I want to show this:
<img src="https://www.example.com/img/<?php echo $jsonObj->data->image; ?>" />
If <?php echo $jsonObj->data->image; ?> has no value, then <img src="https://www.example.com/img/<?php echo $jsonObj->data->image; ?>" /> should remain hidden.
Any help please?
Use php if-else statement for that.
<?php
if(!empty($jsonObj->data->image)) {
?>
<img src="https://www.example.com/img/<?php echo $jsonObj->data->image; ?>" />
<?php
}
?>
You can add else part and do whatever you want.

How to print Table of this format [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have following data in mysql, and I want to echo in this format:
Data:
Name,Image URL,Link
I want to print it dynamically like this : http://screensaver.cf/screensavers.php
I don't know user's screen width, still I want it to appear as much as possible in width.
How can I do this in html and PHP?
My code:
<?php
require("config.php");
?>
<div id="main-wrap">
<div class="container">
<div id="main">
<div id="content"><div id='wsite-content' class='wsite-elements wsite-not-footer'>
<div class="paragraph" style="text-align:left;">
<?php
$sql='SELECT * FROM `games` where 1=1';
$data = mysql_query($sql);
echo '<h4 class="result">Result:</h4>';
while($row = mysql_fetch_row($data)){
$table=WHAT TO DO HERE TO MAKE IT LOOK LIKE THAT???????
echo $table;
echo '<br><br>';
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
include("footer.php");
?>
P.S I know mysql is depreciated and I am constantly working to learn Mysqli, as I am in 8th class, I don't have much time.
<style>.a{float:left;}
</style>
>
in while loop use this
<div class = "a">
<?php <img src='".$row['url']."' width='140' height='140'> ?>
</div>

How to change this to HTML from PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i want to change this into html format
echo " http://somedomain/somepath/usn_handler.php?usn='" . $row['usn'] .
"' >" . $row['usn'] . " ";
This will work
?>
link
<?php
If you are just making a link to the same domain omit the full URL
?>
link
<?php
Assuming you want to make a hyper link. But really you should just google first.
I think you mean something like this :
<div>
http://somedomain/somepath/usn_handler.php?usn=<?php echo $row['usn']; ?>' >" <?php echo $row['usn']; ?>
</div>
or :
<div>
<a src="http://somedomain/somepath/usn_handler.php?usn=<?php echo $row['usn']; ?>" > <?php echo $row['usn']; ?></a>
</div>

How can I make a $function echo <div> PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Hey I have a question that I can not seem to figure out, how can I make a $function echo a html markup like this code:
<div style="color: purple;">Hello</div>
I can not seem to get it. Here is the code I am using is not working:
$contactUs = echo <div style="color: green;">click here</div>;
How can I make my $function work?
$contactUs = '<div style="color: green;">click here</div>';
echo $contactUs;
Not really sure what you're asking about, but you can do:
$function = function() { echo '<div style="color: green;">click here</div>'; };
...
$function();
1° In php, all strings need to be surrounded by quotes:
'<div style="color: green;">click here</div>';
Then, echo is a language construct which send text to output (your screen for example);
// If you want to use a variable
$contactUs = '<div style="color: green;">click here</div>';
echo $contactUs;
// but you can use echo 'your string':
echo '<div style="color: green;">click here</div>';

Categories