farril Posted November 11, 2008 Share Posted November 11, 2008 hi there. ive got the following code <?php print"<td align>$getthreads3[showtime] </td>" ?> i need to align that column to the right. but because its using print it doesnt allow me to just add ="right" into it. is there a way to do this. and also, iv been told using print and echo arnt good programming practice, so how would i go about adding that line without using either? Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/ Share on other sites More sharing options...
Yesideez Posted November 11, 2008 Share Posted November 11, 2008 <td align="right"> Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687288 Share on other sites More sharing options...
DeanWhitehouse Posted November 11, 2008 Share Posted November 11, 2008 <?php echo "<td align='right'>".$getthreads3['showtime']."</td>"; ?> I believe this is what you are looking for. Edit: The second set were escaped, but this site seems to remove it in code tags. Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687291 Share on other sites More sharing options...
revraz Posted November 11, 2008 Share Posted November 11, 2008 No, since the 2nd set of double quotes will end the string echo "<td align='right'>$getthreads3['showtime']</td>"; Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687292 Share on other sites More sharing options...
farril Posted November 11, 2008 Author Share Posted November 11, 2008 when using that i get this error.. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\WAMP\www\NEW\News\news_board.php on line 281 Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687294 Share on other sites More sharing options...
DeanWhitehouse Posted November 11, 2008 Share Posted November 11, 2008 Fixed, trying to escape it doesn't work in the code tags. The working one is below. <?php echo "<td align="\right"\>".$getthreads3['showtime']."</td>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687295 Share on other sites More sharing options...
farril Posted November 11, 2008 Author Share Posted November 11, 2008 still not working :/ Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\WAMP\www\NEW\News\news_board.php on line 281 Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\WAMP\www\NEW\News\news_board.php on line 281 Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687298 Share on other sites More sharing options...
DeanWhitehouse Posted November 11, 2008 Share Posted November 11, 2008 OK, that is wierd. This one should <?php echo "<td align='right'>".$getthreads3['showtime']."</td>"; ?> although the array may be causing an error. if so <?php echo "<td align='right'>".$getthreads3[showtime]."</td>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687300 Share on other sites More sharing options...
farril Posted November 11, 2008 Author Share Posted November 11, 2008 neither cause an error. but neither align it to the right either :/ i thought right had to be in "'s to work? Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687301 Share on other sites More sharing options...
DeanWhitehouse Posted November 11, 2008 Share Posted November 11, 2008 No it doesn't, although the browser may vary on this. I believe that there may be a problem before this that is aligning the table data. Try <?php echo "<td align='right' style='text-align:right;'>".$getthreads3['showtime']."</td>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687304 Share on other sites More sharing options...
farril Posted November 11, 2008 Author Share Posted November 11, 2008 yup. that seems to have moved it to the right. thanks. is there anyway to specify how much i move it to the right? or just the variables left, right, and center? Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687306 Share on other sites More sharing options...
DeanWhitehouse Posted November 11, 2008 Share Posted November 11, 2008 You can use margins, e.g. style="margin-left:100px;" will move it 100px to the right, away from the left Quote Link to comment https://forums.phpfreaks.com/topic/132222-aligning-tables-using-php/#findComment-687309 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.