|
Posted by petersprc on 10/05/06 21:08
You can use phpMyAdmin. Click the Insert icon in the Action column when
viewing your database tables.
You can also use MySQL Query Browser which is a MySQL front-end for
windows:
http://www.mysql.com/products/tools/query-browser/
Using php code and the MDB2 API you can do something like the
following:
<?
// Include the PEAR library
require_once('PEAR.php');
require_once('MDB2.php');
// This function accesses the database
function doit()
{
// Setup error handling for this script
error_reporting(E_ALL);
PEAR::setErrorHandling(PEAR_ERROR_DIE);
// Connect to the database using MDB2
$db =& MDB2::singleton(
'mysql://user:password@localhost/database');
$portOpt = $db->getOption('portability');
$db->setOption('portability', $portOpt ^ MDB2_PORTABILITY_FIX_CASE);
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
$db->loadModule('Extended');
// Define the row data
$row = array(
'titel' => 'The Titel',
'bericht' => 'Bericht',
'datum' => 'datum'
);
// Insert the row
$db->extended->autoExecute('myTable', $row,
MDB2_AUTOQUERY_INSERT);
// Get the inserted row ID
$id = $db->lastInsertID('myTable', 'id');
echo "Inserted a new row with ID $id.";
}
doit();
?>
More info about MDB2 here:
http://oss.backendmedia.com/MDB2/
Best Regards,
John Peters
µ wrote:
> I've made a database with phpmyadmin.
> Now I want to add text to the fields i"ve made.
> Can i do this trough phpmyadmin or how can i do this?
>
> I've got these fields.
> id int(11) No Null auto_increment
> titel varchar(50) No Null
> bericht text No Null
> datum varchar(16) No Null
>
> Can I add text to these fields from phpmyadmin?
> Or do i have to use php to fill it?
> Could someone please help me make a php page that can fill this
> database?
> My aim is not to use this, but to learn how i can do it myself.
> I'm a newbie to mysql and php but willing to learn...
>
> Thanks
Navigation:
[Reply to this message]
|