How to change this to HTML from PHP [closed] - php

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>

Related

how to search for something in a database and display it? [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 2 years ago.
Improve this question
I tried this code for displaying an item name, price and a photo from database for searching an item name in a search bar
<?php
try
{
require('connection.php');
$sql2="SELECT * FROM items
where item.item_name like '".$txt1."%'
$result2=$db->query($sql2);
if ($result2->rowCount()!=0) {
foreach ($result2 as $r2) { ?>
<a href="images/<?php echo $r2['item_photo'] ?>" class="fh5co-card-item image-popup">
<figure>
<div class="overlay"><i class="ti-plus"></i></div>
<img src="images/<?php echo $r2['item_photo']?>" alt="Image" class="img-responsive">
</figure>
<div>
<?php echo "<p><span class='price kk'>" ; ?>
<p style="font-family:'georgia';text-align:center;font-size:20px;color:black;"><?php echo ($r2['item_name']); ?></span></p>
<h2 style="font-family:'georgia';text-align:center;font-size:18px;color:grey;"><?php echo ("BD ".$r2['item_price']); ?></h2>
</div>
<?php }
} ?>
The problem is the sql, There is an extra name after where
$sql2="SELECT * FROM items
where item.item_name like '".$txt1."%' ;
There should be only item_name not item.item_name. Change this as:
$sql2="SELECT * FROM items
where item_name like '".$txt1."%';
And your code may be exploited with sql injection. Be carefull for production use this code.

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 can I download a image file to my local system using 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 7 years ago.
Improve this question
I am having multiple images, for that individual image i am having download button
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<button id='dwn_<? echo $a;?>'>Download</button>
<br>
<? } ?>
</div>
If i click that download button i need to save that corresponding image to my local system.
Kindly give some solution for this.
the easiest way without javascript i think it would ( I edited your code, but i cant try it now)
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<form method="get" action='image_<? echo $a;?>.jpg'>
<button id='dwn_<? echo $a;?>' type="submit">Download</button>
</form>
<br>
<? } ?>
</div>
You can delete the id in button if you only use for download
download.php
.........
<?php
if(isset($_REQUEST) && ($_REQUEST['image_name'])){
$filename = $_REQUEST['image_name'].'.jpg';
// Write download code here
}
display_page.php
............
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<a href="download.php?image_name=<?php echo $a; ?>" >Download</a>
<br>
<? } ?>
</div>
Most easiest way by using html 5
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<a href='image_<? echo $a;?>.jpg' download>
<span id='dwn_<? echo $a;?>'>Download</span >
</a>
<br>
<? } ?>
</div>

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 can I bold HTML text in an array using PHP? [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 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>'

Categories