Does anyone here know PHP and/or J*a*v*a*s*c*r*i*p*t?

I can't even get angry at you for getting my hopes up and then crushing them, if you keep complimenting me. :D
 
I need to pass a avariable from my webpage to a php-file. Right now, nothing happens when I choose one of the options.

code on webpage:

Code:
		<div class="rubrik" id="valjprojekt">
			<form name="form1" method="get" action="hamtaInfo.php">
    	   	<label for="vp">Välj projekt:<br>
    	   	</label>
    	   	<select name="item">
    	   	  <option>*** Välj projekt ***</option>
    	   	  <option <?php if($item == "knatte") echo "selected"; ?>knatte</option>
    	   	  <option <?php if($item == "fnatte") echo "selected"; ?>fnatte</option>
    	   	  <option <?php if($item == "tjatte") echo "selected"; ?>tjatte</option>
              
    	   	 </select>
    	 	<p></p>
			</form>
		</div>

PHP:
<?php

$namnet = $_POST["item"]; 

$con = mysql_connect("hostname","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

$result = mysql_query("SELECT * FROM projekt WHERE namn = '" . $namnet . "'");

echo "<table><tr><td colspan='2' class='rubrik'>Alla projekt</td></tr>";

while($row = mysql_fetch_array($result))
  {
	  $sammanlagt = $row['antaltimmar'] * $row['timkostnad'];
  echo "<tr><td>Projektnamn: </td><td>" . $row['namn'] . "</td></tr>";
  echo "<tr><td>Beskrivning: </td><td>" . $row['beskrivning'] . "</td></tr>";
  echo "<tr><td>Antal timmar: </td><td>" . $row['antaltimmar'] . "</td></tr>";
  echo "<tr><td>Timkostnad: </td><td>" . $row['timkostnad'] . "</td></tr>";
  echo "<tr><td>Total kostnad för detta projekt: </td><td>" . $sammanlagt . "</td></tr>";
  echo "<tr><td>Startdatum: </td><td>" . $row['startdatum'] . "</td></tr>";
  echo "<tr><td>Slutdatum: </td><td>" . $row['slutdatum'] . "</td></tr>";
  
  }
echo "</table>";

mysql_close($con);
?>
 
I can't even get angry at you for getting my hopes up and then crushing them, if you keep complimenting me. :D

I can't really answer your question as I'm Javaskript daft, but as a fellow artist, I would love to know if you drew your avatar.

And how close you resemble it. :devil:
 
Your HTML does not seem to post the form. Easiest is to add a submit button, I suppose.

But you want it to send the string as a variable as soon as you select it? That's were Jahvescript comes in. Sad to say, I can't remember what you're supposed to do, code wise. I think the trigger is OnSelect or OnChange.
 
Your HTML does not seem to post the form. Easiest is to add a submit button, I suppose.

But you want it to send the string as a variable as soon as you select it? That's were Jahvescript comes in. Sad to say, I can't remember what you're supposed to do, code wise. I think the trigger is OnSelect or OnChange.
You don't know what you're talking about.
 
well, prove it.

don't just sit there and take pot shots.

help her fix the problem.
Prove it to whom?

Make it worth my while.

And at least manage to post the word if you want to get my attention.
 
I need to pass a avariable from my webpage to a php-file. Right now, nothing happens when I choose one of the options.

code on webpage:

Code:
		<div class="rubrik" id="valjprojekt">
			<form name="form1" method="get" action="hamtaInfo.php">
    	   	<label for="vp">Välj projekt:<br>
    	   	</label>
    	   	<select name="item">
    	   	  <option>*** Välj projekt ***</option>
    	   	  <option <?php if($item == "knatte") echo "selected"; ?>knatte</option>
    	   	  <option <?php if($item == "fnatte") echo "selected"; ?>fnatte</option>
    	   	  <option <?php if($item == "tjatte") echo "selected"; ?>tjatte</option>
              
    	   	 </select>
    	 	<p></p>
			</form>
		</div>

PHP:
<?php

$namnet = $_POST["item"]; 

$con = mysql_connect("hostname","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

$result = mysql_query("SELECT * FROM projekt WHERE namn = '" . $namnet . "'");

echo "<table><tr><td colspan='2' class='rubrik'>Alla projekt</td></tr>";

while($row = mysql_fetch_array($result))
  {
	  $sammanlagt = $row['antaltimmar'] * $row['timkostnad'];
  echo "<tr><td>Projektnamn: </td><td>" . $row['namn'] . "</td></tr>";
  echo "<tr><td>Beskrivning: </td><td>" . $row['beskrivning'] . "</td></tr>";
  echo "<tr><td>Antal timmar: </td><td>" . $row['antaltimmar'] . "</td></tr>";
  echo "<tr><td>Timkostnad: </td><td>" . $row['timkostnad'] . "</td></tr>";
  echo "<tr><td>Total kostnad för detta projekt: </td><td>" . $sammanlagt . "</td></tr>";
  echo "<tr><td>Startdatum: </td><td>" . $row['startdatum'] . "</td></tr>";
  echo "<tr><td>Slutdatum: </td><td>" . $row['slutdatum'] . "</td></tr>";
  
  }
echo "</table>";

mysql_close($con);
?>

I see the problem.

You spelled "project" wrong. Correct the spelling and you'll be good to go.
 
I really don't know what to make of these people, sometimes.
I happen to agree that if you know the answer, you should give it. Liar's no dummy; I seem to recall some deep familiarity with granular synthesis or FFT or the like. He'd probably be as interested as anyone else in the correct answer.
 
Back
Top