Two styles in one echo - styles

Hope someone could help me with this. I want to get output like this:
Width (cm): 46
I want Width (cm): to be bold and value (46) to be regular.
Here is echo:
echo "<p>". __( 'Width (cm): ', 'woocommerce' ) . $_wccf_pp_width ."</p>";
$_wccf_pp_id_width = get_post_meta($product_id, "__wccf_pp_width", true);
I know I can wrap whole echo in div and put some style to p tag but how to separate styles for field label (Width (cm):) and for value (46)? Thanks in advance.

<?php
echo "<span style='font-weight:bold;'>". __( 'Width (cm):</span><span> ', 'woocommerce'
) . $_wccf_pp_width ."</span>";
$_wccf_pp_id_width = get_post_meta($product_id, "__wccf_pp_width", true);
?>
I think this should work.

echo "<p><b>". __( 'Width (cm): ', 'woocommerce' ) . "</b>" . $_wccf_pp_width ."</p>";
Use html bold tag (<b></b>)

Related

how to remove the double quotes in output when i use echo command with "< >" (these charaters) in the string?

I wish to create a required no. of html divisions each with a different id (a series).
but when I write in a loop
echo "<div id=%prefix%%i%> %innerHTML% </div>" >> file.txt
It should be like
<div id=a1> x </div>
<div id=a2> x </div>
<div id=a3> x </div>
but it comes out to be
"<div id=a1> x </div>"
"<div id=a2> x </div>"
"<div id=a3> x </div>"
I have tried omitting the double quotes "" but then it throws an error due to the use of '>' (used to write in a file)
help me with this
An example as per Aacini's comment:
#Echo Off
Set "innerHTML=x"
Set "prefix=a"
(For /L %%A In (1 1 3) Do Set /P "=<div id=%prefix%%%A> %innerHTML% </div>"<Nul&Echo=)>"file.txt"
Pause
echo ^<escape them^>
this works absolutely fine.
echo ^<div id=%prefix%%i%^> %innerHTML% ^</div^> >> file.txt

Echo set color for variable

I have this code
<?php
$date1=date('d.M',strtotime("+1 days"));
$date2=date('d.M',strtotime("+2 days"));
echo 'Ajunge la tine ' ,$date1, ' - ' ,$date2 ;
?>
I what in echo to set color red for $date1 and $date2 .
Thanx

Can't get li text() from a line

echo '<script>var newUL = $("<ul>';
for($i=1;$i<=4;$i++)
{
echo "<li>"."abcd"."</li>";
}
echo '</ul>");';
echo "\n";
echo '$("#filemanager li").click(function(){$(this).append(newUL);});</script>';
echo '<script>$("#filemanager li").click(function(){alert($(this).text());}); </script>';
"#filemanager" is a div tag
I can't get text from one appended -li- ... it returns text of all appended -li-
By $("#filemanager li") command you've got a collection.
Try this:
$("#filemanager li").each(function(){
alert($(this).text())})

i am having problems passing a variable from a php page to another php page using a hyperlink

I had the code working at one time but i changed something and it quit working.
The $id gets passed to the address bar on the browser but not to the next page.
I used the session_start
while($row = mysql_fetch_array($resultd))
{
$id = $row['id_num'];
echo "Edit "; //ln68
echo "<a href='del.php?id_num = $id'>Delete</a>";
echo $row['id_num'] . " " . $row['first_name'] . " " . $row['last_name'] . ", " . $row['title'] . ", " . $row['city'] . ", " . $row['phone_pri'] . ", " . $row['email_addr'];
echo ""; }
The receiving page is not getting the variable. I have used $_SESSION, $_GET, $_POST and nothing seems to work. I have even reversed the values in the href line and still nothing works. I used session_start here also.
this is page 2
$id = $_POST['id_num'];
// send query
$sql = 'delete FROM `delegate` WHERE `id_num`= $id';
Your comments would be most appreciated.
You are using GET request for passing the data via link
but in your second page, you are using POST
change it to $id = $_GET['id_num']; and try
and dont use spaces in href "
change it to "
space will be counted as a character

Clean string with just specified value PHP?

I have this in PHP
$string="Thisissomekindofstringiwantthislolipop";
I want new string like this
$string="iwantthis";
But i have more string similar
$string1="Thisissomekindofstrigqqqqqqqqqkokiki";
And new string
$string1="qqqqqqqqq";
The value of letters at beggining is always the same, and i always need new string with same letters count, is posible to do that?
Txanks in advance
If you want to cut the string you should take a look on substr.
You can then cut the unneeded parts:
<?php
$string="Thisissomekindofstringiwantthislolipop";
echo substr($string, 22, 9); // returns 'iwantthis'
?>
Update because of your comment:
You can also split a string by a delimiter (here: with explode). E.g.
<?php
$string = "vimeo.com/24076588";
$parts = explode("/", $string);
echo $parts[1]; // prints 24076588
?>
Or even nicer. Just extracting the numeric id from the URL with a regular expression using preg_match_all:
<?php
$string = "http://vimeo.com/24076588";
preg_match_all('/[\d]+/i',$string, $result);
print_r($result);
?>
This prints out
Array
(
[0] => Array
(
[0] => 24076588
)
)

Resources