Jump to content

Recommended Posts

Posted

I am running a small website with sories about my travels. It features all my travel stories, pictures and a LOGBOOK. In this logbook I keep record of things like where I was that day, what the weather was like, road conditions etc.

 

I want to give the user some of this info, and have done some of the programming already but now I am stuck.

Where do I go to get some good help with this PHP programming. I probably need only 10 lines of code, I am even willing to pay for it. I am not a programmer myself, although I try.

 

Can somebody give me a suggestion where to go?

 

(look here for what I have done so for... sorry all in Dutch):

 

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

 

thanks for any suggestions

 

Casper

Posted

Hey stevevan

 

Well, as I mentioned I have this data in my Mysql dbase. On a daily basis I keep things like road conditions., fuel consumption, weather, milage, etc etc.

The user can see my log here:

 

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

 

but this shows only a little part of all the data I keep per day. So I want sort of like a button under the last collumn (the collumn is called ´Meer´, Dutch for ´more´) and when the user clicks the button, a popup window appears with the rest of the info of that day. The user hits the ´close´button on the popup,, it disappears and the user happily browses on.

 

Sounds simple to me, but not being a programmer i might see it to simple :)

 

I have tried a few things, but nothing worked satisfactory.

 

Any ideas, any help?

 

 

 

Casper

Posted

You may also want to check out some script sites like javascripts.com. I've found several things I've used on web sites there!

 

BTW...my father came from Workum and I still have several great aunts & uncles there!

Posted

Hi,

 

What you will need to do is for each button, it must have a value, normally the day, or a unique key in the database. When this is pressed, you should be able to do a simple mysql search and then grab all the data for that day (or key) and display it in the popped up window. I am sure if you look at some very simple PHP database starter scripts, it will show you how to connect, and pull the data based on data passed to it

 

JimE

Posted

Hey guys, thanx for helping me.

Stevevan...Workum hu, nice quite little town. Lots of farmers I think. Ever been there...? You should.... Speak any Dutch, or only the bad words? :D

 

Anyway, i figured I had to do some javasripting, the problem is hoewever that the routine that puts the log on the screen is PHP and i cannot in the loop, just swicth to javascript. Here is how it works:

First I make the connection with the dbase, so far no problem. Then I read the entire log file:

 

$query = "SELECT * FROM log_new ORDER BY datum DESC, beg_km DESC ";

$result = mysql_query($query);

 

 

?>

 

 

 

then make the collums and print the table:

 

<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);

 

 

 

