Simple code to open window and print some info from dbase
Moderator: General Moderators
Simple code to open window and print some info from dbase
I have a window with a list of information (actually a log), you can see it at
http://ctjansen.nl/nuke/modules.php?name=waarbenik
In the last collum you see the item MEER (which means ´more´) and what i would like to do is create a simple routine, where the user clicks on the ´more´of that line, the code retrieves the data from the database for that specific record and displays it in a little popup window with a close button.
Thats all.
I am not a PHP wizard (or any other language for that matter exept for good old clipper), but there must be an easy way to code this.
Could somebody please point me in the right direction, it would be greatly appreciated.
Casper
http://www.ctjansen.nl
http://ctjansen.nl/nuke/modules.php?name=waarbenik
In the last collum you see the item MEER (which means ´more´) and what i would like to do is create a simple routine, where the user clicks on the ´more´of that line, the code retrieves the data from the database for that specific record and displays it in a little popup window with a close button.
Thats all.
I am not a PHP wizard (or any other language for that matter exept for good old clipper), but there must be an easy way to code this.
Could somebody please point me in the right direction, it would be greatly appreciated.
Casper
http://www.ctjansen.nl
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Code: Select all
?>
<!-- all other columns -->
<td>
<a href="simpleRoutine.php?thisRecord=<?php echo $row['id']?>">Go!</a>
</td>Then in simpleRountine.php:
Code: Select all
if(isset($_GET['thisRecord'])) $toBeQueried = (int)$_GET['thisRecord'];
else exit;
$q = 'SELECT * FROM blah blah WHERE id = '.$toBeQueried;
...- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
oh right. i thought you said window by accident and meant page. ok.
try
or possibly:
Having told you how to do it. Now read this and use the example i gave you originally
try
Code: Select all
<a href="#" onclick="window.open('<?php /* as before */?>','window name'); return false">Go!</a>Code: Select all
<a href="<?php /* as before */?>" target="_blank">Go!</a>Ok, I have now put this in:
echo '<td class="border" style="font-size:9px;">'.$row[opmerking].'</td>';
echo "<a href="simpleRoutine.php?thisRecord=<?php echo $row['id']?>" target=blank>Go!</a></td>;
/*echo '<br>';*/
The middle line is your example, but I keep getting a
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/jlolxjqh/public_html/nuke/modules/waarbenik/index_new.php on line 116
is there something not wrong with your code?
Casper
Oh, and i really am gratfull for you taking the time to help a dummie like me.
echo '<td class="border" style="font-size:9px;">'.$row[opmerking].'</td>';
echo "<a href="simpleRoutine.php?thisRecord=<?php echo $row['id']?>" target=blank>Go!</a></td>;
/*echo '<br>';*/
The middle line is your example, but I keep getting a
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/jlolxjqh/public_html/nuke/modules/waarbenik/index_new.php on line 116
is there something not wrong with your code?
Casper
Oh, and i really am gratfull for you taking the time to help a dummie like me.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
echo '<a href="simpleRoutine.php?thisRecord='.$row['id'].'" target=blank>Go!</a></td>';- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Code: Select all
?>
<?php echo 'this will work'?>
<?php
echo 'this will work';
echo '<?php echo 'this will cause an error'?>';
?>Ok , I think this is to hard for me.
The first try finaly worked but gave me a window with only linkable ´GO´
So i tried this:
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>
and keep getting to many errors.
It seems logical but i guess its above my head.
Well, I´ll am willing to try and learn if anybody had the patience...
Thanks
Casper
The first try finaly worked but gave me a window with only linkable ´GO´
So i tried this:
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>
and keep getting to many errors.
It seems logical but i guess its above my head.
Well, I´ll am willing to try and learn if anybody had the patience...
Thanks
Casper
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
OK people really need to learn how strings work.
Watch the colours in this box:
world is black indicating that PHP doesn't believe this to be string. This is because the string begins with the single quote and ends as soon as it hits another single quote. Understand?
So if you wanted to print:
hello 'world'
You would have to use escaping which is were you precede the quote in question with a slash (\)
When PHP sees the slash it knows that the quote after it is to be treated as part of the string instead of the end of it. See its all red now and the string ends when its supposed to.
Watch the colours in this box:
Code: Select all
$string = 'hello 'world'';So if you wanted to print:
hello 'world'
You would have to use escaping which is were you precede the quote in question with a slash (\)
Code: Select all
$string = 'hello \'world\'';- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
post your new code using
Code: Select all
tagsOk guys, well thanks for the help, but i am lost.
I posted this article in the hope i would get a simpel two or three line solution to my question.
Although the asnwers I am getting are much appreciated, they do not bring me closer to the solution. I am to un-experienced to fight with quotes and php tags.
I am not trying to learn PHP, or become a programmer. It is facinating, surely, but I just wanted to add a
small functionality to my site, and turned to you in the hope of a simple solution.
I am about to embark on an 8 year trip around the world, and would have liked to have this extra information on my site, for all to see. The link that is on the first message shows you my day by day log file, where i was, how much km i did this day and the wether condition. Since i have much more info in this dbase (height, rain or not, how much fuel used etc etc) i would have liked it for the visitor to my site, to click on this day and get the extra information of that specific day, then simply click on close and move on.
Sure, I can get a programmer to this work. However I would rather spend this money on things for poor people in poorer countries. I am taking a lot of give-aways, like toothbrushes, toothpaste, calculators etc for the peoples in Nepal, India and Bangladesh and so. I am financing all myself, so you can imagine I have to be carefull.
Wel, I am wandering of the subject. So if anyone has the simple workable solution , please let me know, perhaps I can still get it to work.
Thaks for all the help anyway,
Casper
I posted this article in the hope i would get a simpel two or three line solution to my question.
Although the asnwers I am getting are much appreciated, they do not bring me closer to the solution. I am to un-experienced to fight with quotes and php tags.
I am not trying to learn PHP, or become a programmer. It is facinating, surely, but I just wanted to add a
small functionality to my site, and turned to you in the hope of a simple solution.
I am about to embark on an 8 year trip around the world, and would have liked to have this extra information on my site, for all to see. The link that is on the first message shows you my day by day log file, where i was, how much km i did this day and the wether condition. Since i have much more info in this dbase (height, rain or not, how much fuel used etc etc) i would have liked it for the visitor to my site, to click on this day and get the extra information of that specific day, then simply click on close and move on.
Sure, I can get a programmer to this work. However I would rather spend this money on things for poor people in poorer countries. I am taking a lot of give-aways, like toothbrushes, toothpaste, calculators etc for the peoples in Nepal, India and Bangladesh and so. I am financing all myself, so you can imagine I have to be carefull.
Wel, I am wandering of the subject. So if anyone has the simple workable solution , please let me know, perhaps I can still get it to work.
Thaks for all the help anyway,
Casper
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Invaluable quote by a fellow member
Also, I thought I gave you your answer already as well? Post your new code, in
That doesn't mean we won't help you as much as you can, but we arn't here to do work for you. We are here to push you in the right direction. I can appreciate you don't want to learn something -- but in the real world if I don't know how to do something I hire them in real life.Roja wrote:This is a *learning* site. We help you learn how to do things. Teach a man to fish and he can feed himself for life, ya know?
The alternative (giving you the finished product) is called work. Most people here get paid (a lot) to do that. In most discussions the rate is between $35-$65 US dollars per hour.
I'm sure someone is willing to do it at that rate. If you aren't willing to pay for someone to do work to specification, perhaps you might enjoy learning how to do it yourself, so you can one day charge others.
That service - teaching you a valuable skill - we offer for free here. What a value.
Also, I thought I gave you your answer already as well? Post your new code, in
Code: Select all
tags, perhaps some one will be willing to assist your furthur.