Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Sep 23, 2015

Generate random string with PHP

If you want to generate random code with PHP you can use this function:

<?php
public function genRandmStr($lgt = 8){
       
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@#!';
        $charactersLength = strlen($characters);
        $randomString = '';
        for ($i = 0; $i < $lgt; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
        return $randomString;
    }
}

// you can see the result here
echo genRandmStr();
?>

Sep 18, 2015

CakePHP how to retrieve POST and GET vars

When you are working with CakePHP framework and you try to retrieve the variables which have been sent through GET or POST.

For POST variables you have

For $_POST['key']  we have
$this->request->data('key');


For GET variables you have

For $_GET['kpa']  we have
$this->request->query('kpa');


Aug 14, 2015

CakePHP

Last 2 weeks I tried to put ZF2 to my project www.mateonline.net. It was endless pain to configure Zend Framework 2 for me as a beginner with this. ZF2 as syntax is very nice. But something got wrong with server configuration.
So, then I said I will try Symfony 2. But, I quit immediately. I though it will be easier, but it is no so nice as ZF2.
And, then I pass to CakePHP. Which I like. Except the fact that it has no PDO. I don't like  how is linked to MySQL DB but I can use to it.

Jul 23, 2015

Javascript redirect for mobile devices

The best method to redirect for mobile that I found is following:


<script type="text/javascript">
if (screen.width < 1081) {
 var ref = document.referrer;
 var urls = new Array("http://www.mymainsite.com","http://m.mymobilesite.com");
 var n = ref.match(urls[0]);
 var m = ref.match(urls[1]);
 if ((m!==null) || (n!==null)) {
 stop;
 }
 else if (ref=='') {
 var r = confirm("Small Display is Detected.\nClick \"OK\" for MOBILE SITE.");
 if (r==true) {
  window.location = "http://m.mymobilesite.com";
  }
  else {
  stop ;
 }
 }
 else
 {
 window.location = "http://m.mymobilesite.com";
 } 
}
</script>

Angular JS

Last days I was struggling with implementation of Angular JS on one  my websites: www.pensiunealajura.ro/mobil/

The big issue with this was to list HTML code without listing HTML tags like < or >. For instance, I wanted to have

    This is a bold text.

not

  This is a <b>bold text</b>.

So, I tried to have this with the module ngSanitize and $sanitize and $sce with  $sce.trustAsHtml.

But all of these were not good. And i dug more. And I found out that the best way to write formatted HTML code into a web page using Angular JS  is using directive ngBindHtml as is explained here: 
https://docs.angularjs.org/api/ng/directive/ngBindHtml

Now, everything is ok with my page.
:)

Jan 15, 2014

VB Script

I've needed to access an Access file from an html file. I did could do this using VBScript. It is running very well with Internet Explorer and could be a solutions in Corporatist offices wher security level is too paranoic.

Now I'm working with vbscripts. I use it to generate local xml files. Those xml files I use  to keep data from Access files to be easier to read in my network. The answer of my small app (.hta file) is much faster then if I read straight from MS Access file.

So, I used following code to generate a new .xml file:

<script type='text/vbscript'> 
        Set oFS = CreateObject("Scripting.FileSystemObject") 
           Const strXmlFile = "Documents.xml" 
           Set objXMLFile = oFS.OpenTextFile(strXmlFile, 2, True, 0) 
            objXMLFile.WriteLine "" 
            objXMLFile.WriteLine ""'" href=""Documents.xsl""?>" 
            objXMLFile.WriteLine "
           'Set myFolder = oFS.GetFolder("Documents") 
            'For Each File In myFolder.Files 
            'FileLast = File.DateLastModified 
            'FileMod = DateDiff("d", FileLast, Now) 
            '    If FileMod < 5 Then 
             'Corporate = File.Name 
             'myDate = Split(FileLast,"/") 
             'myYear = Left(myDate(2),4) 
             'myMonth = myDate(0) 
             'myURL = "Whatever your URL is" 
             'Download = "Wherever your download site is" 
             'Call CreateXML(Corporate,myYear,myMonth,myURL,Download) 
             Call CreateXML("Corporatia","myYear","myMonth","myURL","Download") 
              
                'End If 
            'Next 
           'This next call will run once the "CreateXML" has finished. 
           Call CloseXML() 
           Function CreateXML(Corporate,myYear,myMonth,myURL,Download) 
            objXMLFile.WriteLine vbTab & "
            objXMLFile.WriteLine vbTab & vbTab & "" & Corporate & "
            objXMLFile.WriteLine vbTab & vbTab & "" & myYear & "
            objXMLFile.WriteLine vbTab & vbTab & "" & myMonth & "
            objXMLFile.WriteLine vbTab & vbTab & "" & myURL & "
            objXMLFile.WriteLine vbTab & vbTab & "" & Download & "
            objXMLFile.WriteLine vbTab & "
           End Function 
           Function CloseXML() 
            objXMLFile.WriteLine "
