A database for my data

From: ANT_THOMAS18 Nov 2008 23:18
To: Dan (HERMAND) 23 of 158
Ah, not what I want then. Command needs to be run client side.
From: steve18 Nov 2008 23:20
To: ANT_THOMAS 24 of 158
PC Format coverdisks used to use some form of magic to make the browser run an .exe installer without complaining. It was discussed on the first Delphi PCF forum.

HTH :$
From: Peter (BOUGHTONP)18 Nov 2008 23:59
To: ALL25 of 158
Oooh - investigate HTA - that lets you execute shell commands and also connect to servers.

Assuming uni machines don't block it.
From: empathy19 Nov 2008 00:25
To: ANT_THOMAS 26 of 158
Write a tiny program (c, vb, whatever) that can open a certain file extension, say .ant and which then simply runs

c:\Program Files\SpinWorks\SpinWorks.exe Z:\Docs\Uni\MPhil\NMR\2008-10-21-AB-26\10\fid

or whatever. You could either have the .ant file contain the correct directory to use in the call. Then associate .ant files with the application on the client computer, and get your web app to produce the appropriate .ant files. Bit of effort involved but at least it will work seamlessly.
From: Ally19 Nov 2008 14:50
To: empathy 27 of 158
But add a crapload of security to check what it's trying to do. Otherwise you're leaving a huge security hole on the computer... not one that's likely to be exploited but still bad practise.
From: ANT_THOMAS30 Nov 2008 00:08
To: ALL28 of 158

I gave up on the getting things to open in Spinworks idea since it seems way more hassle than it's worth right now, but with what I've decided to do I've come across a problem.

 

When I open a full entry to show the full set of data I want to click a link to show any of the spectra as a PNG or JPEG. I want this image to load underneath the main content area, in an extra DIV. Is this possible easily? Or is the alternative an iframe? (which I was trying to avoid)

 

Also, are there are any batch converters for PDF to PNG/JPEG? I tried irfanview but it was being an arse not being able to recognise PDFs properly even after installing the relevant plugins.

From: ANT_THOMAS30 Nov 2008 00:10
To: ANT_THOMAS 29 of 158
Oh, I want this DIV to be invisible until the image link is clicked.
From: Peter (BOUGHTONP)30 Nov 2008 00:30
To: ANT_THOMAS 30 of 158
You don't need an extra div nor an iframe. Just plonk an image there onclick.

If you provide the current HTML you've got, I can give you the appropriate script. :)
From: ANT_THOMAS30 Nov 2008 01:17
To: Peter (BOUGHTONP) 31 of 158
Which bit of the HTML?
From: ANT_THOMAS30 Nov 2008 01:18
To: Peter (BOUGHTONP) 32 of 158

If you want the actual PHP file then I'll C&P the code.

 

Don't shout at me though.

From: Peter (BOUGHTONP)30 Nov 2008 01:26
To: ANT_THOMAS 33 of 158
I'm not sure. :S

You mentioned something about the main content, and also about the full details - my brain can't figure out how you've got things setup.

With jQuery, you can do something along the lines of:
code:
<a href="spectra1.jpg" onclick="$j('img#spectra').attr('src','spectra1.jpg').show(); return false">view spectra</a>


And then under the content you have
code:
<img id="spectra" src="" alt="" style="display:none;"/>


Which isn't perfect but should work.
From: Peter (BOUGHTONP)30 Nov 2008 01:28
To: ANT_THOMAS 34 of 158
quote:
Don't shout at me though.


Is that your way of saying the code is really terrible? :P


If ^that^ stuff doesn't work then you can provide the PHP and I'll give you an exact solution in the morning. Goodnight. :)
EDITED: 30 Nov 2008 01:29 by BOUGHTONP
From: ANT_THOMAS30 Nov 2008 01:33
To: Peter (BOUGHTONP) 35 of 158
That just seems to open the image directly.

http://wakeupbomb.no-ip.org/full.php?id=5

PHP code:
<html>
<head>
<title>NMR Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
 
<?php
mysql_connect("localhost","xxxxxx","******");
mysql_select_db("nmr");
$tableid = $_GET['id'];
$query  = "SELECT id,code,labbookref,contents,solvent,elements,servercode,time,machine,year,month,nmre1,nmrn1,nmre2,nmrn2,nmre3,nmrn3,nmre4,nmrn4,nmre5,nmrn5 FROM nmr WHERE id=$tableid";
$result = mysql_query($query);
 
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo "
 
 
		<table border='0' width='auto' style='margin-left: 0px;'>
		<tr>
		<td class='fulltop' width='50px'>{$row['code']}</td>
		<td class='fulltop' width='50px'>{$row['labbookref']}</td>
		<td class='fulltop' width='680px' align='right'>{$row['contents']}</td>
		</tr>
		</table>
 
		<div class='fullmain'>
		{$row['solvent']}<br />
		{$row['elements']}<br />
		{$row['year']}<br />
		{$row['month']}<br />
		<a target='_blank' href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn1']}/pdata/1/email_{$row['servercode']}_{$row['nmrn1']}_1.pdf'>{$row['nmre1']}</a><br />
		<a target='_blank' href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn2']}/pdata/1/email_{$row['servercode']}_{$row['nmrn2']}_1.pdf'>{$row['nmre2']}</a><br />
		<a target='_blank' href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn3']}/pdata/1/email_{$row['servercode']}_{$row['nmrn3']}_1.pdf'>{$row['nmre3']}</a><br />
		<a target='_blank' href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn4']}/pdata/1/email_{$row['servercode']}_{$row['nmrn4']}_1.pdf'>{$row['nmre4']}</a><br />
		<a target='_blank' href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn5']}/pdata/1/email_{$row['servercode']}_{$row['nmrn5']}_1.pdf'>{$row['nmre5']}</a><br />
		{$row['servercode']}
