anthony-needs-you Posted August 27, 2009 Share Posted August 27, 2009 can anyone see why this: <?php include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/config.php'); include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/opendb.php'); ?> <table cellspacing="3" cellpadding="3"> <?php $query = "SELECT id, vImage, vName, vDesc, vPrice FROM vehicles WHERE vCategory = 'lease' ORDER BY id"; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if(mysql_num_rows($result)==0) { echo(' <span class="noVehicles"><strong>No Vehicles Listed</strong></span> '); } while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_array($result)) { if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo '<td><div class="stocklisting-row"> <div class="stockphoto"><img src="vehicles/<?php echo $vImage;?>" width="125" /></div> <div class="stocktext"> <div class="stockname"><?php echo $vName;?></div> <div class="stockdesc"><?php echo $vDesc;?></div> <div class="stockprice">£<?php echo $vPrice;?> a month</div> <div class="stockmore"><a href="specification.php?id=<?php echo $id;?>">view details</a></div> </div> </div></td>'; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } } ?> </tr> </table> <?php include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/closedb.php'); ?> doesnt pull the results in this area: echo '<td><div class="stocklisting-row"> <div class="stockphoto"><img src="vehicles/<?php echo $vImage;?>" width="125" /></div> <div class="stocktext"> <div class="stockname"><?php echo $vName;?></div> <div class="stockdesc"><?php echo $vDesc;?></div> <div class="stockprice">£<?php echo $vPrice;?> a month</div> <div class="stockmore"><a href="specification.php?id=<?php echo $id;?>">view details</a></div> </div> </div></td>'; it displays the correct rows just with empty values? I think this part maybe wrong: while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_array($result)) Quote Link to comment https://forums.phpfreaks.com/topic/172140-code-not-pulling-results-out/ Share on other sites More sharing options...
Andy-H Posted August 27, 2009 Share Posted August 27, 2009 while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_assoc($result)) Quote Link to comment https://forums.phpfreaks.com/topic/172140-code-not-pulling-results-out/#findComment-907632 Share on other sites More sharing options...
PFMaBiSmAd Posted August 27, 2009 Share Posted August 27, 2009 Note: list() only works on numerical arrays and assumes the numerical indices start at 0. You must use mysql_fetch_row() or you must use mysql_fetch_array() with MYSQL_NUM as the second parameter. Quote Link to comment https://forums.phpfreaks.com/topic/172140-code-not-pulling-results-out/#findComment-907640 Share on other sites More sharing options...
anthony-needs-you Posted August 27, 2009 Author Share Posted August 27, 2009 tried them, but still nothing The code displays the right number of columns and rows, just no data. . . Quote Link to comment https://forums.phpfreaks.com/topic/172140-code-not-pulling-results-out/#findComment-907653 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.