"              wscript.echo "Completed XML Creation" 
           End Function 

          </script>

Dec 14, 2013

VBscript and ADO connection

We can connect to a MS Access file using vbscript. So we can run query into Access file, we can list data from Access into HTML using vbscript. The problem with that is … if we run HTML from a local drive it is OK. But if we try to access MS Access from the network then... we can have problems. I mean Warning messages for every request from database.


We can avoid this issue if we use .hta instead of .html.

Oct 31, 2012

New forum

Starting today, the coders has a new forum for their comunnication. Here we are:
coderstalk.co.cc

It is structurated by software domains: PHP, ASP, .NET, C#, Databases and HTML&CSS.
We are 4 people which will respond for every question.

The website is based on the SMF Simple Machines Forum.

Sep 18, 2012

Wordpress to regular website

Many clients ask me to build their websites with wordpress. So, now i found an interesting article about that:

"I get that for most of us entrepreneurs, especially when we're just getting started, we're bootstrapping and funds are tight.  That's what you need to jump in and use WordPress to build your website.  So, here's how to make a "regular" (non-blog) website using WordPress.  To see a larger version of any image below, just click on it.
Over the next few days I'll be posting about WordPress and how to get the most out of it.  But back to setting up your site…
First, you'll need to install WordPress on your hosting space.  This is not as scary as it sounds – really, it's not!  Most website hosts will even install it for free for you if you open a support ticket and ask.  Here's a video showing how to install WordPress using Fantastico (will open in a new window so you don't lose this post)."

Read more...

Aug 30, 2012

Aug 13, 2012

IE7 Preview for developers

Last 2 weeks I've tried to repair the css styles for a web app which must be opened with Internet Explorer 7.0

Now I use Windows 7 and IE10. So, for debug my webpage in IE7.0 I've used IETester.

Now, I founded a new app which is just trial for 60 days (unfortunatelly). This application is:
Microsoft Expression Web4 SuperPreview. I've downloaded from here:
http://www.microsoft.com/expression/try-it/Default.aspx

And looks like:



UPDATE: Now I can use this: http://browsershots.org/

Feb 28, 2012

New project

Today, we lance a new project. It is BETA version. But the website is Up. It's about http://www.dentaldirectorylinks.com. It is a link directory with/for dentists and dental network in the world.

It's all withh html, css javascript, jQuery, Mysql and PHP.

Jan 26, 2012

The best Rich Text Editors to use in web CMS

I found an nice article about Rich Text Editors to use in HTML with PHP. It's about Yahoo! UI Library: Rich Text Editor, FCKeditors and others.


The article is not so newest but it's helpfuly: http://woork.blogspot.com/2009/02/best-rich-text-editors-ready-to-use-in.html



Dec 20, 2011

Creating XML from MySQL as easy as PI


ANALYSIS
Unfortunately, importing XML into MySQL is more like chocolate cheesecake, but there are solutions available. Just follow this guide and you'll be on your way to integrating Web services with your database in no time. Starting from scratch
With the growing popularity of XML, developers have found an easy method to present data sets in a standardised way. What else does that sound like? A database! It's only natural that it should be simple to convert your information without a lot of fuss -- and you can. Some proprietary database manufacturers, such as Microsoft and IBM, have taken steps to integrate XML into their systems. This comes as no surprise since these two companies are both heavily involved in the XML standardisation project. Not wanting to be left behind, the creators of MySQL database incorporated a means for generating an XML data file. It's supported in version 3.23.48 and up. You can use the command line or facilitate the process with the programming language of your choice. To get started, you can download MySQL database  for free from MySQL.com. The current release is sufficient to support this feature, and you don't need to compile it with any special parameters. Fruit filling
Once you're installed, created, and populated your database, execute the following command to generate an XML file:
mysqldump --xml databasename [tables]
If you'd like to save this to a file, simply use the standard *NIX method of outputting to a file:
mysqldump --xml databasename > filename.xml
This produces a well formed XML document. Because XML is datacentric, if you dump your entire database and it contains no information, your file will result in a series of empty tags based on the table names. Your output should look something like this:

