Coda Clips

Php Multi Line Assignment

$<<**SelectionInsertionPlaceholder**>> = <<<TEXT
Row 1
Row 2
TEXT;

Added to by Cipa

Install Clip


CI Controller

<?php
class <<**SelectionInsertionPlaceholder**>> extends Controller {
	function <<**SelectionInsertionPlaceholder**>>() {
		parent::Controller();
		$this->load->model('<<**SelectionInsertionPlaceholder**>>s');  // Load Model
	}
	function index() {
		$data['title'] = '<<**SelectionInsertionPlaceholder**>>';
		$data['heading'] = '<<**SelectionInsertionPlaceholder**>> List';
		$data['query'] = $this-><<**SelectionInsertionPlaceholder**>>->get();
		$this->load->view('<<**SelectionInsertionPlaceholder**>>_list', $data);
	}
}
?>

Added to by John Huh

Install Clip


require once php file

require_once('<<**SelectionInsertionPlaceholder**>>.php');

Added to by ndub

Install Clip


include_once php file

include_once('<<**SelectionInsertionPlaceholder**>>.php');

Added to by ndub

Install Clip


include php file

include('<<**SelectionInsertionPlaceholder**>>.php');

Added to by ndub

Install Clip


php tags with echo variable

<?php echo $<<**SelectionInsertionPlaceholder**>>; ?>

Added to by ndub

Install Clip


MySQL Dump by PHP

<?php
$server = "myHost";
$user = "myUser";
$pass = "myPassword";
$db = "myDb";
mysql_connect($server, $user, $pass);
mysql_select_db($db);
$tables = mysql_list_tables($db);
while ($td = mysql_fetch_array($tables))
{
$table = $td[0];
$r = mysql_query("SHOW CREATE TABLE `$table`");
if ($r)
{
$insert_sql = "";
$d = mysql_fetch_array($r);
$d[1] .= ";";
$SQL[] = str_replace("\n", "", $d[1]);
$table_query = mysql_query("SELECT * FROM `$table`");
$num_fields = mysql_num_fields($table_query);
while ($fetch_row = mysql_fetch_array($table_query))
{
$insert_sql .= "INSERT INTO $table VALUES(";
for ($n=1;$n<=$num_fields;$n++)
{
$m = $n - 1;
$insert_sql .= "'".mysql_real_escape_string($fetch_row[$m])."', ";
}
$insert_sql = substr($insert_sql,0,-2);
$insert_sql .= ");\n";
}
if ($insert_sql!= "")
{
$SQL[] = $insert_sql;
}
}
}
echo implode("\r", $SQL);
?>

Added to by Dawson

Install Clip


Write to file

<?php
$text=("Hello World, Please Replace Me!");
$write_to_file=fopen("SimpleTextFile.txt","a");
fwrite($write_to_file,$text);
fclose($write_to_file);
echo ("File successfully written");
?>

Added to by Dawson

Install Clip