Jump to content

takisis666

New Members
  • Posts

    3
  • Joined

  • Last visited

takisis666's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. That fixed the the issue somewhat, now I am getting on the first row just one cell, on the second row 4 cells, and on the final row 3 cells.
  2. I am populating a table from a database. The data is being retrieved correctly however it is not being displayed correctly. This is how I want it to be displayed: +----------------------------------------------------+ | vehicle 1 | vehicle 2 | vehicle 3 | vehicle 4 | |-----------------------------------------------------| | vehicle 5 | vehicle 6 | vehicle 7 | vehicle 8 | |-----------------------------------------------------| | vehicle 9 | veh 10 | veh 11 | veh 12 | +----------------------------------------------------+ This is what I am getting: +----------------------------------------------------+ | vehicle 1 | vehicle 1 | vehicle 1 | vehicle 1 | |-----------------------------------------------------| | vehicle 2 | vehicle 2 | vehicle 2 | vehicle 2 | |-----------------------------------------------------| | vehicle 3 | vehicle 3 | vehicle 3 | vehicle 3 | +----------------------------------------------------+ Here is my code: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $conn=mysqli_connect("localhost","root","","ezwayautos"); if($conn) { $sql="SELECT * FROM vehicles ORDER BY RAND() LIMIT 12"; $result=mysqli_query($conn,$sql); } if(! $result ) { die('Could not get data: ' . mysqli_error($conn)); } $rows = 3; $cols = 4; echo "<table>"; while($row = mysqli_fetch_assoc($result)) { for($tr=1;$tr<=$rows;$tr++) { echo "<tr>"; for($td=1;$td<=$cols;$td++) { echo "<td height='160' valign='top' class='featured'>"; echo "<div class='Image-Thumbnail'>"; echo "<a href=''>"; echo "<img src='".$row['image']."' width='160' height='54' alt='".$row['vehicle_name']."'>"; echo "</a>"; echo "</div> <a href=''>" .$row['vehicle_name']. "</a>"; echo "</td>"; } echo "</tr>"; } } echo "</table>"; ?> Please help
×
×
  • 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.