DeFActo Posted March 30, 2008 Share Posted March 30, 2008 Hello, i have php file a.php with code <?php $link = mysql_connect('', '', ''); mysql_select_db(''); $sql = "SELECT * FROM table1 WHERE id='caspa'"; $sql1= "SELECT * FROM table2 WHERE id='caspa'"; $sql2="SELECT * FROM table3 WHERE id='caspa'"; $query = mysql_query($sql); $query1 = mysql_query($sql1); $query2 = mysql_query($sql2); $result=mysql_fetch_assoc($query); $result1=mysql_fetch_assoc($query1); $result2=mysql_fetch_assoc($query2); if ($result && $result1 && $result2) { $a=$result['gylis4']; $b=$result['gylis3']; $a1=$result1['plotis4']; $b1=$result1['plotis3']; $a2=$result2['aukstis4']; $b2=$result2['aukstis3']; } else{ echo "There is no such a record."; } echo "$a"; //echo "$b<br>"; //echo "$a1"; //echo "$b1<br>"; //echo "$a2"; //echo "$b2"; //echo "$a<br>"; //echo "$a<br>"; //echo "$a<br>"; //echo "$a<br>"; ?> and i need to see the results in a.html file. Anybody could help me with that? Its something like that <form id="form1" name="form1" method="post" action="a.php"> but it doesn't work for me Thank you in advance. Quote Link to comment Share on other sites More sharing options...
Cosizzle Posted March 30, 2008 Share Posted March 30, 2008 Since you are using a forum yes, the forum would be first, and it would error check against a php script. so <form id="form1" name="form1" method="post" action="a.php"> once its submitted it should check against "a.php" I would suggest trying this out here: http://www.tutorialized.com/view/tutorial/HTML-Mail/30099 Quote Link to comment Share on other sites More sharing options...
DeFActo Posted March 30, 2008 Author Share Posted March 30, 2008 Thanks for the replay, but that example opens that a.php, what i need is that the result would be displayed in some html file, e.g. a.html. Quote Link to comment Share on other sites More sharing options...
haku Posted March 31, 2008 Share Posted March 31, 2008 PHP files output (x)html to the browser. So it shouldn't matter. If for some reason you really need your file to have the file extension as .html, then you have two options, both of which will require playing with your server settings. You need to either do a mod re-write, in which case you actually write the file in php, and the file extension is php, but when the user enters an address with a .html file extension, it shows in the browser as being .html, but in fact the page is .php in the background, or else you need to enable your server to parse .html files as .php. This will slow down your processing on static .html pages though, as the server will extend resources in attempting to parse the file even though it doesn't require parsing. Quote Link to comment Share on other sites More sharing options...
DeFActo Posted March 31, 2008 Author Share Posted March 31, 2008 Thanks for the reply, but i think you did not understand what i want (that is my fault, because i did not give enough information). What i want to do is: lets say i have index.html file with some design, couple of buttons and table and i have that a.php file that coresponds with database. What i want to do is if i push one button in index.html file i get results from a.php file in some index.html tables cell. Sorry for my bad english. Thank you in advance. Quote Link to comment Share on other sites More sharing options...
haku Posted April 1, 2008 Share Posted April 1, 2008 Ahh I see. Well if you want to use only php, then you cannot do this without using the techniques I mentioned above. HTML files are static - they cannot be changed. This also means that they cannot interact with the database. The only way around this is to either set your server to parse html files as PHP, or to use mod re-write (which are the two methods I previously mentioned). You CAN however do this with AJAX (using Javascript and Dom functions). You will need to write a php script that pulls the data from the database and echos it. Then you need to use javascript to access that script, and when the results come back, use dom scripting to insert the data into the proper data cell. This method works very good with one downside - it won't work if the user has javascript turned off. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted April 1, 2008 Share Posted April 1, 2008 OR, you can use php to open the index.html file and edit its contents... Quote Link to comment Share on other sites More sharing options...
haku Posted April 1, 2008 Share Posted April 1, 2008 Good point, although that would still require accessing a php file instead of an html file would it not? Quote Link to comment Share on other sites More sharing options...
DeFActo Posted April 1, 2008 Author Share Posted April 1, 2008 Any example how to do it, and is it hard enoug for the begginer? Thank you in advance. Quote Link to comment Share on other sites More sharing options...
haku Posted April 1, 2008 Share Posted April 1, 2008 Google is your friend. Not so easy for a beginner though whichever method you choose. I would suggest just using php docs instead of html docs. If you are a begginer, that is your easiest solution. Quote Link to comment Share on other sites More sharing options...
DeFActo Posted April 1, 2008 Author Share Posted April 1, 2008 OK thanks, i will try to play with php files. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.