Page 2 of 2

Posted: Sat Apr 22, 2006 1:40 am
by ctjansen
Hey Roja,

Thanks for your comments. But perhaps you have not read me previous mail.
Sure, always willing to learn, but in my situation it is a bit hard, as I wrote, I am leaving on a 8 year trip in two months, tons of things to do, and leaning a programming language is very timeconsuming. And al that for perhaps 4 lines of code which I need.

Anyway, your friendly words upt me to try once more.
Can you please give me some constructive help? Comments ment for ´real´ programmers are not what i am looking for.

Ok, I have this lines :

echo '<td class="border" style="font-size:9px;">'.$row[opmerking].'</td>';
echo '<a href="#" onclick="window.open('simpleRoutine.php?thisRecord='.$row['id'].'>','window name'); return false">Go!</a> </td> ;

(line 115 and 116)

its the line 116 which was the advise from here and gives the error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in ..../public_html/nuke/modules/waarbenik/index.php on line 116
I have trie all possibilites of quotes and /` but I probably forgot one haha

What do you think? If you need more info, just let me know

thanks

Casper

Posted: Sat Apr 22, 2006 5:34 am
by timvw
ctjansen wrote: echo '<td class="border" style="font-size:9px;">'.$row[opmerking].'</td>';
echo '<a href="#" onclick="window.open('simpleRoutine.php?thisRecord='.$row['id'].'>','window name'); return false">Go!</a> </td> ;
I'd be surprised if that was the code... Anyway, with a decent editor, the errors becomes clear quite easily... I'll leave it to you to spot it :p (btw, notice that i change something in line 115 too)

Since you have string between single quotes ' ' all the single quotes in there have to be escaped, \'

Code: Select all

echo '<td class="border" style="font-size:9px;">'. $row['opmerking'] .'</td>';
echo '<a href="#" onclick="window.open(\'simpleRoutine.php?thisRecord='.$row['id'].'\',\'window name\'); return false">Go!</a> </td>';

Posted: Mon May 01, 2006 6:32 am
by ctjansen
Well, I have partially solved the problem myself, just one question left.
(the link has changed to this by the way)

http://ctjansen.nl/nuke/modules.php?name=waarwasik

what i am now doing is calling another php program. in the url with the link, i am passing the variables to the new program like this:

echo "<td class='border' style='font-size:11px;'><a href=http://www.ctjansen.nl/xxx/waarbenik/ma ... beg_plaats]." > meer info ";

now in this new program map.php : how do i put the send varaibles (datum and beg_plaats) in a variable so the program can open a new popup window and echo the contents of the variable to this wiindow?

Casper

Posted: Mon May 01, 2006 8:32 am
by Ollie Saunders
I have trie all possibilites of quotes and /` but I probably forgot one haha
its the other slash \

Posted: Wed May 03, 2006 3:01 pm
by ctjansen
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Ok. let me be a little more specific, here is what i have so far:

I connect to MYSQL, then read the whole logbook , so far no problem:

Code: Select all

$query = "SELECT * FROM log_new ORDER BY  datum DESC, beg_km DESC ";
        $result = mysql_query($query);


?>
Then I set up the table, also no problem:

Code: Select all

<table style="text-align:center;	empty-cells:show; border-collapse: collapse; width: 100%;">
<tr>

<td style="background-color: transparent; text-align:center; padding:0px 0px 0px 0px; ">
<TABLE bgcolor="lightgrey" border="2" width="100%">
<th class="border">Datum</th>
<th class="border">Land</th>
<th class="border">Plaats</th>
<th class="border">Weer</th>
<th class="border" >Km gereden</th>
<th class="border" colspan="2">Mijn positie</th>
<th class="border" >Opmerking</th>
<th class="border" >meer</th>
</tr>

<?php

