0

我是 mysql 的新手,我正在使用 joomla 2.5,通过一个表单模块我从 2 个字段中收集值,这些值(item1,item2)正确存储在 mysql 表(item1,item2)中,而且应该有自动存储用户 ID 和电子邮件。现在我可以正确地将值和电子邮件保存在表中,但不能保存用户 ID(joomla 中当前用户的),当我调用这些值时一切正常,直到我尝试按用户(或用户电子邮件 - mysql WHERE 命令进行过滤) ),我尝试了不同的语法但没有结果。

here's the mysql table (jos_schede)
id;  item1;    item2;   item3;
1;   value1;   value2;  email1 (current user email) 
2;   value3;   value4;  email2 (different user email) 
here i would like to store in another column the userID (current user)

这是我在 joomla 中添加的用于提取 db 值的脚本

<?php 
defined('_JEXEC') or die('Restricted access'); 
?>

<?php echo('the values are'); ?><br />
<?php

$user =& JFactory::getUser();
$userEmail = $user->get( 'email' );
$userID = $user->get( 'id' );

//connect to the server
$link = mysql_connect ("myhost", "myuser", "mypw");
if (!$link) {
die('Could not connect: ' . mysql_error());
}

//connect to the database
mysql_select_db ("mydatabase");

//query the database
$query = mysql_query("SELECT item1, item2, item3, id FROM jos_schede, jos_users WHERE    item3='*currentemail*'");

//fetch the results / convert results into an array
    WHILE($rows = mysql_fetch_array($query)):

    $id = $rows['id'];
        $item1 = $rows['item1'];
        $item2 = $rows['item2'];
    $item3 = $rows['item3'];

    echo "$userID<br>$item1<br>$item2<br>item3";

    endwhile;
?>

有人能告诉我哪里错了吗?谢谢你!

4

0 回答 0