Now you're free to use this data file with any application you desire. This method is useful in a number of ways. Not only will it create a standardised representation of your data, but it can also take a snapshot of your database (or portion of your database) for display. Rather than making repeated calls to the database server, just generate an XML document when your database changes and reference that from Web pages or whatever you're using. This can localize calls for data, reduce the overhead of frequent calls to a database, and easily present a subset of your information for improved performance, security, or localization. Ice cream on the side
It's really easy to get XML from MySQL, but how about the other direction? That's a little trickier. MySQL itself doesn't support this function, and with good reason. The database currently has no way to validate the XML file. This could result in a number of scenarios, ranging from a partial load to ignoring malformed tags and statements to simply forcing the entire load to fail. MySQL supports only cascading back-outs in current development versions. While it's not pretty from a native standpoint, you do have some options. One solution is Perl's DBIx::XML_RDB module. You can use this method to both import and export XML, though understandably the import is heavily dependent upon a correctly structured XML file. To get the data, the module essentially runs a query and formats the results in an XML file. Conversely, you can use the module to read an XML file, create a SQL query, and execute it. There is a simpler option as well. The DBIx::XML_RDB module ships with two utility scripts to facilitate the process: xml2sql.pl and sql2xml.pl. I found agreat tutorial  on using this Perl module at O'Reilly's XML.com Web site. It will walk you through the process. Another, more generalized effort comes from Ron Bourret's XML-DBMS project . This is an ongoing effort to support XML imports and exports with relational databases using Perl and Java. There's also some very interesting work that supports mapping one database to another using XML as facilitating middleware. This is a community-oriented open source project being managed on SourceForge . Other languages, particularly Web scripting languages, haven't ignored the need to import XML into SQL databases either. There are similar efforts for Python, such as the xml2sql and dtd2sql modules, outlined in detail in this article from IBM , and a couple of projects in the works for PHP, such as the "XML MySQL class" project. Scrumptious
With these utilities, importing and exporting XML into and from MySQL is easy! Since MySQL is popular and free, it's been the test bed for integrating many scripting languages in XML, and as a result there are a number of tutorials and scripts specific for this database. With the power of a relational database and the ability to easily create XML files, MySQL can be an integral part of your Web services solution.

Nov 23, 2011

XML & PHP

The SimpleXML extension provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators.



<?php
$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<movies>
 <movie>
  <title>PHP: Behind the Parser</title>
  <characters>
   <character>
    <name>Ms. Coder</name>
    <actor>Onlivia Actora</actor>
   </character>
   <character>
    <name>Mr. Coder</name>
    <actor>El ActÓr</actor>
   </character>
  </characters>
  <plot>
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  </plot>
  <great-lines>
   <line>PHP solves all my web problems</line>
  </great-lines>
  <rating type="thumbs">7</rating>
  <rating type="stars">5</rating>
 </movie>
</movies>
XML;
?>



You can find more, here: http://www.php.net/manual/en/simplexml.examples-basic.php

Learn How to Install Joomla on Your Website in Less Than 5 Minutes


You can learn how to install Joomla on your website in a number of ways. However, the simplest and by far, the quickest is through Fantastico. This usually takes about 1-2 minutes once you know how. In this article, we are going to cover just that.

So, here is the step by step process for installing Joomla on your own website.

1. Log in to your hosting account's Control Panel. This should usually be http://www.mydomainname.com/controlpanel, where 'mydomainnane' is replaced your own website that is hosted on that hosting account.

2. Look for the smiley icon that says "Fantastico" and click on it. This is where you will be installing the Joomla package from. Note that Sometimes, it may say "Fantastico De Luxe." Don't worry it is the same thing. Much like saying "my room" and "my bedroom" ;)

3. Look for "Joomla" under the "Content Management" category of scripts in Fantastico and click on it. Also, note that the title 'Joomla' may sometimes have some numerical suffixes showing which version it is. For example, the title may read "Joomla 1.5" for version 1.5 of the CMS. Just click on the most recent version and go to the next step.

