Archive for the 'Programming' Category



accessing CSS of a inherited element

<div id="headerMenu">
<ul>
<li class="dropdown"><span class="ddfont">Contact Lists</span></li>
<li class="dropdown  dropselected"><span class="ddfont">Contact Lists</span></li>
</ul>
</div>
just use
#headerMenu li.dropselected span.ddfont
{
color:#FFFFFF;
}

Simple PHP CSV upload

<form enctype="multipart/form-data" action="up.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000"/>
Chooseafiletoupload:<input name="uploadedfile" type="file"/><br/>
<input type="submit" value="UploadFile" name="Submit"/>
</form>

<?php

if (isset($_POST[’Submit’])){

$target_path="upload/";
$target_path=$target_path.basename($_FILES[’uploadedfile’][’name’]);
if(move_uploaded_file($_FILES[’uploadedfile’][’tmp_name’],$target_path)){
$myFile = "upload/".$_FILES[’uploadedfile’][’name’];
}
else{echo "could not upload";}
[/cc]

Number of Columns and Rows in CSV using php

How to get the # of columns and rows from a csv using php
[Can be useful when parsing a csv, e.g: creating a table in a database from a csv - need to know # of columns]
2 ways
//using FGETCSV

$myFile = "THEFILE.csv";

$row = 0;
if (($handle = fopen($myFile , "r")) !== FALSE) {
    while (($data = [...]

How to get url with Jquery and PHP

current URL in address bar
PHP
$pageURL= $pageURL= $_SERVER["REQUEST_URI"].$_SERVER["REQUEST_URI"];
Jquery
$(document).ready(function() {
var pathname = window.location.pathname;
alert (pathname);
});

Jquery Image area select Z-index issue

If you try using PHP & jQuery image upload and crop [http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop/]
with some sort of modal like popup functionality, you will notice that the imgareaselect selection does not have proper zindex value,
although this plugin is using 0.6 version and 0.8/0.9 claims to have added zindex option, still doesnt seem to work
so grab 0.6 from link [...]

Jquery/CSS menu generator

Jquery UI demos http://jqueryui.com/demos/
CSS menu generator http://www.cssmenumaker.com/

Simple 2 column div layout [css]

Simple 2 column layout with a header using css.
The HTML
<html>
<link rel="stylesheet" type="text/css" href="style.css" />

<div id="wrap">
<div id="header"> HEADER</div>
<div id="sidebar"> SIDEBAR</div>
<div id="main"> BODY</div>
</div>

</html>
div#wrap
{
 margin:0px auto;
 width:800px;
}

div#header
{
width:800px;
height:30px;
float:left;
}

div#sidebar
{
width:100px;
float:left;
height:30px;
}

div#main
{
width:700px;
height:30px;
float:left
}
RESULT [copying image of this http://www.james-blogs.com/2009/05/15/website-layouts-with-sidebars/]
[so result is actually sidebar first then content]

Todays date selected in date fields

POOR mans way of doing this, 3 combo box’s with day/month/year, with todays date already selected,
using my previous changing variable name method
<?php
$day = date("d");
$month = date("m");
$year = date("y");

${’daysel’.$day} = ’selected="selected"’;
${’monthsel’.$month} =  ’selected="selected"’;
${’yearsel’.$year} = ’selected="selected"’;
?>

<html>
<form>
<table>
<tr>
<td><select name="day">
    <option value="01" <?php echo $daysel01; ?>>1</option>
    <option value="02" <?php echo $daysel02; ?>>2</option>
    <option value="03" <?php echo $daysel03; [...]

Check for checkbox’s [PHP]

To check which checkbox is selected, or if both are selected, in PHP
<input type="checkbox" name="coupons[]" value="1" >
<input type="checkbox" name="coupons[]" value="2" >
checker in php
if (isset($_POST[’Submit’])) {
$state=$_POST[’coupons’];
foreach ($state as $statename)
{
$x = $statename;
$ugh .= $x;
}
if 1 is selected, result will be 1
if 2 is selected result will be 2
if both are selected, result will be 12
go forward using [...]

If you need to add several emails, to refer a friend without asking the user to add all in separated by commas !
Code below provides separate field, where user can add individual email and press ADD, emails are then added automatically, separated by a comma “,” . There is an extra comma at the end [...]