MDanz Posted August 8, 2009 Share Posted August 8, 2009 $result= 'Layer1'; <div id="Layer1"> </div> i obviously declared the variable wrong. Whats the correct way to declare the $result variable as the Layer? Quote Link to comment https://forums.phpfreaks.com/topic/169310-declare-variable-as-a-layer/ Share on other sites More sharing options...
smerny Posted August 8, 2009 Share Posted August 8, 2009 you declared the variable correctly...assuming it is within php tags... but then you didnt use it? to get what i think you are looking for... <div id="<?php echo $result; ?>"> </div> Quote Link to comment https://forums.phpfreaks.com/topic/169310-declare-variable-as-a-layer/#findComment-893430 Share on other sites More sharing options...
MDanz Posted August 8, 2009 Author Share Posted August 8, 2009 i think i tried that but i didnt get what i was trying to accomplish. 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>'; i need to find a way to simplify this? is there anyway to simplify this?... so i can do stuff like add this whole code to an array/echo .. Quote Link to comment https://forums.phpfreaks.com/topic/169310-declare-variable-as-a-layer/#findComment-893432 Share on other sites More sharing options...
wildteen88 Posted August 8, 2009 Share Posted August 8, 2009 Nothing much can be simplified, only this code block 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; } in to $types = array( 'I' => 'Image.jpg', 'M' => 'Music.jpg', 'F' => 'File.jpg', 'V' => 'Video.jpg', 'J' => 'Job.jpg', 'D' => 'Discussion.jpg', 'P' => 'Product.jpg' ); if(in_array($type, $types)) { echo '<img src="http://www.u-stack.com/'.$types[$type].'">'; } Quote Link to comment https://forums.phpfreaks.com/topic/169310-declare-variable-as-a-layer/#findComment-893447 Share on other sites More sharing options...
trq Posted August 8, 2009 Share Posted August 8, 2009 Can you stop asking the same questions over and over in multiple threads? Ive reported this thread. Quote Link to comment https://forums.phpfreaks.com/topic/169310-declare-variable-as-a-layer/#findComment-893468 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.