4. Look for the hyperlinked blue "New Installation" link and make sure you have at least as much as the minimum disk space required for you to install Joomla on your website. This is usually about 25 MB of disk space.

This is not usually
a problem, with most people's disk space running into the tens of gigabytes. But it is still good to make sure you have enough to hold a new Joomla installation.

5. Choose where on your website you want to install Joomla. Will it be on your main domain, an existing sub-domain or a new not-yet-existing sub-domain or directory? Indicate it in this part of the installation process.

6. Fill out other required fields that are required to smoothly install Joomla on the site. This includes creating an Admin username and password. Don't choose 'Admin' and 'password' as your username and password. Many people do this and have been hacked. Also, fill out the site name or main keyword, email address and other details here.

Then click the "Install Joomla" button.

7. On the next page, make sure that all the needed information is correct. Also, note down your Admin username, password and backend page (the one that ends with /administrator).

Finally, hit that "Finish Installation" of a button.

Voila! You have just learned how to install Joomla on your website. This should usually take only 1 or 2 minutes at most. After all, all you are doing is just hitting buttons, except for when choosing a username, etc.

If it still sounds a little like "nerd talk" (with all due respect to all the nerds out there ;) ), you can watch the video version of this article where you see the Joomla installation done live on the screen and see if you can learn how to install Joomla after that.

Jun 17, 2011

CSS vs. tables in HTML

An Interesting article about css with css vs. table:
http://esitesecrets.com/articles/1667/1/CSS-Layouts-Vs-Table-Layouts-Which-One-is-Better/Page1.html

In last 2 years I have used HTML with css table-less because more people which asking me for HTML slicing to NOT use tables. And I do  that....

Jul 6, 2010

MySQL tutorial - Managing database

Creating Database

To create a database in MySQL, you use the CREATE DATABASE statement as follows:
CREATE DATABASE [IF NOT EXISTS] database_name;
CREATE DATABASE statement will create the database with the given name you specified. IF NOT EXISTS is an option part of the statement, this part prevents you from error if there is a database with the given name exists on the database server. In our tutorial, for example, to create classicmodels database, you just only apply CREATE DATABASE statement above as follows:
CREATE DATABASE classicmodels;
After executing the statement, the MySQL will returns you a message to indicate whether the execution are successful or not.

Showing Databases

SHOW DATABASE statement will show all databases in your database server. You can use SHOW DATABASE statement  to check the database you've created or to see all the databases' name on the database server before you create a new database.
SHOW DATABASES;
On my database server, the output is :
+--------------------+
| Database           |
+--------------------+
| information_schema |
| classicmodels      |
| mysql              |
+--------------------+
8 rows in set (0.00 sec)

Selecting Database

To select a database which you plan to work with, you use USE statement
USE database_name;
You can select our sample database by using the USE statement as follows:
USE classicmodels;
From now you can query the tables' data and do whatever you want inside the selected database.

Removing Database

Removing database means you delete the database. All the data and related objects inside the database are permanently deleted and cannot be undone. So it is very important to execute this query with cares. To remove the database you can use DROP DATABASE statement as follows :
DROP DATABASE [IF EXISTS] database_name;
Like CREATE DATABASE statement, IF EXIST part is an optional part to prevents you from removing database which is not existed. In order to practice with DROP DATABASEstatement, you can create a temporary database, show the database on the database server, and drop it step by step as follows :
CREATE DATABASE IF NOT EXISTS temp_database;
SHOW DATABASES;
DROP DATABASE IF EXISTS temp_database;

Jun 29, 2010

HTML START...

Hi,

 

now we will start with a simple HTML page.

 

You need a editor to start editing first internet file. E.g. if you work in Windows you may use Notepad. Must create new file (from File->New File).

And after that you'll save this file with extension .htm or .html. For example, firstpage.html.

Now, you must know that one html page will contain some tags like <html>, <b>, <body>, <head>. Every opened tag will must be closed... i.e. every tag must have one end, like </html> or </body>


Now will see how is the structure of a html page.



<html>
<head>
<title>The title of my page</title>
</head>

<body>
<h1>My first HTML page</h1>
<h2>The second title of this page</h2>

Content of this page . . . . . .
bla bla bla


</body>
</html>


and the result is



My first HTML page

The second title of this page


Content of this page . . . . . .
bla bla bla





You can see any documentation here or here.

Good luck!