shamuraq Posted June 3, 2009 Share Posted June 3, 2009 Scenario: I need to loop line drawn in svg: $lebar = 800/10; for(i=0;i<$lebar;i++){ $output .= "<path class=\"SamplePath\" d=\"M\"$i\" 0 L\"$i\" 800\"></path>\n"; } i can't seem to get the loop till 80 lines are drawn vertically($lebar=800/10).... Thanx in advance... Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/ Share on other sites More sharing options...
Mark Baker Posted June 3, 2009 Share Posted June 3, 2009 Try using $i rather than i Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848470 Share on other sites More sharing options...
anupamsaha Posted June 3, 2009 Share Posted June 3, 2009 Try using $i rather than i Also, do this: $output .= "<path class=\"SamplePath\" d=\"M\"$i\" 0 L\"$i\" 800\"></path><br>\n"; Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848480 Share on other sites More sharing options...
shamuraq Posted June 3, 2009 Author Share Posted June 3, 2009 still doesn't work... Btw where do i put: error_reporting(E_ALL); ini_set('display_errors', 1); can i place it at the last line before the "?>" Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848488 Share on other sites More sharing options...
shamuraq Posted June 3, 2009 Author Share Posted June 3, 2009 btw, these is the entire code... really need help to solve this: <?php header("Content-type: image/svg+xml"); $output .="<?xml version=\"1.0\" standalone=\"no\"?>"; $output .="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; $output .= "<svg width=\"1028\" height=\"1024\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"; //class style sheet $output .= "<style type=\"text/css\"> <![CDATA[ .Border { fill:none; stroke:#a4a4a4; stroke-width:1; stroke-dasharray: 5, 3, 9, 2; } .Connect { fill:#505050; stroke:#888888; stroke-width:2 } .SamplePath { fill:none; stroke:#CCCCCC; stroke-width:1 } .EndPoint { fill:none; stroke:#888888; stroke-width:2 } .CtlPoint { fill:#888888; stroke:none } .AutoCtlPoint { fill:none; stroke:blue; stroke-width:4 } .Label {font-family: Arial } ]]> </style>"; $lebar = 80; for($i=0; $i<$lebar; $i++{ $output .= "<path d=\"M$i 0 L$i 800\"></path><br>\n"; } //$lebar = 80; //$output .= "<path class=\"SamplePath\" d=\"M$lebar 0 L$lebar 800\"></path>\n"; $output .= "</svg>\n"; print $output; ?> The syntax for producing path is: //M is moving drawing pointer to x and y axis //L means line to x and y axis //Z is to close the path. Means joining the last point drawn to the first point. <path d="M 100 100 L 300 100 L 200 300 z"></path> // What i want is to duplicate the point drawn.... Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848490 Share on other sites More sharing options...
Mark Baker Posted June 3, 2009 Share Posted June 3, 2009 Btw where do i put: error_reporting(E_ALL); ini_set('display_errors', 1); can i place it at the last line before the "?>" Nope, you put it at the very top of your script, immediately after the <?php You're telling PHP to display all errors... not much point in doing that after the script has finished running and all the errors have already occurred, tell it how it should report any errors before the errors occur Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848524 Share on other sites More sharing options...
Mark Baker Posted June 3, 2009 Share Posted June 3, 2009 Spurious semi-colon for($i=0; $i<$lebar; $i++;){ Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848532 Share on other sites More sharing options...
shamuraq Posted June 3, 2009 Author Share Posted June 3, 2009 nope the additional ";" doesn't work either but i managed to solve it.. Thanx guys... Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848557 Share on other sites More sharing options...
Mark Baker Posted June 3, 2009 Share Posted June 3, 2009 nope the additional ";" doesn't work either but i managed to solve it.. Thanx guys... It's always a good idea to post how you managed to solve it for the benefit of others who might be having similar problems to yourself Link to comment https://forums.phpfreaks.com/topic/160769-solved-loop/#findComment-848599 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.