zed420 Posted December 26, 2008 Share Posted December 26, 2008 Hi All I wonder if someone can help me, I have a form where a customer has an option to book 1 or 2 vehicles by dropdown box so I’m using show/hide div for this which is working fine inserting the data all ok but when it comes to echo data it isn’t a pretty picture specially when I’m showing for two vehicles. The result is all fine its out putting all what he should do. Because there are empty spaces in database the table is not lining up properly . Is there any way I can get rid of these empty spaces when it comes to echo. This is how I’m inserting the data; if ($_POST['noOfVehicle'] == "1" ) { $query = "INSERT INTO restHotel VALUES ('$status',NULL,'$dateTime','$passType','$noOfVehicle','$custname1','$des1','$roomNo1','$tableNo1','$vehicleType1','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','')"; if (@mysql_query($query)) { echo '<p>Your vehicle request has been sent Successfully </p>'; } else { echo '<p>Error adding submitted Information: ' . mysql_error() . '</p>'; } } /************************************** Vehicle 2 ************************************/ if ($_POST['noOfVehicle'] == "2" ) { $query = "INSERT INTO restHotel VALUES ('$status',NULL,'$dateTime','$passType','$noOfVehicle','','','','','','$custname2','$des2','$roomNo2','$tableNo2','$vehicleType2','$custname3','$des3','$roomNo3','$tableNo3','$vehicleType3','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','')"; if (@mysql_query($query)) { echo '<p>Your vehicle request has been sent Successfully </p>'; } else { echo '<p>Error adding submitted Information: ' . mysql_error() . '</p>'; } } $query = "SELECT * FROM restHotel ORDER BY id DESC LIMIT 50"; $result = mysql_query($query)or die(mysql_error()); while ($row = mysql_fetch_array($result)) { extract($row); echo "<tr > <td align=center>" . $row['id'] . "</td> <td align=center>" . $row['dateTime'] . "</td> <td align=center>" . $row['passType'] . "</td> <td align=center>" . $row['noOfVehicle'] . "</td> <td align=center>" . $row['custname1'] . "</td> <td align=center>" . $row['des1'] . "</td> <td align=center>" . $row['roomNo1'] . "</td> <td align=center>" . $row['tableNo1'] . "</td> <td align=center>" . $row['vehicleType1'] . "</td></tr>"; echo "<tr><td></td><td></td><td></td><td></td> <td align=center>" . $row['custname2'] . "</td> <td align=center>" . $row['des2'] . "</td> <td align=center>" . $row['roomNo2'] . "</td> <td align=center>" . $row['tableNo2'] . "</td> <td align=center>" . $row['vehicleType2'] . "</td></tr>"; echo "<tr> <td></td><td></td><td></td><td></td> <td align=center>" . $row['custname3'] . "</td> <td align=center>" . $row['des3'] . "</td> <td align=center>" . $row['roomNo3'] . "</td> <td align=center>" . $row['tableNo3'] . "</td> <td align=center>" . $row['vehicleType3'] . "</td></tr>"; } ?></table></div> Thanks Zed Quote Link to comment https://forums.phpfreaks.com/topic/138503-how-to-eliminate-empty-spaces/ Share on other sites More sharing options...
zed420 Posted December 27, 2008 Author Share Posted December 27, 2008 This is what it looks like [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/138503-how-to-eliminate-empty-spaces/#findComment-724211 Share on other sites More sharing options...
zed420 Posted December 27, 2008 Author Share Posted December 27, 2008 Anyone has any ideas???? Quote Link to comment https://forums.phpfreaks.com/topic/138503-how-to-eliminate-empty-spaces/#findComment-724427 Share on other sites More sharing options...
liad Posted December 27, 2008 Share Posted December 27, 2008 You can echo " " wherever there is no value. Quote Link to comment https://forums.phpfreaks.com/topic/138503-how-to-eliminate-empty-spaces/#findComment-724431 Share on other sites More sharing options...
CroNiX Posted December 29, 2008 Share Posted December 29, 2008 if you put this just before your extract($row); it should convert them to html spaces (which is required for an empty tabledata to display properly. foreach($row as $k => $v) { if($v == NULL) { $row[$k] = ' '; } } Quote Link to comment https://forums.phpfreaks.com/topic/138503-how-to-eliminate-empty-spaces/#findComment-725787 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.