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 Link to comment https://forums.phpfreaks.com/topic/172302-solved-show-everything-in-one-box/ 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. Link to comment https://forums.phpfreaks.com/topic/172302-solved-show-everything-in-one-box/#findComment-908447 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 Link to comment https://forums.phpfreaks.com/topic/172302-solved-show-everything-in-one-box/#findComment-908452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.