<br />
<br />
		<a target='image' href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn1']}/pdata/1/email_{$row['servercode']}_{$row['nmrn1']}_1.png'>{$row['nmre1']}</a><br />
                <a href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn1']}/pdata/1/email_{$row['servercode']}_{$row['nmrn1']}_1.png' onclick='$j('img#spectra').attr('src','./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn1']}/pdata/1/email_{$row['servercode']}_{$row['nmrn1']}_1.png').show(); return false'>{$row['nmre1']} #2</a>
		<img id='spectra' src='' alt='' style='display:none;'/>
                </div>
                <iframe name='image' width='780px' height='550px' frameborder='0' class='fullimage' ></iframe>
 
 
 
 
 
         ";
}
 
 
 
 
?>
</body>
</html>
EDITED: 30 Nov 2008 01:36 by ANT_THOMAS
From: Peter (BOUGHTONP)30 Nov 2008 14:27
To: ANT_THOMAS 36 of 158
Ah, I forgot to explicitly mention the bit where you need to add jQuery library to the page.

Download this file, put it in the same dir as the stylesheet and then insert this code just before the </head>
code:
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript">$j = jQuery.noConflict();</script>




And yes, that code is terrible. :P

You could at least save yourself some headache by doing:

PHP code:
$prefix = "./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/";


Just before the echo, after the opening brace.

And then replacing the start of all your links with {$prefix} to make things a bit more readable.
EDITED: 30 Nov 2008 14:31 by BOUGHTONP
From: ANT_THOMAS30 Nov 2008 14:33
To: Peter (BOUGHTONP) 37 of 158
Thank you, and good idea. I'll give that a go.
From: ANT_THOMAS30 Nov 2008 14:50
To: Peter (BOUGHTONP) 38 of 158
I've stuck these lines in...

PHP code:
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript">$j = jQuery.noConflict();</script>

(between the head tags)

then

PHP code:
<a href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn1']}/pdata/1/email_{$row['servercode']}_{$row['nmrn1']}_1.png' onclick='$j('img#spectra').attr('src','./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn1']}/pdata/1/email_{$row['servercode']}_{$row['nmrn1']}_1.png').show(); return false'>{$row['nmre1']} #2</a>
<br />
<img id='spectra' src='' alt='' style='display:none;'/>


But it just opens the image directly instead of within the page.
EDITED: 30 Nov 2008 14:51 by ANT_THOMAS
From: Ally30 Nov 2008 17:20
To: ANT_THOMAS 39 of 158
Two possibilities:

  • The js is erroring out before it gets to return false- therefore it'll just go ahead and follow the link. It might then also wipe the JS error console and you won't get to see what the problem is. Try just doing a href to # to test it.
  • return false isn't actually a terribly reliable way of stopping things from happening. I forget the details now but in MooTools you'd call e.stop() to stop all event bubbling. But Peter made you use jQuery, so he can bloody well sort out his own mess, can't he?
From: Peter (BOUGHTONP)30 Nov 2008 18:02
To: ANT_THOMAS 40 of 158
Firstly, make sure you're testing in Firefox, and have Firebug installed, as it makes debugging much easier.

Then, you can either:
1) switch the href to # like Ally says
2) rename it to xhref which is a little simpler

And then look in Firebug's console to see what it says about the error.
From: ANT_THOMAS30 Nov 2008 20:17
To: Peter (BOUGHTONP) 41 of 158
Changed it to <x href and firebug says

syntax error
http://wakeupbomb.no-ip.org/full.php?id=5
Line 1
(

When it is an 'a' the code outputted by the page is:

PHP code:
<a false="" return="" ).show();="" email_2008-10-09-ab-49_10_1.png="" 1="" pdata="" 10="" 2008-10-09-ab-49="" nmr="" ab="" data="" oct="" 2008="" bruk400data="" .="" ,="" src="" ).attr(="" img#spectra="" onclick="(" href="./nmr/bruk400data/2008/Oct/data/AB/nmr/2008-10-09-AB-49/10/pdata/1/email_2008-10-09-AB-49_10_1.png">F #2</a>
<br/>
<img id="spectra" style="display: none;" alt="" src=""/>


I see that somehow there is a cheeky extra RHS bracket there:

<a false="" return="" ).show();=""

The code I on the page is:

PHP code:
<a href='./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn1']}/pdata/1/email_{$row['servercode']}_{$row['nmrn1']}_1.png' onclick='$j('img#spectra').attr('src','./nmr/{$row['machine']}/{$row['year']}/{$row['month']}/data/AB/nmr/{$row['servercode']}/{$row['nmrn1']}/pdata/1/email_{$row['servercode']}_{$row['nmrn1']}_1.png').show(); return false'>{$row['nmre1']} #2</a>
<br />
<img id='spectra' src='' alt='' style='display:none;'/>


I should really start using your $prefix idea because the long directory structures are doing my head in now.
From: Peter (BOUGHTONP)30 Nov 2008 20:30
To: ANT_THOMAS 42 of 158
Eh? I didn't mean <x href=""... - I meant <a xhref=""...

Anyway, no matter - the problem is that you've got single quotes for the HTML attributes, which is conflicting with the JavaScript single quotes, and causing all that funniness to occur.

Use double quotes for the onclick and it should be fine - but that means escaping them with a backslash so PHP echo doesn't get all confused:

code:
onclick=\"...\"


Once you've got that all working, you can replace the URL within onclick section with this.href so you don't have to repeat yourself but also keep your code accessible.