new line for tooltip fetching values from the database - tooltip

$price = mysql_result($result, $num, "drinks_shot"); $price2 = mysql_result($result, $num, "drinks_bottle");
$append = $clean_name.'<br> Per shot: Php'.$price.'<br> Per bottle: Php'.$price2.'.00'; $description = mysql_result($result, $num, "drinks_image"); echo "<td class='label'><img src='". mysql_result($result, $num, 'drinks_image')."' onclick='addtocart(". mysql_result($result, $num, 'drinks_id').")' class='masterTooltip' title= '".$append."'<br>";
if only i could make it display like
hennessy
price1
price2
i found similar posts regarding my problem but none of them are really working. Please help. :(

You want linebreaks inside a title="" tooltip? Instead of using <br>, use \n and make sure it's inside double (") quotes and not single quotes. Like so:
$append = $clean_name . "\n Per shot: Php" . $price . "\n ...";

Related

splitting a string into similar elements along with the values

I have a string like
$query = "date=20.10.2007&amount=400+date=11.02.2008&amount=1400+date=12.03.2008&amount=1500";
there are two variables named date and amount containing a value e.g date= 20.10.2007 and amount=400 and these two variables repeat itself with different values and each set (date & amount) are separated by '+' sign. Now i want to display this string like this:
Date Amount
20.10.2007 400
11.02.2008 1400
12.02.2008 1500
Need help
We can make judicious use of explode and preg_split here to get the output you want:
$query = "date=20.10.2007&amount=400+date=11.02.2008&amount=1400+date=12.03.2008&amount=1500";
$array = explode("+", $query);
$counter = 0;
echo "Date Amount\n";
foreach($array as $item) {
if ($counter > 0) echo "\n";
$parts = explode("&", $item);
echo preg_split("/=/", $parts[0])[1] . " ";
echo preg_split("/=/", $parts[1])[1];
$counter = $counter + 1;
}
This prints:
Date Amount
20.10.2007 400
11.02.2008 1400
12.03.2008 1500
The logic here is that we first split the query string on + to obtain components looking like:
date=20.10.2007&amount=400
Then, inside the loop over all such components, we split again by & to obtain the date and amount terms. Finally, each of these are split again on = to get the actual values.
Thanks a lot Tim Biegeleisen for your kind guidance. From your help i did it with this code below:
$str = "date=20.10.2007&amount=400+date=11.02.2008&amount=1400+date=12.03.2008&amount=1500"; $array = explode("+",$str);
$i = 0;
echo nl2br("Date Amount \n");
foreach($array as $item[$i])
{
parse_str($item[$i]);
echo $date;
echo $amount."<br>";
$i++;
}

Get code between tags and generate youtube embed

I have some tekst and in the middle of article I put {youtube}IPtv14q9ZDg{/youtube}. How to make code which is between {youtube} generated in youtube embed
I use PHP, but there might be other options.
I filter the text for the key-words. Then take the 11 digit code and wrap it in a link tag. Works best in a "for loop".
This is one I use to find url's in my text and make them live. But you can modify it to do what you want by changing the "preg_match" setting.
function make_clickable($string) {
$string = preg_replace("/[\n\r]/"," <br /> ",$string);
$arr = explode(' ', $string);
foreach($arr as $key => $value){
if(preg_match('#((^https?|http|ftp)://(\S*?\.\S*?))([\s)\[\]{},;"\':<]|\.\s|$)#i', $value)){
$arr[$key] = "<a class=\"custome\" href='". $value ."' target=\"_blank\" class='link'>$value</a> ";
}
}
$string = implode(' ', $arr);
return $string;
}

Parsing spaces and returns

I have arrived at the below code to read the file name and contents of *.txt files within a specified folder. My current issue is that it seems to interpret returns as spaces within the read contents instead of inserting a return. I would also like to be able to parse and replace tabs in the txt file with a number of spaces to simulate a "tab". How may I achieve this?
<Html>
<Head>
<Title>Installer</Title>
<Script Language="VBScript" Type="Text/VBScript">
'-- Resize & move app to center
Sub SetWindow( WidthX,HeightY )
Self.ResizeTo WidthX, HeightY
Self.MoveTo (screen.Width - WidthX)/2, (screen.Height - HeightY)/2
End Sub
'-- Call Window resize Sub
SetWindow 800, 600
</Script>
<Hta:Application Id="Installer" ApplicationName="Installer" Version="0.1"
SingleInstance="Yes"
Icon="image/appIcon.ico"
Caption="No"
Border="None"
InnerBorder="No"
ContextMenu="No"
SysMenu="Yes"
Scroll="No"
Selection="No"
/>
</Head>
<Body>
<Script Language="VBScript" Type="Text/VBScript">
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "Notes\"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If UCase(objFSO.GetExtensionName(objFile.name)) = "TXT" Then
Files = objStartFolder & objFile.name
Set objReadFile = objFSO.OpenTextFile(Files, 1)
document.write Left(objFile.name, Len(objFile.name)-4) & "<br>"
document.write objReadFile.ReadAll & "<br><br>"
objReadFile.Close
else
document.write ="File was empty"
End If
Next
</Script>
</Body>
</Html>
HTML does not handle the CRLF at the end of the lines in the way you expect.
You can replace all line ends with <br> tags
document.write Replace(objReadFile.ReadAll, vbCRLF, "<br>") & "<br><br>"
Or you can place the file contents inside <pre> tags
document.write "<pre>" & objReadFile.ReadAll & "</pre><br><br>"
Maybe the second option will better fit your problem as you also want to replace tabs with spaces
document.write "<pre>" & replace(objReadFile.ReadAll, vbTab, " ") & "</pre><br><br>"
Here is the modified code to get the desired outcome I wanted, for those who want it in plain code format:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "Notes\"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If UCase(objFSO.GetExtensionName(objFile.name)) = "TXT" Then
Files = objStartFolder & objFile.name
Set objReadFile = objFSO.OpenTextFile(Files, 1)
strExt = Left(objFile.name, Len(objFile.name)-4)
strNote = Replace(objReadFile.ReadAll, vbCRLF, "<br>")
objReadFile.Close
document.write strExt & "<br><br>"
document.write strNote & "<br><br>"
else
document.write ="File was empty"
End If
Next

Jquery Mobile data-autodividers

Is there a way to have the auto-dividers sort by last name?
I don't think it should have anything to do with the php code, but I thought I would include it for a reference below:
$result = mysql_query("SELECT * FROM `patients` WHERE `company_id` = " . $user_data['company_id'] . " ORDER BY `patient_lastname`");
while($row = mysql_fetch_array($result)) {
echo '<li>' . $row['patient_firstname'] . ' ' . $row['patient_lastname'] . '<span class="ui-li-count">DOB: ' . $row['patient_dob'] . '</span></li>';
}
Appreciate any help!
You can do the sorting in the front-end by selecting the list items and sorting them afterward. In the example below, instead of selecting the text content of the list items, you can select the last-name value.
var listContentArray = listViewInstance.find('li').not('.ui-li-divider').get();
listContentArray.sort(function (a, b) {
var first = $(a).text(),
second = $(b).text();
if (first < second) {
return -1;
}
if (first > second) {
return 1;
}
return 0;
});
Then you can destroy the content of the listViewInstance, re-append the elements in the listContentArray, and finally refresh the listView component.
You can download a fully functional example that does all of this at:
http://appcropolis.com/page-templates/autodividers/
Couldn't find a way to display Firstname then Lastname and autodivide by Lastname, so I just replaced the code with:
' . $row['patient_lastname'] . ', ' . $row['patient_firstname'] . '
which displays: "Lastname, Firstname" and autodivides by Lastname. It'll have to work for now.

Remove a specific character of plaintext with simple dom html

I have this code to retrieve some products on a website:
foreach($page1->find('.link_category') as $produit1)
echo $produit1->plaintext . '<br />';
I retrieve product with double quote ", i would like to replace it (the double quote)by nothing
thanks for help
foreach($page1->find('.link_category') as $produit1) {
$product = str_replace('"','',$produit1->plaintext);
echo $product;
}
I hope it works :)

Resources