MySql Results显示的是id号而不是单词

时间:2014-03-23 01:54:18

标签: php mysql join

我有一份我填写的表格,一旦提交,它将与您的提交一起返回成功留言。 一切都很完美,除了我无法弄清楚如何让成功的消息显示给定变量的单词。例如:

在我提交参赛作品后,你会得到一个像这样的出局

您的通话详情 会计问题 (2)来自迈克尔,关于(1) 所采取的行动: 会计 - 更改密码。 这个问题已解决? (1)

我想说的是 帐户问题 关于(密码重置)的来自Michael的(来电) 所采取的行动: 会计 - 更改密码 此问题已解决? (是)

我曾尝试过左连接,但我不确定我是否做得对。 这是我的代码 -

if(isset($_POST['new_support'])) {

    $tech_id = $_POST['tech_id'];
    $callform_id = $_POST['callform_id'];
    $issues_id = $_POST['issues_id'];
    $cbr = $_POST['cbr'];
    $custname = $_POST['custname'];
    $connection_id = $_POST['connection_id'];
    $os_id = $_POST['os_id'];
    $device_id = $_POST['device_id'];
    $email_id = $_POST['email_id'];
    $comments = $_POST['comments'];
    $resolved_id = $_POST['resolved_id'];
    $address_id = $_POST['address_id'];
    $date = time();

    if($error == '') {

    $sql = "INSERT INTO support (tech_id, callform_id, issues_id, account_id, connection_id, router_id, connectedto_id, os_id, device_id, wired_id, email_id, hosting_id, customer_id, resolved_id, address_id, cbr, custname, comments)
                            VALUES ('$tech_id', '$callform_id', '$issues_id', '$account_id', '$connection_id', '$router_id', '$connectedto_id', '$os_id', '$device_id', '$wired_id', '$email_id', '$hosting_id', '$customer_id', '$resolved_id', '$address_id', '$cbr', '$custname', '$comments')";

    $query = mysql_query($sql) or die("Snilbogs ".mysql_error());

$sql2 = "SELECT * FROM support LEFT JOIN callform ON support.callform_id = callform.id LEFT JOIN issues ON support.issues_id = issues.id LEFT JOIN account ON support.account_id = account.id LEFT JOIN connection ON support.connection_id = connection.id LEFT JOIN router ON support.router_id = router.id LEFT JOIN connectedto ON support.connectedto_id = connectedto.id LEFT JOIN os ON support.os_id = os.id LEFT JOIN device ON support.device_id = device.id LEFT JOIN wired ON support.wired_id = wired.id LEFT JOIN email ON support.email_id = email.id LEFT JOIN hosting ON support.hosting_id = hosting.id LEFT JOIN resolved ON support.resolved_id = resolved.id WHERE cbr=$cbr";

$result = mysql_query($sql2) or die ("Snilbogs something went wrong here".mysql_error());

while($row = mysql_fetch_array($result)); {
    echo $row['callform_id'];

    echo "<h2>Success!</h2>";
    echo "<div class='success_message'>Thank you! </div>";

    echo "<h2>Details of your call</h2>";

    echo "<ul class='success-reg'>";
    if($issues_id == '1'){
    echo "<li><span class='success-info'><b>Accounting Issues</b></span><br />
               ($callform_id) from $custname, regarding a $account_id<br />
                       Actions Taken: <br />
                       $comments.<br />
                      This issus is Resolved? $resolved_id <br />";
    }
}

if(!isset($_POST['new_support']) || $error != '') {

echo $error;

1 个答案:

答案 0 :(得分:0)

这很简单,您只需要从表支持中获取内容。您必须在SELECT中指定您还需要连接表中的列。