f.ismayil Posted May 14, 2011 Share Posted May 14, 2011 Looks like HTML problem. But can not put this question in HTML section cause it has PHP code. I have table. I have 3 rows. 1 of rows has rowspan with 2 other rows.Problem is when database is empty program should take one picture and put inside 2 cells of table. First picture sits inside td normally but second picture not fitting into td and gows out of <tr>. Do not know what to do. echo "<tr> <td rowspan='2' width='1000' height='600'> <div id='fadeshow1'></div> </td> <td valign='top' height='300' background='tilbud.jpg'>"; if(!mysql_num_rows($result)){ echo "<img src='note.jpg'>"; }else{ echo "<table border='1' width='120' style='table-layout:fixed' cellspacing='0'> <tr><td colspan='2'><center><b>Ukens tilbud</b></center><br></td></tr>"; while($row = mysql_fetch_array($result)){ echo "<tr><td>"; $product = $row["Product"]; $price = $row["Price"]; echo "$product"; echo "</td>"; echo "<td>" . "$price" . "</td></tr>"; } } echo "</table></td></tr>"; $query = "SELECT Product, Price FROM tilbud WHERE Period='Daglig'"; $result = mysql_query($query,$link_id) or die (mysql_error()); echo "<tr background='tilbud.jpg'> <td valign='top' height='300' width=120 background='tilbud2.jpg'>"; if(!mysql_num_rows($result)){ echo "<img src='note.jpg' width='120'>"; }else{ echo "<table border='1' width='120' style='table-layout:fixed' cellspacing='0'> <col width=110> <tr><td colspan=2><center><b>Dagens tilbud</b></center><br></td></tr>"; while($row = mysql_fetch_array($result)){ echo "<tr><td width='110'>"; $product = $row["Product"]; $price = $row["Price"]; echo "$product"; echo "</td>"; echo "<td>" . "$price" . "</td></tr>"; } echo "</table>"; } echo "</td></tr> Quote Link to comment Share on other sites More sharing options...
fugix Posted May 15, 2011 Share Posted May 15, 2011 might be because you forgot to encase one of your attributes in quotes...this <td valign='top' height='300' width=120 background='tilbud2.jpg'>"; needs to be changed to this <td valign='top' height='300' width='120' background='tilbud2.jpg'>"; Quote Link to comment Share on other sites More sharing options...
f.ismayil Posted May 15, 2011 Author Share Posted May 15, 2011 Thanks fugix for reply. I modified code as you said. Still the same thing. One <td> do not fit into <tr> and goes down. I even decreased width and height of picture. It also doesn't help Quote Link to comment Share on other sites More sharing options...
f.ismayil Posted May 15, 2011 Author Share Posted May 15, 2011 One more note. When remove second <img> tag and write just echo "a"; it also writes letter a in another row. if(!mysql_num_rows($result)){ echo "a"; } Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 15, 2011 Share Posted May 15, 2011 If your table is not displaying correctly it is probably due to your script outputting invalid HTML. Quote Link to comment Share on other sites More sharing options...
f.ismayil Posted May 15, 2011 Author Share Posted May 15, 2011 I have already found my own mistake. Closing </table> tag is not in correct place :-) echo "<tr>"; if(!mysql_num_rows($result)){ echo "<td valign='top' width='150' height='300' bgcolor='white' cellpadding='0'>"; echo "<img src='note.jpg'>"; }else{ echo "<td valign='top' width='150' height='300' background='tilbud2.jpg' cellpadding='0'> <table border='0' width='150' style='table-layout:fixed' cellspacing='0'> <col width='120'> <col width='30'> <tr><td colspan=2><center><b>Dagens tilbud</b></center><br></td></tr>"; while($row = mysql_fetch_array($result)){ echo "<tr><td>"; $product = $row["Product"]; $price = $row["Price"]; echo "$product"; echo "</td>"; echo "<td>" . "$price" . "</td></tr>"; } echo "</table>"; } echo "</td></tr> Quote Link to comment Share on other sites More sharing options...
crmamx Posted May 22, 2011 Share Posted May 22, 2011 If your table is not displaying correctly it is probably due to your script outputting invalid HTML. And if you get a totally useless reply to a question, what is that due to? Quote Link to comment 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.