MDanz Posted August 7, 2009 Share Posted August 7, 2009 For my search engine the results are echoed into a table. The best way i can think of doing this. Is declaring the results as a variable. So then i can input the results into an array and do this $stack= array($results); array_push($stack, $results); echo($stack); so i get to display my old results with my new one how do i declare my results as a variable though... echo '<br><table '.$margin.'>'; while ($runrows = mysql_fetch_assoc($run)) { //get data $name = $runrows['name']; $image = $runrows['image']; $hyperlink = $runrows['hyperlink']; $currency = $runrows['currency']; $info = $runrows['info']; $type = $runrows['type']; echo '<tr><td>'; switch ($type) { case 'I': echo '<img src="http://www.u-stack.com/Image.jpg">'; break; case 'M': echo '<img src="http://www.u-stack.com/Music.jpg">'; break; case 'F': echo '<img src="http://www.u-stack.com/File.jpg">'; break; case 'V': echo '<img src="http://www.u-stack.com/Video.jpg">'; break; case 'J': echo '<img src="http://www.u-stack.com/Job.jpg">'; break; case 'D': echo '<img src="http://www.u-stack.com/Discussion.jpg">'; break; case 'P': echo '<img src="http://www.u-stack.com/Product.jpg">'; break; } echo '</td></tr>'; } echo '</table>'; } how do i declare all of that as a variable?... like $results Link to comment https://forums.phpfreaks.com/topic/169176-declaring-results-as-a-variable/ Share on other sites More sharing options...
kratsg Posted August 7, 2009 Share Posted August 7, 2009 $results = <<<ANYTHINGYOUWANTSRSLY//this has to match up exactly at the end Multiple Lines And other stuff Like quotes and html and tables WHeeeeeee! ANYTHINGYOUWANTSRSLY;//this matches exactly with the beginning echo $results; I believe I've answered this thread 8-) ~kratsg Link to comment https://forums.phpfreaks.com/topic/169176-declaring-results-as-a-variable/#findComment-892650 Share on other sites More sharing options...
MDanz Posted August 7, 2009 Author Share Posted August 7, 2009 doesn't work.. keeps saying Parse error: syntax error, unexpected '[' in /home/ustackc1/public_html/search.php on line 151 thats where i declare the $result Link to comment https://forums.phpfreaks.com/topic/169176-declaring-results-as-a-variable/#findComment-892672 Share on other sites More sharing options...
kratsg Posted August 7, 2009 Share Posted August 7, 2009 I honestly do not know what your code looks like at this point.... can you post it so I can see? Link to comment https://forums.phpfreaks.com/topic/169176-declaring-results-as-a-variable/#findComment-893246 Share on other sites More sharing options...
p2grace Posted August 7, 2009 Share Posted August 7, 2009 There's a very easy way to declare results as a variable. http://us3.php.net/manual/en/function.extract.php $arr = array("test" => "Found"); extract($arr); echo $test; // displays Found Link to comment https://forums.phpfreaks.com/topic/169176-declaring-results-as-a-variable/#findComment-893293 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.