hilite code into different pretty-printed HTML format and embed [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 6 days ago.
Improve this question
How to converts your code snippets into pretty-printed HTML format, easily embeddable for blog posts
give me mysql query
i am creating a site for converts your code snippets into pretty-printed HTML format, easily embeddable into blog posts, emails and websites.

If you're wanting to syntax highlight SQL, it's pretty simple, you can do this live client side, or if its static just do it server side.
Syntax highlighting is often done using a "pre" tag.
So you'd have something like this:
<pre><span class="sql-keyword">SELECT</span> <span class="sql-all">*</span><span class="sql-keyword"> FROM</span> <span class="sql-tableName">INFORMATION_SCHEMA.TABLES</span></pre>
Then you'd just stylise this in css:
<style>
.sql-keyword{
color:#33b5e5;
}
</style>
Now if you're wanting to do this dynamically and pass through any SQL query, just create a function that matches keywords and wraps them with span tags.
a basic example would be:
$query = str_replace('SELECT' , '<span class="sql-keyword">SELECT</span>' , $query);
or if you wanted something a little more adaptable.
$query = preg_replace('/(SELECT|UPDATE|DELETE|CREATE|DROP|TRUNCATE)/' , '<span class="sql-keyword">$0</span>' , $query);

Related

How to add styling and links to manual WordPress excerpt [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 6 years ago.
Improve this question
I've hit a bit of a road block I'm not sure how to add font styling i.e. bold font and also links.
I'm trying to get something like what brian over at backlinko has, which can be seen in this image below
I've only managed to achieve this:
Any ideas or suggestion to be able to achieve adding links and font styling to WordPress manual excerpt would be brilliant.
I was totally overthinking this and thought it was more complex than it actually was.
All I had to do was write the HTML inline in the manual excerpt box like this:
People that succeed with launching a new blog do one thing very well:
They build an email list! But in most cases, they do this before even launching their blog.
But you're probably wondering:
"How do I build an email list before I've even launched my blog?"
I'll break it down into three simple actionable steps that you implement yourself.
[alert-note]<strong>Free Checklist:</strong>Download a free checklist that shows you exactly how to use the strategy from this post (step-by-step).[/alert-note]

Convert mysql String into Paragraphs, links, quotes, etc [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 6 years ago.
Improve this question
I'm developing a Blog, and I want to give some Style to the content of Every post body.
I'm storaging each post with a form into my data base, and then retrieving it into the blog.
My form has Title, Date and Body.
What I need is to retrieve the body, and separate the paragraphs, quotes, and whatever I want to.
My idea was to add characters in the body like % or & (% mean paragraph, and & quote for example), so the I can use explote function.
Is there a simpler way?
You'd honestly be so much better to store your post's content as HTML and simply output that.
You'll have to implement security yourself but this could be as simple as using the strip_tags() function - example:
$post_body = strip_tags($_POST['body'], '<p><strong><em><span><a><blockquote>');
This would simply strip all HTML tags other than <p>, <strong>, <em>, <span>, <a> and <blockquote>. That should prevent any issues with malicious users inserting Javascript code etc.
Hope that helps!

Get news and convert to plain text 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 6 years ago.
Improve this question
I want to know if there's a way to chose a random link from a news website, get the page and remove all but text to be stored in a database with php cli. I have no limitations on what can be installed as far as php extensions. If there is no easy way to do this, is there a news service that supplies plain text news?
thanks.
Nope - not from a 'website'... html will vary from site to site and too complex to filter from one source - add multiple sources and the mission is impossible.
That's the bad news. The good news is that there is a way:
Most "news" site provide their content, or a portion of the content, in RSS feeds. Do some research on RSS2 and ATOM protocols and your answer is in there...
Start here: http://www.whatisrss.com

Tagging systems [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 6 years ago.
Improve this question
Can someone tell me more about tagging systems like facebook, youtube, instagram and similar sites have. On posts and photos...
If you have some examples it would be great and don't ask me for code because I didn't done any of coding... In my mind it is something mixed with live search that starts after some symbol like $ or # or something else and on click on some value it shows that value inside text where you typed it....
I know it is mostly ajax but if you have some examples it would be great. Thanks
Tagging is like Comments. You have to make sql table, put a reference to the item that it's tagging, to the tagger, tag contents like the person that we tagged, and some additional datas of tag (like the position of the tag in a photo).
So we will got a table like this:
ID ID_IMAGE ID_TAGGER ID_TARGET tag_position_x tag_position_y
Now that you have made you table you need to build a php page where you will retrieve the tags. Then you need to make the front end code, which will need some js code so that the tag will be placed in position(tag_position_x,tag_position_y) in a photo. This can be done like this:
//some css code
container_img{
position : relative;
background : rgba(0,0,0,0.7);
}
.tag{
position : absolute;
}
and the js will be like (in jquery):
$(".tag").each(function() {
$( this ).css("top",$(this).data("position-x"));
$( this ).css("top",$(this).data("position-y"));
});
Now what I gave you is hints so you know what you have to do.

Displaying text area input within something other than text area [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 am working on a form completion view that needs to be easily copied. One of the inputs is a that displays multiple lines. So person can type out something that looks like this.
Dear Bob,
I am here to do this.
Thank you
SirRahal
I then take that data and store it into a database as varchar(1500) latin1_swedish_ci. The issue is that when I try to display this data in anything other than a it combines all the lines into 1. Example the not above would display like this:
Blockquote
Dear Bob, I am here to do this. Thank you SirRahal
The reason why I can't use a textarea to display it is because it doesn't copy and paste friendly.
Questions:
1) Is there another way of displaying this correctly?
2) Are there hidden characters in the string that I can use to identify in php and parse the text?
This code does work but I can't use a textarea:
<textarea>
<?php echo $model->description;?>
</textarea>
I believe you need to add nl2br when you output, e.g.
<?php echo nl2br($model->description);?>
Use CSS, and set white-space: pre on the container of the text.

Categories