Skip to content

Instantly share code, notes, and snippets.

@asika32764
Created October 24, 2013 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asika32764/7133611 to your computer and use it in GitHub Desktop.
Save asika32764/7133611 to your computer and use it in GitHub Desktop.
<?php
// index.php
$page = $_REQUEST['page'];
$page = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $page);
// page=aaa/bbb/ccc
// page=save_item
/*
* index.php
* source
* | -- aaa
* | |---bbb
* | |--- ccc.php
*/
echo $page_path = __DIR__ . '/source/' . $page . '.php';
require_once $path_path;
<?php
$array = array('a', 'b', 'c');
$items = array();
$item = array(
'id' => 20,
'title' => 'Foo',
'description' => 'Bar',
'created_time' => '2013-10-24 16:31:00'
);
for($i = 0; $i < 5; $i++)
{
$items[] = $item;
}
print_r($items);
echo $items[2]['title'];
echo "\n\n";
// ---------------------------
$items = array();
while($item = mysql_fetch_assoc($conn))
{
$items[] = $item;
}
// Model
// ---------------
// View
?>
<div>
<ul>
<?php foreach($items as $key => $item):?>
<li>
<a href="index.php?page=item&id=<?php echo $item['id'];?>">
<?php echo $item['title']; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment