JIMBOJAMBO99 Posted April 13, 2008 Share Posted April 13, 2008 I have the following PHP script: <?php $link = mysql_connect('localhost', 'myuser', 'mypw') or die('Could not connect: ' . mysql_error()); #echo 'Connected successfully'; mysql_select_db('mydb') or die('Could not select database'); $fields = array(); $promo = $_POST['Promcode']; #echo $fields; if (isset($_POST["submit"])){ // Performing SQL query $query = "SELECT * FROM promo WHERE (pcode = '$promo')" ; # echo $query; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); #echo $result; // Printing results in HTML while($row = mysql_fetch_assoc($result)) {$_POST['Result'] = $row['pfraction'];} $data= $_POST['Result']; #echo $_POST['Result']; // Free resultset mysql_free_result($result); // Closing connection mysql_close($link); } ?> I've got a form and successfully picked up the promotion code discount fraction 'pfraction'. How do I get this back into the source html form field 'Result'? I'm new to PHP so please bear this in mind. Any help appreciated. Link to comment https://forums.phpfreaks.com/topic/100910-passing-data-back-from-php-to-html-form/ Share on other sites More sharing options...
poleposters Posted April 13, 2008 Share Posted April 13, 2008 print "$promo"; ?? Link to comment https://forums.phpfreaks.com/topic/100910-passing-data-back-from-php-to-html-form/#findComment-516070 Share on other sites More sharing options...
JIMBOJAMBO99 Posted April 19, 2008 Author Share Posted April 19, 2008 print will just throw it out to the screen and since I am using a separate php to my html page it just comes out on a blank page ...not really what I was looking for ??? any other ideas would be appreciated. Link to comment https://forums.phpfreaks.com/topic/100910-passing-data-back-from-php-to-html-form/#findComment-521570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.