elentz Posted November 11, 2007 Share Posted November 11, 2007 I must not be seeing the forest for the trees! I have a query that works fine in phpmyadmin. I use phpmyadmin to create the php code. When I run the query all I get is an output of the query. I know this is incredibly simple but I just can't see the error. Thanks for looking at this. <?//**********************Database Connection************* $conn = mysql_connect("localhost", "admin", "9axmy425"); mysql_select_db ('vtigercrm50',$conn); //****************************************************** $sql = 'SELECT SUM((vtiger_inventoryproductrel.quantity) * (vtiger_inventoryproductrel.listprice))' . ' from vtiger_inventoryproductrel' . ' where vtiger_inventoryproductrel.id = \'17193\''; $result = mysql_query($sql,$conn); Echo "$sql"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/76860-solved-driving-me-crazy/ Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 You didn't fetch a result set and mysql returns the row as an numerically indexed array, so call the element by the index <?php //**********************Database Connection************* $conn = mysql_connect("localhost", "admin", "9axmy425"); mysql_select_db ('vtigercrm50',$conn); //****************************************************** $sql = 'SELECT SUM((vtiger_inventoryproductrel.quantity) * (vtiger_inventoryproductrel.listprice))' . ' from vtiger_inventoryproductrel' . ' where vtiger_inventoryproductrel.id = \'17193\''; $result = mysql_query($sql,$conn); $row = mysql_fetch_row($result); echo $row[0]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/76860-solved-driving-me-crazy/#findComment-389158 Share on other sites More sharing options...
elentz Posted November 11, 2007 Author Share Posted November 11, 2007 Thanks Daukan That worked just right with one exception. I got the result I wanted which was 9350.15000. How do I make that 9350.15? And to take it a step further how do I make it 9,350.15? Thanks for all your help! Quote Link to comment https://forums.phpfreaks.com/topic/76860-solved-driving-me-crazy/#findComment-389193 Share on other sites More sharing options...
tippy_102 Posted November 11, 2007 Share Posted November 11, 2007 The info on this page will help you with the formatting: http://ca3.php.net/number_format Quote Link to comment https://forums.phpfreaks.com/topic/76860-solved-driving-me-crazy/#findComment-389195 Share on other sites More sharing options...
elentz Posted November 11, 2007 Author Share Posted November 11, 2007 Thanks Guys for all your help!! Quote Link to comment https://forums.phpfreaks.com/topic/76860-solved-driving-me-crazy/#findComment-389223 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.