Skip to main content

Posts

Showing posts from March, 2012

MySQL Query for getting subcategory name and parent category name in a single row

How to get subcategory name and parent category name  in a single row with out using multiple query

Suppose You have a category table with values like this

catId,catName,catParent
1 , Books , NULL
2 , DVD , NULL
3 , Science , 1
4 , Maths , 1
5 , English Movies , 2
6 , Malayalam Movies , 2


Based on above table structure category and subcategory values are identified by the presense of values in catParent field.

if catParent is NULL, the it is a category and if have a numeric value then the record will be that of a subcategory.

So we are here is know how we can get subcategory name and parent category name  in a single row with out using multiple query

Try this query


SELECT sc.catId AS catid, sc.catName AS subcat, c.catName AS cat
FROM tbl_category sc
LEFT JOIN tbl_category c ON c.catId = sc.catParent
WHERE c.catParent IS NOT NULL



this query will generate result like this

catid | subcat | cat
-----------------------
3 | Science | Books
4 | Maths | Books
5 | English Movies | DVD
6 | Mal…

How to prevent people from accessing the include files directly on the browser in php

PHP Script to prevent people from accessing the include files directly on the browser

If a single file has to be included then here is the sample code

index.php  where the file is to be included
___________

//define a constant "CALL_FROM_MAIN" in the main file
    define('CALL_FROM_MAIN', TRUE);
    include('folder/footer.inc.php');


and the footer file (for example) looks this way then

footer.inc.php ( the file to be inluded )
___________

// in the include file code check whether the constant "CALL_FROM_MAIN"  is set

    defined('CALL_FROM_MAIN') or die('file not found');
    echo('My Blog is www.crozoom.com');


So when someone tries to access the footer.php file directly then will get the "file not found" messages written on the screen. An alternative option is to redirect the person who wants to access the file directly to a 404 error page or any other location, so instead of the above code you would have to write the …

How to take screen shot of a website using PHP - Scripts and services to create website thumbnails

How to create website thumbnails using PHP

Website Thumbnails (also known as PagePix, thumbshots, snapshots, or previews) are screenshots of web pages that can help you quickly and easily recognize and identify certain websites. Web page previews display the exact site you would see before you click on a link.

few solutions solution for this :-


IMAGEGRABWINDOW()
Use of imagegrabwindow function in php. This Grabs a window or its client area using a windows handle (HWND property in COM instance) This function is only available on Windows server.
Check the use of function from php.net


WEBSITE THUMB GENERATOR (IECAPT)

This free php script used to create website thumbnails for your needs, or start your own website thumbnail generation service.

Download IECapt from http://iecapt.sourceforge.net or click download IECapt. Place it in some folder on your server.
Download Website Thumbnail Generator using link below, and unzip it to the same folder.
Update webthumb.php with your settings for thu…


Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »
Member
Search This Blog