timmah1 Posted August 28, 2009 Share Posted August 28, 2009 I have this form that a user submits and it shows them everything that is in the database for that particular week I would like all the results to show in a textarea, so that they can copy and paste it. But, this only puts one of the results, the last one, in the text box. can anybody tell me what I'm doing wrong or show me how I can get all the results to show in the textarea? <?php $query = "SELECT * FROM picks WHERE week = '$week' AND YEAR(posted) = '".date("Y")."'"; $picks = mysql_query($query); $numrows = mysql_num_rows($picks); if($numrows == 0){ echo "No picks for $week1!<br /><a href='export_picks.php'>Go Back!</a>"; } else { while($a = mysql_fetch_array($picks)){ $sport = $a['sport']; $game = date("F j, Y", strtotime($a['game'])); $game_time = $a['game_time']; $description = nl2br($a['description']); $away = $a['away']; $home = $a['home']; $prediction = $a['prediction']; $sql = "SELECT * FROM $sport WHERE id = '$home'"; $q= mysql_query($sql); while($a= mysql_fetch_assoc($q)){ $home_team = $a['team']; $home_image = "<img src='http://www.10freefootballpicks.com/sports/$a[image]' alt='$a[team]' width='100' />"; } $sql = "SELECT * FROM $sport WHERE id = '$away'"; $q= mysql_query($sql); while($a= mysql_fetch_assoc($q)){ $away_team = $a['team']; $away_image = "<img src='http://www.10freefootballpicks.com/sports/$a[image]' alt='$a[team]' width='100' />"; } $string = " <table width='100%' border='0' align='center' cellpadding='2' cellspacing='0' class='side'> <tr> <td align='center' colspan='3'><h1><em>$away_team at $home_team</em></h1> <h2><em>Game Time: $game, $game_time</em></h2></td> </tr> <tr> <td align='right'>$away_image</td> <td align='center' valign='middle'><h1> vs </h1></td> <td align='left'>$home_image</td> </tr> <tr> <td colspan='3' align='left' valign='top'>$description</td> </tr> <tr> <td colspan='3' align='center' valign='top'><font color='#ff0000'><strong>$prediction</strong></font></td> </tr> </table>"; echo $string; } echo "<br /><textarea name='' cols='75' rows='5'>$string</textarea><br /><br />"; } } ?> Thanks in advance Quote Link to comment Share on other sites More sharing options...
ReKoNiZe Posted August 28, 2009 Share Posted August 28, 2009 Every cycle through the while() loop you are overwriting $string. Do $string .= to concate. Quote Link to comment Share on other sites More sharing options...
timmah1 Posted August 28, 2009 Author Share Posted August 28, 2009 oh man. Something simple that is overlooked!! Thank you RekoNiZe 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.