twilitegxa Posted September 21, 2008 Share Posted September 21, 2008 Can anyone help me figure out why my query is only returning one result when there are several in my table? What code must I add in order for the query to return all the records in the table? Here is my query: //validate defects $get_defects = "SELECT * FROM character_defects INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id] ORDER BY defect_id ASC"; $get_defects_res = mysql_query($get_defects) or die (mysql_error()); if (mysql_num_rows($get_defects_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $defect_id = stripslashes(mysql_result($get_defects_res,0,'defect_id')); $desc = mysql_result($get_defects_res,0,'desc'); $bp = stripslashes(mysql_result($get_defects_res,0,'bp')); //display stats $display_block .= " <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>$defect_id $desc</td> <td>$bp BP</td></tr> </table>"; } Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/ Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 <? //validate defects $get_defects = "SELECT * FROM character_defects INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id] ORDER BY defect_id ASC"; $get_defects_res = mysql_query($get_defects) or die (mysql_error()); if (mysql_num_rows($get_defects_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $defect_id = stripslashes(mysql_result($get_defects_res,0,'defect_id')); $desc = mysql_result($get_defects_res,0,'desc'); $bp = stripslashes(mysql_result($get_defects_res,0,'bp')); while ($a = mysql_fetch_array($get_defects_res)) { // YOU CAN USE $a['COLUMN NAME']; TO ECHO VALUES FROM DB IN THIS LOOP * TILL WHILE ENDS * HIHIH //display stats $display_block = " <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>$defect_id $desc</td> <td>$bp BP</td></tr> </table>"; } } ?> this should help //edit you can use $a like $a['desc'] this will echo $desc value and so on Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647242 Share on other sites More sharing options...
.josh Posted September 21, 2008 Share Posted September 21, 2008 To answer your question, your query may or may not be returning only 1 result, but you are only pulling 1 row from the result source, instead of looping it. Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647245 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 Oh, okay. Well, how do I loop it in this case? Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647249 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 look at my post you have everything you need.. i am invisible? Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647250 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 No, you are not invisible. I am trying your suggestion, but it is just repeating the same result over and over. What am I doing wrong? Wrong placement maybe? Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647254 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 i gaved you an example at least you could change the variables from <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>$defect_id $desc</td> <td>$bp BP</td></tr> </table>"; with <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>$a['defect_id'] $a['desc']</td> <td>$a['bp'] BP</td></tr> </table>"; Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647259 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 Oh, I think I misunderstood the example. Let me try that. Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647261 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 It didn't work. It returned this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in on line 182 Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647265 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 ups <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>".$a['defect_id']." ".$a['desc']."</td> <td>".$a['bp']." BP</td></tr> </table>"; that should work 100% Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647266 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 Same error, also I can't use " because I am already using " around the entire display_block. I tried using ' but that didn't work, and still returned the same error. Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647272 Share on other sites More sharing options...
.josh Posted September 21, 2008 Share Posted September 21, 2008 post your entire display block Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647274 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 yup what line is 182? Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647277 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 Hold on. I did it with the " and it seems to be working, except it is repeating one line it doesn't need to: Character Defects. Here is the code. See if you can tell me how to move that line so it won't keep repeating: <?php //validate defects $get_defects = "SELECT * FROM character_defects INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id] ORDER BY defect_id ASC"; $get_defects_res = mysql_query($get_defects) or die (mysql_error()); if (mysql_num_rows($get_defects_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $defect_id = stripslashes(mysql_result($get_defects_res,0,'defect_id')); $desc = mysql_result($get_defects_res,0,'desc'); $bp = stripslashes(mysql_result($get_defects_res,0,'bp')); while ($a = mysql_fetch_array($get_defects_res)) { //display stats $display_block .= " <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>".$a['defect_id']." ".$a['desc']."</td> <td>".$a['bp']." BP</td></tr> </table>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647280 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 This is what it looks like: Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647283 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 the table is looping this should fix the problem <?php //validate defects $get_defects = "SELECT * FROM character_defects INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id] ORDER BY defect_id ASC"; $get_defects_res = mysql_query($get_defects) or die (mysql_error()); if (mysql_num_rows($get_defects_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $defect_id = stripslashes(mysql_result($get_defects_res,0,'defect_id')); $desc = mysql_result($get_defects_res,0,'desc'); $bp = stripslashes(mysql_result($get_defects_res,0,'bp')); $display_block .= "<table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'>"; while ($a = mysql_fetch_array($get_defects_res)) { //display stats $display_block .= " <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>".$a['defect_id']." ".$a['desc']."</td> <td>".$a['bp']." BP</td></tr>"; } $display_block .= "</table>"; } ?> so i won a special prize? Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647290 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 No special prize yet. Still isn't working right. Still looks like it's looping, just not in the actualy table now. Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647293 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 weird i dont see nothing wrong in my code... maybe cause is 2:30 in the morning give me the HTML part from the deffects table.... (SOURCE CODE took from browser not from php file) Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647295 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 I don't know what you mean? I don't have a source code in HTML? Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647297 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 Is this what you meant? <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Attack Restriction (Loved Ones)</td> <td>2 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Attack Words </td> <td>2 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Awkward </td> <td>1 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Easily Distracted (Food, Cute Guys, Video Games)</td> <td>2 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Empty Mind </td> <td>1 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Item Dependency (Sailor Scout Attacks)</td> <td>2 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Item Dependency (Transformation)</td> <td>1 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Phobia </td> <td>1 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Powered After Transformation </td> <td>2 BP</td></tr> </table> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>Transformation Loss </td> <td>1 BP</td></tr> </table> Source code from browser. Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647302 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 check with this if it work <?php //validate defects $get_defects = "SELECT * FROM character_defects INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id] ORDER BY defect_id ASC"; $get_defects_res = mysql_query($get_defects) or die (mysql_error()); $display_block = "<table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'>"; if (mysql_num_rows($get_defects_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $defect_id = stripslashes(mysql_result($get_defects_res,0,'defect_id')); $desc = mysql_result($get_defects_res,0,'desc'); $bp = stripslashes(mysql_result($get_defects_res,0,'bp')); while ($a = mysql_fetch_array($get_defects_res)) { //display stats $display_block .= " <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>".$a['defect_id']." ".$a['desc']."</td> <td>".$a['bp']." BP</td></tr>"; } } $display_block .= "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647305 Share on other sites More sharing options...
twilitegxa Posted September 21, 2008 Author Share Posted September 21, 2008 No, that just makes everything else on the page disappear except for the defects table, which is still looping. Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647309 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 show full code -.- normally it should work show the part of code where you echo the variable $display_block with 5 lines above and after the echo part... Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647315 Share on other sites More sharing options...
twilitegxa Posted September 22, 2008 Author Share Posted September 22, 2008 Here is the entire code: <?php //connect to database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("smrpg",$conn) or die(mysql_error()); //validate profile $get_profile = "select * from scout where id = $_GET[id]"; $get_profile_res = mysql_query($get_profile) or die (mysql_error()); if (mysql_num_rows($get_profile_res) < 1) { //invalid profile $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid profile, get info $identity = (stripslashes( mysql_result($get_profile_res,0,'identity'))); $charactername = stripslashes(mysql_result($get_profile_res,0,'charactername')); $elementofinfluence = mysql_result($get_profile_res,0,'elementofinfluence'); $age = stripslashes(mysql_result($get_profile_res,0,'age')); $birthdatemonth = (mysql_result($get_profile_res,0,'birthdatemonth')); $birthdateday = (mysql_result($get_profile_res,0,'birthdateday')); $birthdateyear = (mysql_result($get_profile_res,0,'birthdateyear')); $heightfeet = (mysql_result($get_profile_res,0,'heightfeet')); $heightinches = (mysql_result($get_profile_res,0,'heightinches')); $bloodtype = (mysql_result($get_profile_res,0,'bloodtype')); $hobbies = (mysql_result($get_profile_res,0,'hobbies')); $favoritecolor = (mysql_result($get_profile_res,0,'favoritecolor')); $favoritegemstone = (mysql_result($get_profile_res,0,'favoritegemstone')); $favoritefood = (mysql_result($get_profile_res,0,'favoritefood')); $leastfavoritefood = (mysql_result($get_profile_res,0,'leastfavoritefood')); $favoriteschoolsubject = (mysql_result($get_profile_res,0,'favoriteschoolsubject')); $leastfavoriteschoolsubject = (mysql_result($get_profile_res,0,'leastfavoriteschoolsubject')); $strengths = (mysql_result($get_profile_res,0,'strengths')); $weaknesses = (mysql_result($get_profile_res,0,'weaknesses')); $goal = (mysql_result($get_profile_res,0,'goal')); $biography = (mysql_result($get_profile_res,0,'biography')); $display_block = "<h1><center>$identity</center></h1>"; //display profile $display_block .= " <table cellpadding=3 cellspacing=3 border='0' width='100%'> <tr> <td width='25%'><strong>Character Name:</strong></td> <td>$charactername</td></tr> <tr> <td><strong>Element Of Influence:</strong></td> <td>$elementofinfluence</td></tr> <tr> <td><strong>Age:</strong></td> <td>$age</td></tr> <tr> <td><strong>Birthdate:</strong></td> <td>$birthdatemonth $birthdateday, $birthdateyear</td></tr> <tr> <td><strong>Height:</strong></td> <td>$heightfeet' $heightinches"</td></tr> <tr> <td><strong>Blood Type:</strong></td> <td>$bloodtype</td></tr> <tr> <td><strong>Hobbies:</strong></td> <td>$hobbies</td></tr> <tr> <td><strong>Favorite Color:</strong></td> <td>$favoritecolor</td></tr> <tr> <td><strong>Favorite Gemstone:</strong></td> <td>$favoritegemstone</td></tr> <tr> <td><strong>Favorite Food:</strong></td> <td>$favoritefood</td></tr> <td><strong>Least Favorite Food:</strong></td> <td>$leastfavoritefood</td></tr> <tr> <td><strong>Favorite School Subject:</strong></td> <td>$favoriteschoolsubject</td></tr> <tr> <td><strong>Least Favorite School Subject:</strong></td> <td>$leastfavoriteschoolsubject</td></tr> <tr> <td><strong>Strengths:</strong></td> <td>$strengths</td></tr> <tr> <td><strong>Weaknesses:</strong></td> <td>$weaknesses</td></tr> <tr> <td><strong>Goal:</strong></td> <td>$goal...</td></tr>"; $display_block .= " </td> </tr> </table> <p>$biography</p>"; } //validate stats $get_stats = "SELECT * FROM stats INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id]"; $get_stats_res = mysql_query($get_stats) or die (mysql_error()); if (mysql_num_rows($get_stats_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $body = stripslashes(mysql_result($get_stats_res,0,'body')); $mind = mysql_result($get_stats_res,0,'mind'); $soul = stripslashes(mysql_result($get_stats_res,0,'soul')); $health = (mysql_result($get_stats_res,0,'health')); $energy = (mysql_result($get_stats_res,0,'energy')); $acv = (mysql_result($get_stats_res,0,'acv')); $acv_sa = (mysql_result($get_stats_res,0,'acv_sa')); $dcv = (mysql_result($get_stats_res,0,'dcv')); $dcv_sa = (mysql_result($get_stats_res,0,'dcv_sa')); $tcp = (mysql_result($get_stats_res,0,'tcp')); //display stats $display_block .= " <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Stats And Derived Values</td></tr> <tr> <td><strong>Body:</strong></td> <td>$body</td></tr> <tr> <td><strong>Mind:</strong></td> <td>$mind</td></tr> <tr> <td><strong>Soul:</strong></td> <td>$soul</td></tr> <tr> <td><strong>Health:</strong></td> <td>$health</td></tr> <tr> <td><strong>Energy:</strong></td> <td>$energy</td></tr> <tr> <td><strong>Attack Combat Value:</strong></td> <td>$acv</td> <td>$acv_sa (for Sailor Scout Attack)</td></tr> <tr> <td><strong>Defense Combat Value:</strong></td> <td>$dcv</td> <td>$dcv_sa (for Sailor Scout Attack)</td></tr> <tr> <td><strong>Total Character Points:</strong></td> <td>$tcp</td></tr></table>"; } //validate defects $get_defects = "SELECT * FROM character_defects INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id] ORDER BY defect_id ASC"; $get_defects_res = mysql_query($get_defects) or die (mysql_error()); if (mysql_num_rows($get_defects_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $defect_id = stripslashes(mysql_result($get_defects_res,0,'defect_id')); $desc = mysql_result($get_defects_res,0,'desc'); $bp = stripslashes(mysql_result($get_defects_res,0,'bp')); while ($a = mysql_fetch_array($get_defects_res)) { //display stats $display_block .= " <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>".$a['defect_id']." ".$a['desc']."</td> <td>".$a['bp']." BP</td></tr> </table>"; } } ?> <html> <head> <title>Profile - <?php print $identity ?></title> <link rel="stylesheet" type="text/css" href="simpletree2.css" /> </head> <body> <?php print $display_block; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647322 Share on other sites More sharing options...
Minase Posted September 22, 2008 Share Posted September 22, 2008 now it should work impossible to not <?php //connect to database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("smrpg",$conn) or die(mysql_error()); //validate profile $get_profile = "select * from scout where id = $_GET[id]"; $get_profile_res = mysql_query($get_profile) or die (mysql_error()); if (mysql_num_rows($get_profile_res) < 1) { //invalid profile $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //valid profile, get info $identity = (stripslashes( mysql_result($get_profile_res,0,'identity'))); $charactername = stripslashes(mysql_result($get_profile_res,0,'charactername')); $elementofinfluence = mysql_result($get_profile_res,0,'elementofinfluence'); $age = stripslashes(mysql_result($get_profile_res,0,'age')); $birthdatemonth = (mysql_result($get_profile_res,0,'birthdatemonth')); $birthdateday = (mysql_result($get_profile_res,0,'birthdateday')); $birthdateyear = (mysql_result($get_profile_res,0,'birthdateyear')); $heightfeet = (mysql_result($get_profile_res,0,'heightfeet')); $heightinches = (mysql_result($get_profile_res,0,'heightinches')); $bloodtype = (mysql_result($get_profile_res,0,'bloodtype')); $hobbies = (mysql_result($get_profile_res,0,'hobbies')); $favoritecolor = (mysql_result($get_profile_res,0,'favoritecolor')); $favoritegemstone = (mysql_result($get_profile_res,0,'favoritegemstone')); $favoritefood = (mysql_result($get_profile_res,0,'favoritefood')); $leastfavoritefood = (mysql_result($get_profile_res,0,'leastfavoritefood')); $favoriteschoolsubject = (mysql_result($get_profile_res,0,'favoriteschoolsubject')); $leastfavoriteschoolsubject = (mysql_result($get_profile_res,0,'leastfavoriteschoolsubject')); $strengths = (mysql_result($get_profile_res,0,'strengths')); $weaknesses = (mysql_result($get_profile_res,0,'weaknesses')); $goal = (mysql_result($get_profile_res,0,'goal')); $biography = (mysql_result($get_profile_res,0,'biography')); $display_block = "<h1><center>$identity</center></h1>"; //display profile $display_block .= " <table cellpadding=3 cellspacing=3 border='0' width='100%'> <tr> <td width='25%'><strong>Character Name:</strong></td> <td>$charactername</td></tr> <tr> <td><strong>Element Of Influence:</strong></td> <td>$elementofinfluence</td></tr> <tr> <td><strong>Age:</strong></td> <td>$age</td></tr> <tr> <td><strong>Birthdate:</strong></td> <td>$birthdatemonth $birthdateday, $birthdateyear</td></tr> <tr> <td><strong>Height:</strong></td> <td>$heightfeet' $heightinches&#34;</td></tr> <tr> <td><strong>Blood Type:</strong></td> <td>$bloodtype</td></tr> <tr> <td><strong>Hobbies:</strong></td> <td>$hobbies</td></tr> <tr> <td><strong>Favorite Color:</strong></td> <td>$favoritecolor</td></tr> <tr> <td><strong>Favorite Gemstone:</strong></td> <td>$favoritegemstone</td></tr> <tr> <td><strong>Favorite Food:</strong></td> <td>$favoritefood</td></tr> <td><strong>Least Favorite Food:</strong></td> <td>$leastfavoritefood</td></tr> <tr> <td><strong>Favorite School Subject:</strong></td> <td>$favoriteschoolsubject</td></tr> <tr> <td><strong>Least Favorite School Subject:</strong></td> <td>$leastfavoriteschoolsubject</td></tr> <tr> <td><strong>Strengths:</strong></td> <td>$strengths</td></tr> <tr> <td><strong>Weaknesses:</strong></td> <td>$weaknesses</td></tr> <tr> <td><strong>Goal:</strong></td> <td>$goal...</td></tr>"; $display_block .= " </td> </tr> </table> <p>$biography</p>"; } //validate stats $get_stats = "SELECT * FROM stats INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id]"; $get_stats_res = mysql_query($get_stats) or die (mysql_error()); if (mysql_num_rows($get_stats_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $body = stripslashes(mysql_result($get_stats_res,0,'body')); $mind = mysql_result($get_stats_res,0,'mind'); $soul = stripslashes(mysql_result($get_stats_res,0,'soul')); $health = (mysql_result($get_stats_res,0,'health')); $energy = (mysql_result($get_stats_res,0,'energy')); $acv = (mysql_result($get_stats_res,0,'acv')); $acv_sa = (mysql_result($get_stats_res,0,'acv_sa')); $dcv = (mysql_result($get_stats_res,0,'dcv')); $dcv_sa = (mysql_result($get_stats_res,0,'dcv_sa')); $tcp = (mysql_result($get_stats_res,0,'tcp')); //display stats $display_block .= " <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <tr> <tr><td colspan='3' id='th'>Stats And Derived Values</td></tr> <tr> <td><strong>Body:</strong></td> <td>$body</td></tr> <tr> <td><strong>Mind:</strong></td> <td>$mind</td></tr> <tr> <td><strong>Soul:</strong></td> <td>$soul</td></tr> <tr> <td><strong>Health:</strong></td> <td>$health</td></tr> <tr> <td><strong>Energy:</strong></td> <td>$energy</td></tr> <tr> <td><strong>Attack Combat Value:</strong></td> <td>$acv</td> <td>$acv_sa (for Sailor Scout Attack)</td></tr> <tr> <td><strong>Defense Combat Value:</strong></td> <td>$dcv</td> <td>$dcv_sa (for Sailor Scout Attack)</td></tr> <tr> <td><strong>Total Character Points:</strong></td> <td>$tcp</td></tr></table>"; } //validate defects $get_defects = "SELECT * FROM character_defects INNER JOIN scout USING (identity) WHERE scout.id = $_GET[id] ORDER BY defect_id ASC"; $get_defects_res = mysql_query($get_defects) or die (mysql_error()); if (mysql_num_rows($get_defects_res) < 1) { //invalid table $display_block .= "<p><em>Invalid table selection.</em></p>"; } else { //valid table, get info $defect_id = stripslashes(mysql_result($get_defects_res,0,'defect_id')); $desc = mysql_result($get_defects_res,0,'desc'); $bp = stripslashes(mysql_result($get_defects_res,0,'bp')); while ($a = mysql_fetch_array($get_defects_res)) { //display stats $display_block .= " <tr> <tr><td colspan='3' id='th'>Character Defects</td></tr> <tr> <td>".$a['defect_id']." ".$a['desc']."</td> <td>".$a['bp']." BP</td></tr>"; } } ?> <html> <head> <title>Profile - <?php print $identity ?></title> <link rel="stylesheet" type="text/css" href="simpletree2.css" /> </head> <body> <table cellpadding=3 cellspacing=3 border='0' width='40%' id='stats'> <?php print $display_block; ?> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/125218-solved-query-only-returning-one-result/#findComment-647330 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.