/*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].'º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]."º ".$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]."º ".$row[lengte_min]."' ";

echo $row[lengte_sec].'"</a></td>';

 

echo '<td class="border" style="font-size:9px;">'.$row[omschr_dag].'</td>';

 

and now i need to put the link or the button, and i do not know how to do this. I have tried this:

 

echo "<td class='border' style='font-size:11px;'><a href=http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?land=".$row[land]."&datum=".$row[datum]."&beg_plaats=".$row[beg_plaats]." target=blank > meer info ";

 

This links to a new program ´map.php´ and passes the variables. But then i do not know hot to work with these variables inside map.php. It might be better to keep it all together because switching from php files i think is not so nice.

 

 

if you see al this, you might think i am a hell of a prgrammer , but I have not made this. I wish I could.

 

Could anybody give me an example of how to continue to get it to work. It must be so simple for all you wise programmers (lick*lick) :wallbash:

 

Hope to hear from you

 

Casper

Posted

http://www.ctjansen.nl/nuke/modules/waarbe...quot;.$row[land]."&datum=".$row[datum]."&beg_plaats=".$row[beg_plaats]." target=blank

 

In versions of PHP up to and including 4.1.x, the information afer the ? will appear in variables of the same name as the first word, content being the second word - for example

.....php?fred=tom

will give you a variable called $fred with the value tom.

 

From versions 4.1.x up, you should use the $_GET array, so our example would set you an array element called $_GET["fred"]with a value of tom.

 

Does this help?

Posted

Just one more simple question.

 

I am working in PHP.

I am calling another php file with this link:

 

echo "<td class='border' style='font-size:11px;'><a href=http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=".$row[recno]." target=_blank> meer ";

 

now in map.php i can acces this passed recno variable with this:

 

echo $_GET["recno"] ;

 

but a few lines further on I am switching to javascript.

How do i acces the same variable in Javascript (in the same program?)

 

say I open a popup in javascript (which was my intention al along) , and I want to print rekno in this popup window?

 

Should be simple... I hope?

 

Casper

Posted

I'm no javascript expert, but from what I have found on the web, something like this should work:

<script type="text/javascript" language="javascript">

<!--

<?php

echo ("javaRecno = $_GET['recno'];") ;

?>

// -->

*** Do whatever with $javaRecno in your javascript here ***

</script>

Posted

He Steve,

 

did you actually try this, because I cant get it to work. Can you tell me where you found it, perhaps i can go and study some more there.

Posted (edited)

var sStr = "My name is <?php echo $username ?>.";

<script type="text/javascript" language="javascript">

var javaRecno = "<?php echo $_GET['recno']?>";

*** Do whatever with $javaRecno in your javascript here ***

</script>

 

Found here: http://p2p.wrox.com/topic.asp?TOPIC_ID=12125

 

First example was found here: http://www.daniweb.com/techtalkforums/thread19598.html

 

but I see the error in the first page through the second answer. I just searched Google with "access php variable in javascript" (without the quotes).

Edited by Steve Scrimpshire
Posted

YES YES YES

did get it to work.

Now only one problem left to solve, and I am a happy traveller :)

 

Ok, as you know, I am putting a link in my table. User can click it, then the map.php is called, with the record number of the data the user wants to see. In map.php i retrieve the data from the dbase, create a popup and print the data in the popup. All just as I wanted it, with one exception.... because i am using a link, my main window/screen is also going blank, since it thinks I guess that map.php is a different screen or so. Mmm, and that is not what I wanted.

 

So either I have to change the link in such a way that the main screen/monitor just stays on the monitor, (some paramter i do not know, using target=blank is not the solution, because then i get a popup AND a new window)or I have to rewrite it all, and instead of using a link (href....), I use a buttun, but then I have to start all over agaian.

Can anyone follow me? If so, any advise.

 

Thanks

Posted

Valid target types are:

 

* _blank - the target URL will open in a new window

* _self - the target URL will open in the same frame as it was clicked

* _parent - the target URL will open in the parent frameset

* _top - the target URL will open in the full body of the window

Posted
So either I have to change the link in such a way that the main screen/monitor just stays on the monitor, (some paramter i do not know, using target=blank is not the solution, because then i get a popup AND a new window)or I have to rewrite it all, and instead of using a link (href....), I use a buttun, but then I have to start all over agaian.

 

I know little about these things but I have seen where target=blank and target=_blank mean different things.

 

With HTML I believe you can give any name you want to a target window.

 

I have seen on my test site where target="results" will open a new window only if another window named "results" doesn't exist, otherwise the existing window will be used. Similar to how Google "open search results in a new window" works. Every time you click a link with target="results" the same window displays the data.

 

I do not think this applies in your case since you say man.php opens in a new window and that window opens yet a third window. You say that your first window is going blank?

Posted

Yes, I think it does not apply to me.

Lets do one step back.

 

in my main program, a table is set up with this link inside:

 

echo "<td class='border' style='font-size:11px;'><a href=http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=".$row[recno]." > meer ";

 

the link opens map.php whit the ´recno´ (record number) of the data the browser want to see (and also a blank window, which is what i do not want)

 

in Map.php I read the data from the database :

 

$q = 'SELECT * FROM log_new WHERE recno = '.$recnum;

$result = mysql_query($q);

if($result === false) exit('Query error');

 

and then have a function called popitup to do the popup and the printing of the data into this popup:

 

 

function popitup2()

{

newwindow2=window.open('','name','height=200,width=150');

var tmp = newwindow2.document;

var jrecno = "<?php echo $recno; ?>";

tmp.write('<html><head><title>popup</title>');

tmp.write('<p><a href="java script:self.close()">close</a> the popup.</p>');

tmp.write('</body></html>');

tmp.close();

}

 

 

popitup2()

 

 

and I call the function

(in this example i only echo recno, but the priciple is the same for all the database data)

 

Easy...?

 

ok, the problem is that the first line opens a fresh window, and the popup opens one as wel, so i have one window to many.

So idealy I should change the href in program 1 to a button with the link or so.

 

anybody have a clever idea?

sorry to be so persistent, but i am so close to making it work....

Posted (edited)
Ok, as you know, I am putting a link in my table. User can click it, then the map.php is called, with the record number of the data the user wants to see. In map.php i retrieve the data from the dbase, create a popup and print the data in the popup. All just as I wanted it, with one exception.... because i am using a link, my main window/screen is also going blank, since it thinks I guess that map.php is a different screen or so. Mmm, and that is not what I wanted.

 

Right. There is no output from map.php other than the popup, so when you click the link, the main screen goes blank. If you use javascript to open a new window from where you are, then have map.php just do normal output, that'll be what you want.

 

So, instead of this in your main page:

<a href=http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=".$row[recno]." > meer </a>;

 

put this:

 

<FORM>

<INPUT type="button" value="meer" onClick="window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=".$row[recno]." ','mywindow','width=150,height=200')"></FORM>

 

Then just have map.php output normally. You can still have this:

<p><a href="java script:self.close()">close</a> the popup.</p>

To have a close button if you wish.

Edited by Steve Scrimpshire
Posted

I wish life was so easy..

 

echo '<td class="border" style="font-size:9px;">'.$row[omschr_dag].'</td>';

echo '<td class='border' style='font-size:11px;'>'<FORM> <INPUT type="button" value="meer" onClick="window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=".$row[recno]." ','mywindow','width=150,height=200')">

</FORM>

echo '</a></td>';

 

 

gives me this:

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/jlolxjqh/public_html/nuke/modules/waarbenik/index.php on line 119

(line 119 is the one with the FORM statement)

Posted
echo ''.$row[omschr_dag].'';

echo '

' ' ;

echo '

' ;

echo '

';

 

I think you need a ; after the middle two lines,

and an echo for the closing form tag (added in red).

 

or you could try this

echo <<< HEREDOC

$row[omschr_dag]

onclick="window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=$row[recno]

,'mywindow','width=150,height=200')">

HEREDOC;

Posted (edited)

Yes, this works fine, for one problem. (haha, always ONE problem left).

It should open a window (which it doesn´t), instead of calling map.php.

 

can somebody tell me what to change in the line

<INPUT type="button" value="meer"

onClick="window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=$row[recno]

,'mywindow','width=150,height=200')">

 

instead of opening a window, starting map.php

 

Please...

Edited by ctjansen
Posted

I don't have a problem with it. It opens a new window fine, which goes to the right map.php (of course it gives me an error because the recno i made up is wrong:

recnum nie goed joggie
I did have to escape some of the quotes in this line:

echo '<INPUT type="button" value="meer" onClick="window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=".$row[recno]." ','mywindow','width=150,height=200')">';

 

like this:

echo "<INPUT type=\"button\" value=\"meer\" onClick=\"window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=$row[recno]','mywindow','width=150,height=200')\">";

 

Sorry I am not catching these small problems ahead of time.

 

If you use the HERE doc like Don suggests:

echo <<< HEREDOC

<td class="border" style="font-size:9px;"> $row[omschr_dag] </td>

<td class='border' style='font-size:11px;'>

<FORM>

<INPUT type="button" value="meer"

onClick="window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=$row[recno]

,'mywindow','width=150,height=200')">

</FORM>

</a></td>

HEREDOC;

 

I don't think you'll have to escape the quotes.

Posted

Steve, don´t be sorry. I am so glad with the help you are giving me.

However, I do NOT want a new window to open, because in map.php I have a routine which opens the popup window already, and I do not want two windows to open. I just need the line(or button) to start map.php. WITHOUT openeing a window.

 

Possible?

Posted

To get the effect you want in your original request and keep the main table showing in the main window, taking out the code in map.php that opens the popup and doing the last way i describe is the best way. Let the main page open the popup with the info from map.php in it.

Posted

The reason I thought it would be easier not to open a window is that I have this function :

 

function popitup2()

{

newwindow2=window.open('','name','height=200,width=150');

var tmp = newwindow2.document;

var jrecno = "<?php echo $recno; ?>";

 

 

tmp.write('<html><head><title>popup</title>');

 

tmp.write('</head><body><p>this is once again a popup.</p>');

 

 

tmp.write(jrecno);

 

 

tmp.write('<p><a href="java script:alert(self.location.href)">view location</a>.</p>');

tmp.write('<p><a href="java script:self.close()">close</a> the popup.</p>');

tmp.write('<p><a href="java script:self.close()">close</a> the popup.</p>');

tmp.write('</body></html>');

tmp.close();

}

 

 

which pops up and writes variables without needing anything else.

I would not know how to change the opening part only.

 

casper

Posted (edited)

So, this evening I have been trying with this line for 90 minutes:

 

echo '<td class='border' style='font-size:11px;'> <INPUT type=button value=\"meer\" onClick=\"http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=$row[recno];\"></td>';

 

and only getting this stupid error:

Parse error: syntax error, unexpected T_CLASS, expecting ',' or ';' in /home/jlolxjqh/public_html/nuke/modules/waarbenik/index.php on line 119

 

(I am asuming onclick is PHP, cause I am in PHP mode)

if i wasn´t bold already, i would pull the hairs right out.....grrrr

Edited by ctjansen
Posted

I'm not a PHP person, not really at least. But my guess is that you're having a nested apostrophe problem.

 

It looks like you want to echo the whole line, is that right?

 

I think that the apostrophe after the word echo is getting closed by the apostrophe between the equals sign and the word "border".

 

Does that make sense? So what if you used double quotes around the class and style attributes.

 

If that doesnt work, then I'd say that you might try pulling the whole thing out of PHP and rendering that line in HTML, adding just PHP code where you need it.

Posted (edited)

echo "<td class='border' style='font-size:11px;'> <INPUT type=button value=\"meer\" onClick=\"http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=$row[recno];\"></td>";

 

Instead.

 

In map.php, you don't need any javacript. Just print it to the window (the one that you popup from the original page with the code i suggest) in map.php:

 

<?php

 

**your code to parse the database**

 

echo <<< HEREDOC

<html><head><title>popup</title></head>

<body>

$recno;

<p><a href="java script:alert(self.location.href)">view location</a>.</p>

<a href="java script:self.close()">close</a> the popup.</p>

</body>

</html>

HEREDOC;

?>

 

 

Much easier if you have opened the popup from the original page already.

Edited by Steve Scrimpshire
Posted

Hello,

 

I get the same problem.

 

However, the error code I get in IE is:

 

>Expected '}'
Line 137 Char 78

 

However, Firefox is far more handy with its error listing, it even points to the exact spot!

 

>Error: missing ) after argument list
Source File: http://ctjansen.nl/nuke/modules.php?name=waarbenik
Line: 1, Column: 77
Source Code:
window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=1 ,'popup.htm','width=150,height=200')

 

Notice the ' is lacking from the end of the URL, try fixing that bit first.

 

Try this correction:

>window.open('http://www.ctjansen.nl/nuke/modules/waarbenik/map.php?recno=1','popup.htm','width=150,height=200')

One step at a time!

 

JimE

Posted

Hey Guys,

 

The problem has been tackled, the solution found and the program written.

 

For all of you who helped me :

 

THANKSTHANKSTHANKS :offtopic:

 

And for all of you who want to see what it became:

 

My Webpage

 

I have learned a lot, i am even starting to like it , so... until a next time :whip:

 

Greetz

 

Casper

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...