Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using php to getting a sql result on the same page...

Status
Not open for further replies.

tranquillo

Technical User
Jan 6, 2003
22
SE
here we go again.. ;)

----------------------------
----------------------------

<?php

$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);
mysql_select_db(&quot;seko&quot;,$db);

$kid = $_POST[&quot;kid&quot;];
$namn = $_POST[&quot;namn&quot;];
$gadr = $_POST[&quot;gadr&quot;];
$postnr = $_POST[&quot;postnr&quot;];
$ort = $_POST[&quot;ort&quot;];
$sek = $_POST[&quot;sek&quot;];

if ($Submit) {

$query = &quot;INSERT INTO klubb(klubbID,namn,gatuadress,postnummer,ort,sektion)
VALUES('$kid','$namn','$gadr','$postnr','$ort','$sek')&quot;;
$result = mysql_query($query);

$result2 = mysql_query(&quot;SELECT * FROM klubb order by klubbID desc&quot;,$db);
}
if ($myrow = mysql_fetch_array($result2))
{
printf(&quot;<b>Klubb ID:</b> %s<br>\n&quot;, mysql_result($result2,0,&quot;klubbID&quot;));
printf(&quot;<b>Klubbnamn:</b> %s<br>\n&quot;, mysql_result($result2,0,&quot;namn&quot;));
printf(&quot;<b>Adress:</b> %s<br>\n&quot;, mysql_result($result2,0,&quot;gatuadress&quot;));
printf(&quot;<b>Postnummer:</b> %s<br>\n&quot;, mysql_result($result2,0,&quot;postnummer&quot;));
printf(&quot;<b>Ort:</b> %s<br>\n&quot;, mysql_result($result2,0,&quot;ort&quot;));
printf(&quot;<b>Sektion:</b> %s<br>\n&quot;, mysql_result($result2,0,&quot;sektion&quot;));
} else {
echo &quot;Sorry, no records were found!&quot;;
}

?>

----------------------------
----------------------------

<form name=&quot;links&quot; method=&quot;post&quot; action=&quot;<?php echo $PHP_SELF?>&quot;>
<p><br>
<table border=&quot;0&quot; class=&quot;textsmallbold&quot;>
<tr>
<td> Klubb ID : </td>
<td><input type=&quot;text&quot; name=&quot;kid&quot;></td>
</tr>
<tr>
<td>Klubbens namn : </td>
<td><input type=&quot;text&quot; name=&quot;namn&quot;></td>
</tr>
<tr>
<td>Gatuadress : </td>
<td><input type=&quot;text&quot; name=&quot;gadr&quot;></td>
</tr>
<tr>
<td>Postnummer : </td>
<td>Ort :</td>
</tr>
<tr>
<td><input type=&quot;text&quot; name=&quot;postnr&quot;>
<td><input type=&quot;text&quot; name=&quot;ort&quot;></td></td>
</tr>
<tr>
<td>Sektion : </td>
<td> <select name=&quot;sek&quot;>
<option value=&quot;V&auml;g&amp;Ban sydost&quot;>V&auml;g&amp;Ban sydost</option>
<option value=&quot;V&auml;g&amp;Ban nordost&quot;>V&auml;g&amp;Ban nordost</option>
</select></td>
</tr>
<tr>
<td><input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;left&quot;>&nbsp;</td>
</tr>
</table></p>
</form>

----------------------------
----------------------------

what am I doing wrong? this code used to work... but I moved it around and at the beginning it was split up on two pages... and now it don't work... is it the --- action=&quot;<?php echo $PHP_SELF?>&quot;> --- thing that screws thing up? coz that's the only thing I can think of... (it's 5am, so I might have missed a couple of things though) and I don't know how to do the php_self thing...

thanks

 
You are missing a ;

<?php echo $PHP_SELF;[color] ?>

also to keep in line with programming for later versions of PHP would be advisable to change it to:
<?php echo $_SERVER[PHP_SELF]; ?> ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
The semicolon shouldn't matter, since PHP would parse the ?> as the end of the command. //Daniel
 
Hehe just realised that ... been playing with perl all weekend and realised my mistake almost as quickly ay you Dan :p ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top