Jump to content

removal of brackets


kimjessen
Go to solution Solved by Barand,

Recommended Posts

Hi Yes I start a new thread, this is probably the correct one.
I have solved my problem almost. the result ends with the end of a parenthesis.
 
see picture
how do I get it deleted.
 

 

post-172690-0-01267100-1421885719_thumb.gif

<?php
$dir    = './data/test111';
$ddArray1 = scandir($dir,1);
?>
<html>
<head>
<title>Select Drop Down List</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
	
		<select name="file">
		<?php
		FOREACH($ddArray1 AS $file){
		PRINT '<option value="'.$file.'">'.$file.'</option>';
		}
		?>
		</select>


	<input type="submit"/>
	

	
</form>
</body>
</html>

<?php


if ($_POST) {
	
	echo '<pre&gt';
	print_r($_POST);
	$test='</pre&gt>';
	echo $test;
}
?>
Link to comment
Share on other sites

the &gt are right not a err.
yes it did make a difference, not for the better.
but a difference is something.
the result is here!

 

Array
(
[file] => test111-2015-01-22.csv
)

 

now I can almost imagine where the end brackets come from.
but how do I get them removed?
 
Moreover, many thanks for the help.
Edited by kimjessen
Link to comment
Share on other sites

Hello again!
It does not work as I expected. I would combine it with the graph, but I only get an error when I press the button.
I understand: who is in error description but can it be solved, or do I need to have the graph to run on a page by itself. ?
error message looks like this.
"
Explanation:
HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it's image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).

Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser.

For example it is a common mistake to leave a blank line before the opening "<?php". "

 

post-172690-0-89833300-1421889153_thumb.gif

<?php
$dir    = './data/test111';
$ddArray1 = scandir($dir,1);
?>
<html>
<head>
<title>Select Drop Down List</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
		<select name="file">
		<?php
		FOREACH($ddArray1 AS $file){
		PRINT '<option value="'.$file.'">'.$file.'</option>';
		}
		?>
		</select>
 	<input type="submit"/>
	</form>
</body>
</html>
 <?php
 if ($_POST) {
 $id=$_POST['file']; //only echos the 'file' index from the $_POST array
 //echo $id;
define("LOG_FILE", "./data/test111/".$id);
	require_once('jpgraph/src/jpgraph.php');
	require_once('jpgraph/src/jpgraph_line.php');
	$times = array();
	$values = array();	
	$file_lines = file(LOG_FILE, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
	foreach($file_lines as $line_num => $line_value) {
		$line_elements = explode(",", $line_value);
		$times[] = date($line_elements[0]);
		$values[] = $line_elements[1];
	}
	
	$graph = new Graph(800, 400);
	$graph->SetFrame(false);
	$graph->SetScale('intint');
	$graph->SetMarginColor('white');
	$graph->title->Set("Temp midt tank");
	
	$graph->xaxis->SetTickLabels($times);
	$graph->yaxis->scale->SetAutoMin(0);
	$graph->yaxis->title->Set("°C");
	
	$graph->ygrid->SetFill($aFlg=true, $aColor1='white', $aColor2='gray9');
	$lineplot = new LinePlot($values);
	$lineplot->SetColor('blue');
	
	$graph->Add($lineplot);
	$graph->Stroke();
	
}

 


?>
Link to comment
Share on other sites

  • Solution

No problem now we have established that works

<?php
$dir = './data/test111';
$ddArray1 = scandir($dir,1);
?>
<html>
<head>
<title>Select Drop Down List</title>
</head>
<body>
<form action="" method="get">
<select name="file">
<?php
FOREACH($ddArray1 AS $file){
PRINT '<option value="'.$file.'">'.$file.'</option>';
}
?>
</select>
<input type="submit"/>
</form>
</body>
</html>

<?php
    if (isset($_GET['file'])) {
        $id = $_GET['file'];
        echo "<img src='mygraph.php?file=$id' />" ;
    }
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.