【发布时间】:2012-08-17 01:30:41
【问题描述】:
tb1
-----------------
id | codetb1
-----------------
1 | code1,code2
2 | code2,code3
tb2
-----------------
codetb2 | cost
-----------------
code1 | $20
code2 | $40
code3 | $60
save.php -> 这就是我将复选框值插入数据库的方式。
$codetb1 = $_POST['codetb1'];
var_dump($codetb1);
// Setting up a blank variable to be used in the coming loop.
$allStyles = "";
// For every checkbox value sent to the form.
foreach ($typeocodetb1fvisit as $style) {
// Append the string with the current array element,
// and then add a comma and a space at the end.
$allStyles .= $style . ", ";
}
// Delete the last two characters from the string.
$allStyles = subs
tr($allStyles, 0, -2);
Result.php -> 这是我的连接以及如何获得结果
$query="SELECT * FROM tb1, tb2 WHERE
tb1.codetbl1 = tb2.codetbl2 AND
tb1.id='$id'";
大家好 - 非常感谢您的帮助。我有 2 个数据库(表 1 和表 2)。我希望将 2 个数据库相互链接。我很难做到这一点。例如,我尝试了爆炸,但我无法使其工作。
那么我怎样才能摆脱 codetb1 中的逗号并找到与 codetb2 匹配的方法。所以最后我可以得到成本。有什么想法吗?
【问题讨论】:
-
请尝试重新表述您的问题,以便其他人不需要阅读这些不清楚的句子。尽力而为——从他人那里获得适当的帮助可能取决于它。
标签: php mysql arrays explode implode