hydraulicpump Posted March 15, 2014 Share Posted March 15, 2014 hello I am looking for help on a sql problem. Not sure if I have a statement mixed up or not but the table simply won't render. Any help would be greatly appreciated. Database name = test I have two tables table 1 = parts table 2 = parts_pricing The main recordset name is RSparts Please see my current php code - $maxRows_RSparts = 10; $pageNum_RSparts = 0; if (isset($_GET['pageNum_RSparts'])) { $pageNum_RSparts = $_GET['pageNum_RSparts']; } $startRow_RSparts = $pageNum_RSparts * $maxRows_RSparts; $colname1_RSparts = "-1"; if (isset($_GET['figno'])) { $colname1_RSparts = $_GET['figno']; } $colname2_RSparts = "-1"; if (isset($_GET['modelno'])) { $colname2_RSparts = $_GET['modelno']; } mysql_select_db($database_test, $test); $query_RSparts = sprintf("SELECT * FROM parts INNER JOIN partspricing ON partspricing.sellingprice=parts.partID WHERE figno = %s AND modelno = %s ORDERBY ACS ", GetSQLValueString($colname1_RSparts, "text"),GetSQLValueString($colname2_RSparts, "text")); $query_limit_RSparts = sprintf("%s LIMIT %d, %d", $query_RSparts, $startRow_RSparts, $maxRows_RSparts); $RSparts = mysql_query($query_limit_RSRSparts, $test) or die(mysql_error()); $row_RSparts = mysql_fetch_assoc($RSparts; if (isset($_GET['totalRows_RSparts'])) { $totalRows_RSparts = $_GET['totalRows_RSparts']; } else { $all_RSparts = mysql_query($query_RSparts, $test); $totalRows_RSRSparts = mysql_num_rows($all_RSparts); } $totalPages_RSparts = ceil($totalRows_RSparts/$maxRows_RSparts)-1; Table setup; <table> <tr> <td>Key No.</td> <td>Part Number</td> <td>Description</td> <td>QTY</td> <td>S/N Break</td> <td>Availabilty</td> <td>Price</td> </tr> <?php do { ?> <tr> <td><?php echo $row_RSparts['keyno']; ?></td> <td><?php echo $row_RSparts['partno']; ?></td> <td><?php echo $row_RSparts['description']; ?></td> <td><?php echo $row_RSparts['qty']; ?></td> <td><?php echo $row_RSparts['snbreak']; ?></td> <td><?php echo $row_RSparts['availability']; ?></td> <td><?php echo $row_RSparts['sellingprice']; ?></td> </tr> <?php } while ($row_RSparts = mysql_fetch_assoc($RSparts)); ?> If I leave out parts INNER JOIN partspricing ON partspricing.sellingprice=parts.partID the table works and renders fine or if I leave out WHERE figno = %s AND modelno = %s ORDERBY ACS the table renders fine. I am missing something here. If I leave it as is the table will not render at all. Hopefully this is something simple any help would be greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/286992-issue-with-inner-join-and-where-statements/ Share on other sites More sharing options...
ginerjm Posted March 15, 2014 Share Posted March 15, 2014 Do you have error checking turned on? Quote Link to comment https://forums.phpfreaks.com/topic/286992-issue-with-inner-join-and-where-statements/#findComment-1472717 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.