I have an image with a blank space in it. On some pages, it works fine. On others, it cuts off where the blank space is. Is there a reason why it works sometimes and not others?
the same image...
I get this on one page (incorrect):
<img src="/assets/848b31ff/thumb_4307-0403141" large.jpg="">
$thumb = Yii::app()->assetManager->publish(Yii::app()->basePath.'/images/'.$data->product->product_image);
<? echo '<img src ='.$thumb.'><b>'.$prodname.'</b>';?>
And this on another (correct):
<img src="/assets/848b31ff/thumb_4307-0403141 large.jpg" class="thumb-product" border="0" alt="">
if(is_file($img_path.$model->product_image) && is_file($thumb_path.$model->product_image)){
$product_imaget = Yii::app()->assetManager->publish(Yii::app()->basePath.'/images/'.$model->product_image);
}
You are missing enclosing quotes in the first echo on the src param. This is how it should be:
<? echo '<img src ="'.$thumb.'"><b>'.$prodname.'</b>';?>
Related
Let's say I extract some classes from some HTML:
p_standards = soup.find_all("p",attrs={'class':re.compile(r"Standard|P3")})
for p_standard in p_standards:
print(p_standard)
And the output looks like this:
<p class="P3">a</p>
<p class="Standard">b</p>
<p class="P3">c</p>
<p class="Standard">d</p>
And let's say I only wanted to print the text inside the P3 classes so that the output looks like:
a
c
I thought this code below would work, but it didn't. How can I compare the class name of the container tag to some value?
p_standards = soup.find_all("p",attrs={'class':re.compile(r"Standard|P3")})
for p_standard in p_standards:
if p_standard.get("class") == "P3":
print(p_standard.get_text())
I'm aware that in my first line, I could have simply done r"P3" instead of r"Standard|P3", but this is only a small fraction of the actual code (not the full story), and I need to leave that first line as it is.
Note: doing something like .find("p", class_ = "P3") only works for descendants, not for the container tag.
OK, so after playing around with the code, it turns out that
p_standard.get("class")[0] == "P3"
works. (I was missing the [0])
So this code works:
p_standards = soup.find_all("p",attrs={'class':re.compile(r"Standard|P3")})
for p_standard in p_standards:
if p_standard.get("class")[0] == "P3":
print(p_standard.get_text())
I think the following is more efficient. Use select and CSS Or syntax to gather list based on either class.
from bs4 import BeautifulSoup as bs
html = '''
<html>
<head></head>
<body>
<p class="P3">a</p>
<p class="Standard">b</p>
<p class="P3">c</p>
<p class="Standard">d</p>
</body>
</html>
'''
soup = bs(html, 'lxml')
p_standards = soup.select('.Standard,.P3')
for p_standard in p_standards:
if 'P3' in p_standard['class']:
print(item.text)
want to insert a new empty line before a selected array element while we loop through it using v-for to create a list..trying to do this using \n isn't working
<!-- this is the template part -->
<ul>
<li v-for = "ninja in ninjas" > {{ninja}}</li>
</ul>
/* this is the script part notice index no 2 in the array*/
data() {
return {
ninjas: [
'mati kahe kumhaar sey, tu kya ronday mohey',
' Ik din aisa aayega mai rondungi tohe',
'\n aaye hain toh jaayengay Raja, Rank, fkeer',
' Ik sinhaasan chodi chale, Ik baandhay zanjeer'
]
};
},
This is pretty easy to do using the <pre> tag which forces it to preserve white space, new lines, etc. This is often used for preserving formatting in code examples.
<div id="app">
<ul>
<li v-for = "ninja in ninjas" ><pre>{{ninja}}</pre></li>
</ul>
</div>
working example: https://jsfiddle.net/skribe/10yL6va8/8/
You will probably want to use css to style the text surrounded by <pre> since most browsers automatically format it differently.
When I try and delete an entry from the code below it seems to spew out two array values with different index numbers and will not delete the entry. If I click multiple times it finally gets the correct ID but only by some random chance.
Using echo var_dump($deleted) results in something like:
String(2) "10"
String(1) "7"
These can vary and seems to be random.
I have reduced my whole plugin to just the code below thinking that maybe some other submit query might be interfering with it. And still I get two ID's with unknown string assignments.
Any ideas?
function myplugin_update_page(){
global $wpdb;
$update_page_list = $wpdb->get_results('SELECT * FROM wp_update_page');
$active = $wpdb->get_var("SELECT * FROM wp_update_page WHERE active='on'");
echo '<form method="post" action=""><table>';
foreach ( $update_page_list as $update ) { ?>
<tr>
<td><input type="image" src="<?php echo plugin_dir_url(__FILE__).'images/delete.png'; ?>" name="delete[]" value="<?php echo $update->ID; ?>" /></td>
</tr>
</table>
</form>
</div>
<?php
}
if(isset($_POST['delete'])) {
$delete = $_POST['delete'];
foreach ($delete as $deleted) {
$wpdb->query("DELETE FROM wp_update_page WHERE ID = $deleted");
}
echo "<script type='text/javascript'>window.location=document.location.href;</script>";
}
}
I'm using VirtueMart 2.0.10 with Joomla! 2.5.6 and my problem is the autogenerated pdf documents for each product don't include my custom fields. I'm no php expert but I think theese lines in file /components/com_virtuemart/views/productdetails/tmpl/default_pdf.php has something to do with it, starting at line 145:
<?php // Product custom_fields TODO relation to Childs
if (!empty($this->product->customfields)) { ?>
<div class="product-fields">
<?php
$custom_title = null ;
foreach ($this->product->customfields as $field){
?><div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if ($field->custom_title != $custom_title) { ?>
<span class="product-fields-title" ><strong><?php echo JText::_($field->custom_title); ?></strong></span>
<?php //echo JHTML::tooltip($field->custom_tip, $field->custom_title, 'tooltip.png');
} ?>
<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo jText::_($field->custom_field_desc) ?></span>
</div>
<?php
$custom_title = $field->custom_title;
} ?>
</div>
<?php
} // Product custom_fields END ?>
I tested adding an else statement echoing some text after the above if statement and it executetd. So apperently there are no custom fields... but there really are...
I haven't found anyone else experiencing this problem wich I think is weird, but I don't think I have screwed something up. I HAVE made a few changes in the /components/com_virtuemart/views/productdetails/tmpl/default.php file.
I removed all the code that I entered in my question and replaced it with the following code from the file /components/com_virtuemart/views/productdetails/tmpl/default.php:
<?php
$custom_title = null;
foreach ($this->product->customfieldsSorted['normal'] as $field) { // I set the position to normal
if ( $field->is_hidden )
continue;
if ($field->display) {
?>
<?php if ($field->custom_title != $custom_title) { ?>
<b><?php echo JText::_($field->custom_title); ?></b><br />
<?php
if ($field->custom_tip)
echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png');
}
?>
<?php echo $field->display ?><br />
<?php echo jText::_($field->custom_field_desc) ?><br />
<?php
$custom_title = $field->custom_title;
}
}
?>
I'm no expert but this worked for me. The PDF now includes the custom fields.
As you see in the comment in the code I changed the position to 'normal'. The other positions seems to be 'ontop' and 'onbot'. But I won't change that setting so I leave it be.
EDIT: I forgot to mention I added some other html-code to that segment, like <br /> and <b> just for apperences. So nothing major, just to clarify that the code isn't EXACTLY like it is in the file default.php
I'm webdesigner and I touch NOTHING in development, so, I really need your help (exam in school). So, indeed, I've made a search form in the same page. There a field to search by town (ville) and the results should be appareate in a div. Sometimes it works, but I really need to fix that.
The error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\foodsurfing\index.php on line 55
There is the code
<?php
require_once('Connections/foodsurfing.php');
if(isset($_GET['recherche']))
$requete="SELECT * FROM fiche_membres WHERE ville LIKE '%".$_GET['recherche']."%'
LIMIT 0 , 1 ";
else
$requete="SELECT * FROM fiche_membres
LIMIT 1 , 1 ";
mysql_query("SET NAMES UTF8");
$resultat=mysql_query($requete);
if (false === $resultat) {
echo mysql_error();
}
?>
and the result's div
<div id="gmap_result_container">
<div class="gmap_result">
<?php while($fiche_membres=mysql_fetch_array($resultat)) {?> <p>
<a class="prenom"><?php echo($fiche_membres['prenom']); ?></a>
<a> , </a>
<a class="ville"><?php echo($fiche_membres['ville']); ?></a></p>
<img src="images/avatar_unknown.jpg">
<p><?php echo($fiche_membres['experience_culinaire']); ?></p>
<p><img src="images/ensavoirplus.png" name="roll" border="0" alt="En savoir plus" align="middle" class="ensavoirplus"></p>
<?php }?>
</div>
</div>
Thank you so much for your help !!
Glad to be into the community I just discover as beginner !
Warning says that the resource is not valid which is parameter of mysql_fetch_array() method. You have to verify the reference before retrieving rows.
if(isset($_GET['recherche']))
$requete="SELECT * FROM fiche_membres WHERE ville
LIKE '%" . mysql_real_escape_string($_GET['recherche']) . "%' LIMIT 0 , 1 ";
else
$requete="SELECT * FROM fiche_membres LIMIT 1 , 1 ";
$resultat=mysql_query($requete);
if($resultat)
{
while($fiche_membres=mysql_fetch_array($resultat))
{
//
}
}