twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Same error is still occuring. :-( Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645762 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Here is the full code I have, just in case I've messed up somewhere, so you can see: <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="simpletree2.css" /> </head> <?php $con = mysql_connect("mysql5.webdesignsbyliz.com","twilitegxa","minimoon"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("smrpg", $con); //get Sailor Moon's data from the "scout" table $result = mysql_query("SELECT * FROM scout where identity = 'Sailor Moon'") or die(mysql_error()); $row = mysql_fetch_array( $result ); $birthdatemonth = $row["birthdatemonth"]; $birthdateday = $row["birthdateday"]; $birthdateyear = $row["birthdateyear"]; $birthdate = $birthdatemonth . " " . $birthdateday . ", ". $birthdateyear; $identity = $row["identity"]; echo "<h1><center>$identity</center></h1>"; echo "<table border='0' width='100%'>"; // keeps getting the next row until there are no more to get echo "<tr><td width='25%'>"; echo "<b>Name:</b></td><td>"; echo $row['charactername']; echo "</td></tr><tr><td>"; echo "<b>Element Of Influence:</b></td><td>"; echo $row['elementofinfluence']; echo "</td></tr><tr><td>"; echo "<b>Age:</b></td><td>"; echo $row['age']; echo "</td></tr><tr><td>"; echo "<b>Birthdate:</b></td><td>"; echo $birthdate; echo "</td></tr><tr><td>"; echo "<b>Height:</b></td><td>"; echo $row['heightfeet']; echo "' " ; echo $row['heightinches']; echo """; echo "</td></tr><tr><td>"; echo "<b>Blood Type:</b></td><td>"; echo $row['bloodtype']; echo "</td></tr><tr><td>"; echo "<b>Hobbies:</b></td><td>"; echo $row['hobbies']; echo "</td></tr><tr><td>"; echo "<b>Favorite Color:</b></td><td>"; echo $row['favoritecolor']; echo "</td></tr><tr><td>"; echo "<b>Favorite Gemstone:</b></td><td>"; echo $row['favoritegemstone']; echo "</td></tr><tr><td>"; echo "<b>Favorite Food:</b></td><td>"; echo $row['favoritefood']; echo "</td></tr><tr><td>"; echo "<b>Least Favorite Food:</b></td><td>"; echo $row['leastfavoritefood']; echo "</td></tr><tr><td>"; echo "<b>Favorite School Subject:</b></td><td>"; echo $row['favoriteschoolsubject']; echo "</td></tr><tr><td>"; echo "<b>Least Favorite School Subject:</b></td><td>"; echo $row['leastfavoriteschoolsubject']; echo "</td></tr><tr><td>"; echo "<b>Strengths:</b></td><td>"; echo $row['strengths']; echo "</td></tr><tr><td>"; echo "<b>Weaknesses:</b></td><td>"; echo $row['weaknesses']; echo "</td></tr><tr><td>"; echo "<b>Goal:</b></td><td>"; echo $row['goal']; echo "..."; echo "</td></tr></table><p>"; echo $row['biography']; echo "</p>"; echo "</td></tr>"; echo "<tr><td> </td></tr>"; echo "</table>"; $result = mysql_query("SELECT * FROM stats where identity = 'Sailor Moon'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "<table width='100%' valign='top'><tr><td width='50%' align='right' valign='top'>\n"; // added align='right' valign='top' echo "<table width='100%' border='0' id='stats' align='right'>\n"; // keeps getting the next row until there are no more to get echo "<tr><td colspan='3' id='th'>Stats And Derived Values</td></tr>\n"; echo "<tr><td>\n"; echo "<b>Body:</b></td><td col class='right'>\n"; echo $row['body']; echo "</td></tr><tr><td>\n"; echo "<b>Mind:</b></td><td col class='right'>\n"; echo $row['mind']; echo "</td></tr><tr><td>\n"; echo "<b>Soul:</b></td><td col class='right'>\n"; echo $row['soul']; echo "</td></tr><tr><td>\n"; echo " </td></tr><tr><td>\n"; echo "<b>Health Points:</b></td><td col class='right'>\n"; echo $row['health']; echo "</td></tr><tr><td>\n"; echo "<b>Energy Points:</b></td><td col class='right'>\n"; echo $row['energy']; echo "</td></tr><tr><td>\n"; echo "<b>Attack Combat Value:</b></td><td col class='right'>\n"; echo $row['acv']; echo "</td><td col class='right'>\n"; // added </td> echo " ("; echo $row['acv_sa']; echo " for Sailor Scout Attack)"; echo "</td>\n"; echo "</td></tr><tr><td >\n"; echo "<b>Defense Combat Value:</b></td><td col class='right'>\n"; echo $row['dcv']; echo "</td><td col class='right'>\n"; // added </td> echo " ("; echo $row['dcv_sa']; echo " for Sailor Scout Attack)"; //echo "</td>\n"; // that's an extra one echo "</td></tr><tr><td>\n"; echo "<b>Total Character Points:</b></td><td col class='right'>\n"; echo $row['tcp']; echo "</td></tr>\n"; echo "</table>\n"; //while statement for character_attributes while($row = mysql_fetch_array( $result )) { if ($row['attribute_id']=="Scout Powers"){ echo "<tr><td>\n"; echo $row['attribute_id']; echo " "; echo $row['desc']; } elseif ($row['desc']!=""){ echo "<tr><td> \n"; //indent two spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } elseif ($row['sub']==1){ //not sure how to detect its subattributes, so you'll have to do that echo "<tr><td> \n"; //indent four spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } else{ //this is the defeault echo "<tr><td> \n"; //indent six spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } echo "</td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['level']; echo "</td><td width='2%'> </td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['points']; echo "</td><td width='2%'> </td></tr>\n"; //end while statement $result = mysql_query("SELECT * FROM character_attributes ORDER BY attribute_id ASC") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "</td><td valign='top' width='50%' rowspan='2'>\n"; // added this whole line echo "<table width='100%' border='0' id='stats' align='left'>\n"; echo "<tr><td colspan='7' id='th'>Character Attributes And Sub-Attributes</td></tr>\n"; echo "<tr class='sub'><td>Attribute/Sub-Attribute</td><td colspan='3' align='center'>Level</td><td colspan='3' align='center'>Points</td></tr>\n"; echo "<tr><td></td></tr>\n"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { echo "<tr><td>\n"; echo $row['attribute_id']; echo " "; echo $row['desc']; echo "</td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['level']; echo "</td><td width='2%'> </td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['points']; echo "</td><td width='2%'> </td></tr>\n"; } echo "</table></td></tr><tr><td valign='top' width='50%'>\n"; $result = mysql_query("SELECT * FROM character_defects where identity = 'Sailor Moon' ORDER BY defect_id ASC") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "<table border='0' width='100%' id='stats' align='right'>\n"; echo "<tr><td colspan='3' id='th'>Character Defects</td></tr>\n"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { echo "<tr><td>\n"; echo $row['defect_id']; echo " "; echo $row['desc']; echo "</td><td>\n"; echo $row['bp']; echo " BP"; echo "</td></tr>\n"; } echo "</table>\n"; echo "</td><td>\n"; echo "</td></tr></table>\n"; And the error would be line 207. I had some extra blank lines before. Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645766 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 Line 165 needed a }. <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="simpletree2.css" /> </head> <?php $con = mysql_connect("mysql5.webdesignsbyliz.com","twilitegxa","minimoon"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("smrpg", $con); //get Sailor Moon's data from the "scout" table $result = mysql_query("SELECT * FROM scout where identity = 'Sailor Moon'") or die(mysql_error()); $row = mysql_fetch_array( $result ); $birthdatemonth = $row["birthdatemonth"]; $birthdateday = $row["birthdateday"]; $birthdateyear = $row["birthdateyear"]; $birthdate = $birthdatemonth . " " . $birthdateday . ", ". $birthdateyear; $identity = $row["identity"]; echo "<h1><center>$identity</center></h1>"; echo "<table border='0' width='100%'>"; // keeps getting the next row until there are no more to get echo "<tr><td width='25%'>"; echo "<b>Name:</b></td><td>"; echo $row['charactername']; echo "</td></tr><tr><td>"; echo "<b>Element Of Influence:</b></td><td>"; echo $row['elementofinfluence']; echo "</td></tr><tr><td>"; echo "<b>Age:</b></td><td>"; echo $row['age']; echo "</td></tr><tr><td>"; echo "<b>Birthdate:</b></td><td>"; echo $birthdate; echo "</td></tr><tr><td>"; echo "<b>Height:</b></td><td>"; echo $row['heightfeet']; echo "&#39; " ; echo $row['heightinches']; echo "&#34;"; echo "</td></tr><tr><td>"; echo "<b>Blood Type:</b></td><td>"; echo $row['bloodtype']; echo "</td></tr><tr><td>"; echo "<b>Hobbies:</b></td><td>"; echo $row['hobbies']; echo "</td></tr><tr><td>"; echo "<b>Favorite Color:</b></td><td>"; echo $row['favoritecolor']; echo "</td></tr><tr><td>"; echo "<b>Favorite Gemstone:</b></td><td>"; echo $row['favoritegemstone']; echo "</td></tr><tr><td>"; echo "<b>Favorite Food:</b></td><td>"; echo $row['favoritefood']; echo "</td></tr><tr><td>"; echo "<b>Least Favorite Food:</b></td><td>"; echo $row['leastfavoritefood']; echo "</td></tr><tr><td>"; echo "<b>Favorite School Subject:</b></td><td>"; echo $row['favoriteschoolsubject']; echo "</td></tr><tr><td>"; echo "<b>Least Favorite School Subject:</b></td><td>"; echo $row['leastfavoriteschoolsubject']; echo "</td></tr><tr><td>"; echo "<b>Strengths:</b></td><td>"; echo $row['strengths']; echo "</td></tr><tr><td>"; echo "<b>Weaknesses:</b></td><td>"; echo $row['weaknesses']; echo "</td></tr><tr><td>"; echo "<b>Goal:</b></td><td>"; echo $row['goal']; echo "..."; echo "</td></tr></table><p>"; echo $row['biography']; echo "</p>"; echo "</td></tr>"; echo "<tr><td> </td></tr>"; echo "</table>"; $result = mysql_query("SELECT * FROM stats where identity = 'Sailor Moon'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "<table width='100%' valign='top'><tr><td width='50%' align='right' valign='top'>\n"; // added align='right' valign='top' echo "<table width='100%' border='0' id='stats' align='right'>\n"; // keeps getting the next row until there are no more to get echo "<tr><td colspan='3' id='th'>Stats And Derived Values</td></tr>\n"; echo "<tr><td>\n"; echo "<b>Body:</b></td><td col class='right'>\n"; echo $row['body']; echo "</td></tr><tr><td>\n"; echo "<b>Mind:</b></td><td col class='right'>\n"; echo $row['mind']; echo "</td></tr><tr><td>\n"; echo "<b>Soul:</b></td><td col class='right'>\n"; echo $row['soul']; echo "</td></tr><tr><td>\n"; echo " </td></tr><tr><td>\n"; echo "<b>Health Points:</b></td><td col class='right'>\n"; echo $row['health']; echo "</td></tr><tr><td>\n"; echo "<b>Energy Points:</b></td><td col class='right'>\n"; echo $row['energy']; echo "</td></tr><tr><td>\n"; echo "<b>Attack Combat Value:</b></td><td col class='right'>\n"; echo $row['acv']; echo "</td><td col class='right'>\n"; // added </td> echo " ("; echo $row['acv_sa']; echo " for Sailor Scout Attack)"; echo "</td>\n"; echo "</td></tr><tr><td >\n"; echo "<b>Defense Combat Value:</b></td><td col class='right'>\n"; echo $row['dcv']; echo "</td><td col class='right'>\n"; // added </td> echo " ("; echo $row['dcv_sa']; echo " for Sailor Scout Attack)"; //echo "</td>\n"; // that's an extra one echo "</td></tr><tr><td>\n"; echo "<b>Total Character Points:</b></td><td col class='right'>\n"; echo $row['tcp']; echo "</td></tr>\n"; echo "</table>\n"; //while statement for character_attributes while($row = mysql_fetch_array( $result )) { if ($row['attribute_id']=="Scout Powers"){ echo "<tr><td>\n"; echo $row['attribute_id']; echo " "; echo $row['desc']; } elseif ($row['desc']!=""){ echo "<tr><td> \n"; //indent two spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } elseif ($row['sub']==1){ //not sure how to detect its subattributes, so you'll have to do that echo "<tr><td> \n"; //indent four spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } else{ //this is the defeault echo "<tr><td> \n"; //indent six spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } echo "</td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['level']; echo "</td><td width='2%'> </td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['points']; echo "</td><td width='2%'> </td></tr>\n"; } //end while statement $result = mysql_query("SELECT * FROM character_attributes ORDER BY attribute_id ASC") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "</td><td valign='top' width='50%' rowspan='2'>\n"; // added this whole line echo "<table width='100%' border='0' id='stats' align='left'>\n"; echo "<tr><td colspan='7' id='th'>Character Attributes And Sub-Attributes</td></tr>\n"; echo "<tr class='sub'><td>Attribute/Sub-Attribute</td><td colspan='3' align='center'>Level</td><td colspan='3' align='center'>Points</td></tr>\n"; echo "<tr><td></td></tr>\n"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { echo "<tr><td>\n"; echo $row['attribute_id']; echo " "; echo $row['desc']; echo "</td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['level']; echo "</td><td width='2%'> </td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['points']; echo "</td><td width='2%'> </td></tr>\n"; } echo "</table></td></tr><tr><td valign='top' width='50%'>\n"; $result = mysql_query("SELECT * FROM character_defects where identity = 'Sailor Moon' ORDER BY defect_id ASC") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "<table border='0' width='100%' id='stats' align='right'>\n"; echo "<tr><td colspan='3' id='th'>Character Defects</td></tr>\n"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { echo "<tr><td>\n"; echo $row['defect_id']; echo " "; echo $row['desc']; echo "</td><td>\n"; echo $row['bp']; echo " BP"; echo "</td></tr>\n"; } echo "</table>\n"; echo "</td><td>\n"; echo "</td></tr></table>\n"; Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645769 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Okay, now I can see the page again with no errors, but there appears to be no changes. Also, I was thinking, since Scout Powers needs to be first on the list, I probably should assign it a a sub of 2, so we can include a statement for it as well, because right now it's lower in the list. Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645773 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Attributes Acrobatics through Strong Soul all have a sub value of 0 by the way, in case we need to use that. Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645774 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 Or, you could just assign a different 'sub' value to each scenario that you want. That would significantly simplify your if statement. For example: if sub is 1, don't indent at all, display attribute_id and desc else if sub is 2, indent two spaces and only display attribute_id else (if none of the above is trye), indent four spaces and only display desc I'm sure the above isn't exactly what you want, but you could easily write it out that way. Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645778 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 I think I have it so far as: if sub = 2, no indent and display before all others if sub = 1, indent x number of spaces and also display desc if sub = 0, no indent How would I write that exactly though? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645787 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Oh, and if desc is not blank, indent x number of spaces as well with a - at the beginning Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645788 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 <?php while($row = mysql_fetch_array( $result )) { if ($row['sub']==2){ echo "<tr><td>\n"; echo $row['attribute_id']; echo " "; echo $row['desc']; } elseif ($row['sub']==1){ echo "<tr><td> \n"; //indent two spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } elseif ($row['desc']!=""){ echo "<tr><td> - \n"; //indent four spaces with a dash echo $row['attribute_id']; echo " "; echo $row['desc']; } else{ //this is the defeault echo "<tr><td>\n"; //indent six spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } echo "</td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['level']; echo "</td><td width='2%'> </td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['points']; echo "</td><td width='2%'> </td></tr>\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645792 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 I wonder why it's not doing anything? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645820 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 What do you mean it's not doing anything? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645823 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 http://webdesignsbyliz.com/sailormoonrpg/test.php Still looks the same :-( Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645828 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 What's you whole code? and can you tell me what some of the items are in your DB table, so I know what is supposed to be treated how (I can't see what $row['sub'] is from your page). Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645840 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Here is the whole code for the page: <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="simpletree2.css" /> </head> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("smrpg", $con); //get Sailor Moon's data from the "scout" table $result = mysql_query("SELECT * FROM scout where identity = 'Sailor Moon'") or die(mysql_error()); $row = mysql_fetch_array( $result ); $birthdatemonth = $row["birthdatemonth"]; $birthdateday = $row["birthdateday"]; $birthdateyear = $row["birthdateyear"]; $birthdate = $birthdatemonth . " " . $birthdateday . ", ". $birthdateyear; $identity = $row["identity"]; echo "<h1><center>$identity</center></h1>"; echo "<table border='0' width='100%'>"; // keeps getting the next row until there are no more to get echo "<tr><td width='25%'>"; echo "<b>Name:</b></td><td>"; echo $row['charactername']; echo "</td></tr><tr><td>"; echo "<b>Element Of Influence:</b></td><td>"; echo $row['elementofinfluence']; echo "</td></tr><tr><td>"; echo "<b>Age:</b></td><td>"; echo $row['age']; echo "</td></tr><tr><td>"; echo "<b>Birthdate:</b></td><td>"; echo $birthdate; echo "</td></tr><tr><td>"; echo "<b>Height:</b></td><td>"; echo $row['heightfeet']; echo "' "; echo $row['heightinches']; echo """; echo "</td></tr><tr><td>"; echo "<b>Blood Type:</b></td><td>"; echo $row['bloodtype']; echo "</td></tr><tr><td>"; echo "<b>Hobbies:</b></td><td>"; echo $row['hobbies']; echo "</td></tr><tr><td>"; echo "<b>Favorite Color:</b></td><td>"; echo $row['favoritecolor']; echo "</td></tr><tr><td>"; echo "<b>Favorite Gemstone:</b></td><td>"; echo $row['favoritegemstone']; echo "</td></tr><tr><td>"; echo "<b>Favorite Food:</b></td><td>"; echo $row['favoritefood']; echo "</td></tr><tr><td>"; echo "<b>Least Favorite Food:</b></td><td>"; echo $row['leastfavoritefood']; echo "</td></tr><tr><td>"; echo "<b>Favorite School Subject:</b></td><td>"; echo $row['favoriteschoolsubject']; echo "</td></tr><tr><td>"; echo "<b>Least Favorite School Subject:</b></td><td>"; echo $row['leastfavoriteschoolsubject']; echo "</td></tr><tr><td>"; echo "<b>Strengths:</b></td><td>"; echo $row['strengths']; echo "</td></tr><tr><td>"; echo "<b>Weaknesses:</b></td><td>"; echo $row['weaknesses']; echo "</td></tr><tr><td>"; echo "<b>Goal:</b></td><td>"; echo $row['goal']; echo "..."; echo "</td></tr></table><p>"; echo $row['biography']; echo "</p>"; echo "</td></tr>"; echo "<tr><td> </td></tr>"; echo "</table>"; $result = mysql_query("SELECT * FROM stats where identity = 'Sailor Moon'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "<table width='100%' valign='top'><tr><td width='50%' align='right' valign='top'>\n"; // added align='right' valign='top' echo "<table width='100%' border='0' id='stats' align='right'>\n"; // keeps getting the next row until there are no more to get echo "<tr><td colspan='3' id='th'>Stats And Derived Values</td></tr>\n"; echo "<tr><td>\n"; echo "<b>Body:</b></td><td col class='right'>\n"; echo $row['body']; echo "</td></tr><tr><td>\n"; echo "<b>Mind:</b></td><td col class='right'>\n"; echo $row['mind']; echo "</td></tr><tr><td>\n"; echo "<b>Soul:</b></td><td col class='right'>\n"; echo $row['soul']; echo "</td></tr><tr><td>\n"; echo " </td></tr><tr><td>\n"; echo "<b>Health Points:</b></td><td col class='right'>\n"; echo $row['health']; echo "</td></tr><tr><td>\n"; echo "<b>Energy Points:</b></td><td col class='right'>\n"; echo $row['energy']; echo "</td></tr><tr><td>\n"; echo "<b>Attack Combat Value:</b></td><td col class='right'>\n"; echo $row['acv']; echo "</td><td col class='right'>\n"; // added </td> echo " ("; echo $row['acv_sa']; echo " for Sailor Scout Attack)"; echo "</td>\n"; echo "</td></tr><tr><td >\n"; echo "<b>Defense Combat Value:</b></td><td col class='right'>\n"; echo $row['dcv']; echo "</td><td col class='right'>\n"; // added </td> echo " ("; echo $row['dcv_sa']; echo " for Sailor Scout Attack)"; //echo "</td>\n"; // that's an extra one echo "</td></tr><tr><td>\n"; echo "<b>Total Character Points:</b></td><td col class='right'>\n"; echo $row['tcp']; echo "</td></tr>\n"; echo "</table>\n"; //while statement for character_attributes while($row = mysql_fetch_array( $result )) { if ($row['sub']==2){ echo "<tr><td>\n"; echo $row['attribute_id']; echo " "; echo $row['desc']; } elseif ($row['sub']==1){ echo "<tr><td> \n"; //indent two spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } elseif ($row['desc']!=""){ echo "<tr><td> - \n"; //indent four spaces with a dash echo $row['attribute_id']; echo " "; echo $row['desc']; } else{ //this is the defeault echo "<tr><td>\n"; //indent six spaces echo $row['attribute_id']; echo " "; echo $row['desc']; } echo "</td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['level']; echo "</td><td width='2%'> </td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['points']; echo "</td><td width='2%'> </td></tr>\n"; } //end while statement $result = mysql_query("SELECT * FROM character_attributes ORDER BY attribute_id ASC") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "</td><td valign='top' width='50%' rowspan='2'>\n"; // added this whole line echo "<table width='100%' border='0' id='stats' align='left'>\n"; echo "<tr><td colspan='7' id='th'>Character Attributes And Sub-Attributes</td></tr>\n"; echo "<tr class='sub'><td>Attribute/Sub-Attribute</td><td colspan='3' align='center'>Level</td><td colspan='3' align='center'>Points</td></tr>\n"; echo "<tr><td></td></tr>\n"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { echo "<tr><td>\n"; echo $row['attribute_id']; echo " "; echo $row['desc']; echo "</td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['level']; echo "</td><td width='2%'> </td><td width='2%'> </td><td width='1%' align='right'>\n"; echo $row['points']; echo "</td><td width='2%'> </td></tr>\n"; } echo "</table></td></tr><tr><td valign='top' width='50%'>\n"; $result = mysql_query("SELECT * FROM character_defects where identity = 'Sailor Moon' ORDER BY defect_id ASC") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "<table border='0' width='100%' id='stats' align='right'>\n"; echo "<tr><td colspan='3' id='th'>Character Defects</td></tr>\n"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { echo "<tr><td>\n"; echo $row['defect_id']; echo " "; echo $row['desc']; echo "</td><td>\n"; echo $row['bp']; echo " BP"; echo "</td></tr>\n"; } echo "</table>\n"; echo "</td><td>\n"; echo "</td></tr></table>\n"; In my table within my database, here are the fields: id, identity, attribute_id, sub, desc, level, and points Does that help? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645842 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 Partially. I know what your fields are. From looking at your site, I sorta know what attribute_id and desc are for each row, but I have no way of knowing what your sub values are for each row. Can you copy the results of this query in tabular form here? "SELECT * FROM stats where identity = 'Sailor Moon'" Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645850 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 It's from: SELECT * FROM character_attributes where identity = 'Sailor Moon'; And the results are: id identity attribute_id sub desc level points 1 Sailor Moon Scout Powers 2 5 20 2 Sailor Moon Animal Guardian 1 4 4 3 Sailor Moon Combined Attacks 1 4 4 4 Sailor Moon Elemental Control 1 4 12 5 Sailor Moon Item Of Power 1 Upgraded Sailor Suit 1 2 6 Sailor Moon Item Of Power 1 Moon Tiara 1 2 7 Sailor Moon Item Of Power 1 Luna Pen 1 2 8 Sailor Moon Item Of Power 1 Crescent Moon Wand 1 2 9 Sailor Moon Item Of Power 1 Imperium Silver Crystal 5 10 10 Sailor Moon Rejuvenation 1 5 5 11 Sailor Moon Sailor Scout Attack 1 Moon Crystal Healing Activation 4 16 12 Sailor Moon Sailor Scout Attack 1 Moon Scepter Elimination 4 2 13 Sailor Moon Sailor Scout Attack 1 Cosmic Moon Power 3 1 14 Sailor Moon Sailor Scout Attack 1 Moon Healing Activation 2 1 15 Sailor Moon Sailor Scout Attack 1 Moon Tiara Magic 2 1 16 Sailor Moon Acrobatics 0 1 1 17 Sailor Moon Appearance 0 4 4 18 Sailor Moon Art Of Distraction 0 4 3 19 Sailor Moon Combat Mastery 0 2 4 20 Sailor Moon Energy Bonus 0 6 6 21 Sailor Moon Focused Combat 0 (Sailor Scout Attack) 3 3 22 Sailor Moon Heightened Scout Power 0 7 7 23 Sailor Moon Strong Soul 0 3 3 It looks a little choppy when pasting, but hopefully you can still read it okay. Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645855 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Did that help? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645864 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 OK, it should look something like this, right? Scout Powers Animal Guardian Combined Attacks Elemental Control Item Of Power Upgraded Sailor Suit Item Of Power Moon Tiara Item Of Power Luna Pen Item Of Power Crescent Moon Wand Item Of Power Imperium Silver Crystal Rejuvenation Sailor Scout Attack Moon Crystal Healing Activation Sailor Scout Attack Moon Scepter Elimination Sailor Scout Attack Cosmic Moon Power Sailor Scout Attack Moon Healing Activation Sailor Scout Attack Moon Tiara Magic - Acrobatics - Appearance - Art Of Distraction - Combat Mastery - Energy Bonus - Focused Combat 0 (Sailor Scout Attack) - Heightened Scout Power - Strong Soul This is only the first column. Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645915 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 No, like this: Scout Powers Animal Guardian Combined Attacks Elemental Control Item Of Power - Upgraded Sailor Suit - Moon Tiara - Luna Pen - Crescent Moon Wand - Imperium Silver Crystal Rejuvenation Sailor Scout Attack - Moon Crystal Healing Activation - Moon Scepter Elimination - Cosmic Moon Power - Moon Healing Activation - Moon Tiara Magic Acrobatics Appearance Art Of Distraction Combat Mastery Energy Bonus Focused Combat (Sailor Scout Attack) Heightened Scout Power Strong Soul Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645922 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 OK, that doesn't match your DB results. Combining these two quotes: if sub = 2, no indent and display before all others if sub = 1, indent x number of spaces and also display desc if sub = 0, no indent and Oh, and if desc is not blank, indent x number of spaces as well with a - at the beginning leads me to this: if (sub == 2) don't indent //You'll have to sort it from the DB so the 2's come first elseif (sub==1) indent 2 spaces //I picked 2, tell me if that's not OK elseif (desc!="") indent 3 spaces, then a dash, then another space //Again, tell me if that's not OK else don't indent That's how I understood it, but it looks like there's more to it. In you most recent example, you listed the attribute_id as a subheader in some cases. How does the code know when you want that to happen? In other words, I still don't understand. Try writing it out like this: if (sub == 2){ <attribute_id> <desc> } elseif (sub==1){ <attribute_id> <desc> } elseif (desc!=""){ <attribute_id> - <desc> } else{ <attrubute_id> } Make sense? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645927 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Well, what I did was make sub = 2 for Scout Power so that we could somehow make it come before all others, then all of the attributes that are supposed to be indented have a sub = 1 then all attibutes with a desc and a sub = 1 should be indented further with a - starting off the line then all attributes with a sub = 0, no indent That doesn't help? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645948 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 Making sub = 2 for Scout Power won't make it come first if that's not in your SELECT statement. You should make it: SELECT * FROM character_attributes where identity = 'Sailor Moon' ORDER BY sub DESC; Also, you didn't respond to this: if (sub==2){ <attribute_id> <desc> } elseif (sub==1){ <attribute_id> <desc> } elseif (desc!=""){ <attribute_id> - <desc> } else{ <attrubute_id> } Does that look right? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645957 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 if (sub==2){ <attribute_id> <desc> } elseif (sub==1){ <attribute_id> <desc> } elseif (desc!=""){ <attribute_id> - <desc> } else{ <attrubute_id> } It looks like the first part doesn't need the desc (because sub = 2 will have a blank or empty desc), and the third part I don't know if I understand right or not. Does it mean that if desc has nothing in it or something in it, to display - desc? I want if desc has a blank or nothing in it, to not display it, but if it has something, to display it with a - desc. Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645968 Share on other sites More sharing options...
twilitegxa Posted September 19, 2008 Author Share Posted September 19, 2008 Maybe I need to make a few tables within this table to make it display the way I want it to? Do you think that would work? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645970 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 OK, like this? if sub equals 2, display it like this (no indents): <attribute_id> <desc> else if sub equals 1, display it like this (no indent on attribute_id, on a new line three space indent on the desc): <attribute_id> <desc> else if desc is not blank, display it like this (no indent on attribute_id, on a new line two space indent, then dash, then a space on the desc): <attribute_id> - <desc> else (if the desc is blank), don't display anything Is that right?!? Link to comment https://forums.phpfreaks.com/topic/124877-if-else-statement-within-table-possible-ul/page/2/#findComment-645978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.