while ($row=mysql_fetch_array($result))
		{
$breedte_deg = $row[end_b_deg];
$breedte_deg += 0;
$breedte_deg = round($end_b_deg);
$breedte_min = $row[end_b_min];
$breedte_min += 0;
$breedte_min = round($end_b_min);
$breedte_sec = $row[end_b_sec];
$breedte_sec += 0;
$breedte_sec = round($end_b_sec);
$lengte_deg = $row[end_l_deg];
$lengte_deg += 0;
$lengte_deg = round($end_l_deg);
$lengte_min = $row[end_l_min];
$lengte_min += 0;
$lengte_min = round($end_l_min);
$lengte_sec = $row[end_l_sec];
$lengte_sec += 0;
$lengte_sec = round($end_l_sec);
Then i start printing the table:

Code: Select all

/*echo '<tr>';*/

$km = $row[end_km] - $row[beg_km];
$date = Dateconvert($row[datum],2);
echo '<td class="border" style="font-size:11px;">'.$date.'</td>';
echo '<td class="border" style="font-size:11px;">'.$row[land].'</td>';
echo '<td class="border" style="font-size:11px;">'.$row[end_plaats].'</td>';
echo '<td class="border" style="font-size:9px;">'.$row[end_weer].'</td>';

/*echo '<td class="border" style="font-size:11px;">'.$row[end_temp].'&ordm;C</td>';*/

echo '<td class="border" style="font-size:11px;">'.$km.'</td>';
echo "<td class='border' style='font-size:11px;'><a href=http://www.mapquest.com/maps/map.adp?searchtype=address&formtype=latlong&latlongtype=degrees&latdeg=".$breedte_deg."&latmin=".$breedte_min."&latsec=".$breedte_sec."&longdeg=".$lengte_deg."&longmin=".$lengte_min."&longsec=".$lengte_sec."&zoom=2 target=_blank>".$row[N_S]." ".$row[breedte_deg]."&ordm; ".$row[breedte_min]."' ";
echo $row[breedte_sec].'"</a></td>';
echo "<td class='border' style='font-size:11px;'><a href=http://www.mapquest.com/maps/map.adp?searchtype=address&formtype=latlong&latlongtype=degrees&latdeg=".$breedte_deg."&latmin=".$breedte_min."&latsec=".$breedte_sec."&longdeg=".$lengte_deg."&longmin=".$lengte_min."&longsec=".$lengte_sec."&zoom=2 target=_blank>".$row[E_W]." ".$row[lengte_deg]."&ordm; ".$row[lengte_min]."' ";
echo $row[lengte_sec].'"</a></td>';   

echo '<td class="border" style="font-size:9px;">'.$row[omschr_dag].'</td>';
NOW, after this last line, i need a button , when clicked, the user gets a popup wit some more information from this same dbase. I cannot use javascript, because i am inside a php loop. Can somebody give me a working example... PLEASE


Casper

ps, the link where you can see what it looks like up to now you can find in the first message


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed May 03, 2006 4:59 pm
by Ollie Saunders
First of all, every array index you reference in that php code is missing quotes

Code: Select all

$array = array('foo'=>1,'bar'=>2);
echo $array[foo]; // E_WARNING level error, PHP is kind enough to assume you mean the line below
echo $array['foo']; // no error
// you cannot rely on PHP's handling here, so please quote all your array indices
NOW, after this last line, i need a button , when clicked, the user gets a popup wit some more information from this same dbase.
OK.
I cannot use javascript, because i am inside a php loop.
I don't think you understand how PHP works.
PHP runs on the server, when you request a PHP page by its URL the PHP is excuted and only what the PHP script echos reaches the browser. The result contains no PHP, and as far as the browser is concerned no loop ever occured. You can include JavaScript into your page by leaving PHP mode ( ?> ) and that JavaScript will also hit the browser.

Anyway I don't think we should use JavaScript here because that would involve AJAX and that's too complex for a forum reply.
SOOOoooo its time for another PHP script.
Can somebody give me a working example... PLEASE
Yes I think I can. What I am going to do is to get your first PHP file (that presumably displays a summary of all the records from a query) to contain a link (easier than a button) to another PHP file that will get more extended information. So do this the first page has to pass over some information to the second detailing what is being requested. This information will normally be some kind of unique identifier orginating from the database.

I'm using this imaginary database structure for this, sorry for any mistakes:

Code: Select all

CREATE TABLE artist (
	ar_id		INT UNSIGNED NOT NULL AUTO_INCREMENT,
				PRIMARY KEY(ar_id),
	name		VARCHAR(255) NOT NULL,
				INDEX(name),
	born		DATE NOT NULL,
	died		DATE NULL
);

CREATE TABLE painting (
	pa_id		INT UNSIGNED NOT NULL AUTO_INCREMENT,
				PRIMARY KEY(pa_id),
	artist_id	INT UNSIGNED NOT NULL,
				FOREIGN KEY (artist_id) REFERENCES artist(ar_id),
	title		VARCHAR(255) NOT NULL,
	paint		ENUM('watercolor','oil','acyrilic','other') DEFAULT 'other'
);
because I cannot possibly hope to apply this correctly to your project.

artists.php (the summary file)

Code: Select all

<?php

$q = 'SELECT * FROM artist';
$result = mysql_query($q);
if($result === false) exit('Query error');
?>
<table id="artists">
	<tr>
		<th>name</th>
		<th>born</th>
		<th>died</th>
		<th>more</th>
	</tr>
<?
while($row = mysql_fetch_assoc($result)) {
	echo '<tr>';
	// \/ \/ NOT SECURE!!! \/ \/ just an example
	echo '<td>'.$row['name'].'</td><td>'.$row['born'].'</td><td>'.$row['died'].'</td>';
	// URL constructed using ar_id                \/ \/
	echo '<td><a href="paintingsByArtist.php?ar_id='.$row['ar_id'].'">View paintings</a>';
	echo '</tr>';
}
echo '</table>';

?>
paintingsByArtist.php (the detail file)

Code: Select all

if(!isset($_GET['ar_id'])) exit('ar_id unspecified');
$ar_id = (int)$_GET['ar_id'];
if($ar_id == 0) exit('ar_id invalid');

$q = 'SELECT * FROM painting WHERE artist_id = '.$ar_id;
$result = mysql_query($q);
if($result === false) exit('Query error');
?>
<table id="paintings">
	<tr>
		<th>title</th>
		<th>paint</th>
	</tr>
<?
while($row = mysql_fetch_assoc($result)) {
	echo '<tr>';
	// \/ \/ NOT SECURE!!! \/ \/ just an example
	echo '<td>'.$row['title'].'</td><td>'.$row['paint'].'</td>';
	echo '</tr>';
}
echo '</table>';
btw be warned, I literaterally wrote this as fast as I could type.
Hope that helps

Posted: Thu May 04, 2006 12:35 pm
by ctjansen
Hey Ole,

thanks for your reply and taking the time to help me.

I think this is in the direction of what i am looking for, I am going to work on it, see how far I wil get.

Thanks so far

Casper