我首先要谈谈Joomla! 开发并建立了非常简单的模块。
我如何建立包含3个文本领域的表格,然后将已输入的数值列入数据库表?
我首先要谈谈Joomla! 开发并建立了非常简单的模块。
我如何建立包含3个文本领域的表格,然后将已输入的数值列入数据库表?
举这个例子:
我们将把用户名头和最后写到一张桌上。
在您的数据库中建立一个表格。 注
我们将称之为“姓名”。 因此,我们将把我们的表格称为“职务——名称”。
在PHPMyAdmin(或你使用的任何工具)的行文中,Kum公司要创建新的表格:
CREATE TABLE `databasename`.`jos_names` (`id` int(11) NOT NULL auto_increment, `firstname` VARCHAR(100), `lastname` VARCHAR(100), PRIMARY KEY (`id`) )
为了简化工作,我们将把结果放在同一个网页上。 让我们建立这样的形式:
<?php
/** post form to db module **/
// No direct access
defined( _JEXEC ) or die( Restricted access );
//--POST YOUR FORM DATA HERE-->
$fname = $_POST[ fname ];
$lname = $_POST[ lname ];
//--END POST YOUR FORM DATA---|
//--build the form------------>
?>
<form name="names" id="names" action="<?php echo JURI::current(); ?>" method="post">
<p><input type="text" name="fname" id="fname" value="" /></p>
<p><input type="text" name="lname" id="lname" value="" /></p>
<p><input id="submit" name="submit" type="submit" value="Submit Names" /></p>
</form>
//--END BUILD THE FORM--------|
<?
if( (isset($lname)) || (isset($fname)) ) {
//first name or last name set, continue-->
$data =new stdClass();
$data->id = NULL;
$data->firstname = $fname;
$data->lastname = $lname;
$db = JFactory::getDBO();
$db->insertObject( #__names , $data, id);
} else {
echo <h4>One Field Is Required!</h4> ;
}
?>
这样做。 如果你撰写了传统的Joomla模块,这应该是你的助手。 php档案。
NOTES: Only include the "die" script once in a joomla document.. (defined( _JEXEC )..
日 本研究所:现时()自动读到目前的URL网页。 如果你呼呼应JRI:同时();在网页上与url ,那么它将显示同样的链接。
重要的是,“行动”指的是确切行动。 敦促你公布这一模块。
此外,将数据张贴到SELF被认为是不良的做法,但是,如果你建造一个部件或一个gin子,那么你就应该像这个例子那样把表格张贴到SELF。 (JURI:当值;)
在Joomla框架中,没有必要宣布你的数据库名称、用户名或密码,因为Joomla已经“陷入困境”。 因此,在joomla, 而不是查询databasename
。 事实上,在处理 d问和Joomla时,这是最佳的做法,因为用户不必使用预设合同,joomla自动以任何预设办法取代“#”。 在我的案件中,“第”等于“工作”。
在询问桌子时注意,确保你以数据库的实际名称取代<编码>数据库名称<>。
这样做。
If for some reason you are unable to post data: 1) Make sure the form doesn t redirect to a different page when you click submit. If it does, change the form action"" to the absolute url to where this page is published.. then go from there.
2) Sometimes the $data =new method doesn t work. This depends on how you set up your module, functions and classes. Here is an alternative:
$db =& JFactory::getDBO();
$query = "INSERT INTO `#__names` (`fname`, `lname`)
VALUES ($fname, $lname);";
$db->setQuery( $query );
$db->query();
您可以进行一项习俗调查,在简便的薄板上取得结果。
<?php // no direct access
defined( _JEXEC ) or die( Restricted access );
$category = $_REQUEST[ category ];
if(isset($category))
{
$db = JFactory::getDbo();
$db->setQuery("SELECT machine_id FROM j25_machinefinder_products WHERE category = $category ");
// Load the row.
$result = $db->loadRowList();
//your result will return here
print_r($result);
}
?>
<form action="" method="get" name="usedequipment">
<select name="category">
<?php foreach($hello as $category)
{
?><option value="<?php echo $category[0]; ?>"> <?php echo $category[0]; ?></option><?php
} ?>
</select>
<input type="submit" />
</form>
$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...
I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...
I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...
Does anybody know if it is possible to move some (not all) users from one ASP.NET membership database to another? (for the purposes of migrating some users to another database on another machine, but ...
Is it because of size? By the way, what is the limit of the size?
I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...
For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...
I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...