Jump to content

[SOLVED] Embarassed to even ask


elentz

Recommended Posts

I am trying to set up a simple output to my screen the results from a query.  The query will get infor from a Mysql DB from several tables.  That part I have worked out.  The embarassing part is that I want to take each field I get from the query and echo or print it to the screen.  Eventually I want to take this information and apply it to FPDF and make a PDF out of it.  Tight now I am stumped on getting the info to a page to make sure I am extracting the info.  Here is what I have so far:

//******************************************************
<?php
// Connection to the Database
//******************************************************

      $conn = mysql_connect("localhost", "admin", "xxxxxxxxx");
      mysql_select_db ('vtigercrm50',$conn);

//******************************************************
//******Query to get the ticket information*************
$sql = 'SELECT'
        . ' `vtiger_troubletickets`.`ticketid`,'
        . ' `vtiger_ticketcf`.`cf_534`,'
        . ' `vtiger_ticketcf`.`cf_536`,'
        . ' `vtiger_ticketcf`.`cf_538`,'
        . ' `vtiger_ticketcf`.`cf_540`,'
        . ' `vtiger_troubletickets`.`title`,'
        . ' `vtiger_troubletickets`.`description`,'
        . ' `vtiger_troubletickets`.`parent_id`,'
        . ' `vtiger_account`.`accountid`,'
        . ' `vtiger_accountshipads`.`ship_city`,'
        . ' `vtiger_accountshipads`.`ship_street`,'
        . ' `vtiger_accountshipads`.`ship_code`,'
        . ' `vtiger_accountshipads`.`ship_state`,'
        . ' `vtiger_account`.`phone`,'
        . ' `vtiger_accountscf`.`cf_472`,'
        . ' `vtiger_accountscf`.`cf_476`,'
        . ' `vtiger_accountscf`.`cf_464`,'
        . ' `vtiger_accountscf`.`cf_478`,'
        . ' `vtiger_accountscf`.`cf_484`,'
        . ' `vtiger_accountscf`.`cf_486`,'
        . ' `vtiger_accountscf`.`cf_468`'
        . ' FROM'
        . ' `vtiger_troubletickets`'
        . ' Inner Join `vtiger_ticketcf` ON `vtiger_troubletickets`.`ticketid` = `vtiger_ticketcf`.`ticketid`'
        . ' Inner Join `vtiger_account` ON `vtiger_troubletickets`.`parent_id` = `vtiger_account`.`accountid`'
        . ' Inner Join `vtiger_accountshipads` ON `vtiger_account`.`accountid` = `vtiger_accountshipads`.`accountaddressid`'
        . ' Inner Join `vtiger_accountscf` ON `vtiger_account`.`accountid` = `vtiger_accountscf`.`accountid`
Where 'vtiger_troubletickets'.'ticketid' = '17271'';

//************End Query****************

$result=mysql_query($sql);
$title = mysql_result(title);

echo $title;
?>

 

Thanks for any suggestions anyone might have

Link to comment
Share on other sites

Better to use mysql_fetch_assoc then mysql_result:

$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);

echo '<pre>' . print_r($row, true) . '</pre>';

 

$row will be an associative array. I use print_r above to display the contents of the $row array.

Link to comment
Share on other sites

Thanks wildteen for the speedy reply.  That got the whole array, now how do I selectively show the fields I want?  Lets say I want to show cf_476 and ticketid.  What I need is to be able to put those individual results into a cell in the pdf.

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.