0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

webarenaでubuntu その23

Posted at

概要

webarenaでubuntu18.04やってみた。
cheetanやってみた。

使用したライブラリー

create

<?php
	require_once 'config.php';
	require_once 'cheetan/cheetan.php';

	function action(&$c) {
	    if (count($_POST)) 
	    {
	        $c->test->insert($c->data['test']);
	    }
	}
?>
<form method="post" action="create.php">
	name<br />
	<input type="text" name="test/name" /><br />
	age<br />
	<input type="text" name="test/age" /><br />
	<input type="submit" value="new" />
</form>

read

<?php
	require_once './config.php';
	require_once './cheetan/cheetan.php';

	function action(&$c) {
	    $c->set('datas', $c->test->find());
	}
?>
<h1>manager</h1>
<p>
<a href="./create.php">Write new</a>
</p>
<table border="1" width="98%">
	<tr>
	<td>id</td>
	<td>name</td>
	<td>age</td>
	<td>r_time</td>
	<td>edit/del</td>
  	</tr>
<?php 
	foreach ($data["datas"] as $data)
	{ 
?>
	<tr>
	<td><?php print $data["id"]; ?></td>
	<td><?php print $data["name"]; ?></td>
	<td><?php print $data["age"]; ?></td>
	<td><?php print $data["r_time"]; ?></td>
	<td>
		<a href="./update.php?id=<?php print $data["id"]; ?>">Edit</a>&nbsp;
		<a href="./delete.php?id=<?php print $data["id"]; ?>">Del</a>
	</td>
	</tr>
<?php
	}
?>
</table>

update

<?php
	require_once 'config.php';
	require_once 'cheetan/cheetan.php';

	function action(&$c) {
	    if (count($_POST)) 
	    {
	        $c->test->update($c->data['test']);
	    }
	    $c->set('data', $c->test->findone('id=' . $_GET['id']));
	}
?>

<form method="post" action="update.php">
	name<br />
	<input type="text" name="test/name" value="<?php echo $data['data']['name']; ?>" /><br />
	age<br />
	<input type="text" name="test/age" value="<?php echo $data['data']['age']; ?>" /><br />
	<input type="hidden" name="test/id" value="<?php echo $data['data']['id']; ?>" />
	<input type="submit" value="update" />
</form>

delete

<?php
	require_once 'config.php';
	require_once 'cheetan/cheetan.php';

	function action(&$c) {
	    if (count($_POST)) 
	    {
	        $c->test->del('id=' . $_POST['id']);
	    }
	    $c->set('data', $c->test->findone('id=' . $_GET['id']));
	}
?>
<form method="post" action="delete.php">
	name<br />
	<?php echo $data['data']['name'];?><br />
	age<br />
	<?php echo $data['data']['age'];?><br />
	<input type="hidden" name="id" value="<?php echo $data['data']['id']; ?>" />
	<input type="submit" value="del" />
</form>

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?