Page 1 of 1

calling a php function within a html form

Posted: Mon Aug 07, 2006 4:53 am
by ramya
hello there
I am using PHP to query a database whose contents are stored in MySQL.I want to create an query interface wherein i intially display some fields using html forms.If the user wants more fileds to search they can include it by clicking on an add button.And finally there will be a submit button that will take the query and show the results.I have included the the things for displaying the fields in a php function.How do i call this function to the form.All ,the php function,html form are in the same file itself.Or is there is anyother way to do this functionality.Kindly lt me know asap.I am a newbee.....

Thanks in advance
RAmya

Posted: Mon Aug 07, 2006 6:29 am
by shiranwas
hi ,

i hope the following code will help u
<body>

Code: Select all

<?php
include ("Conn.php");

	function fromName(){
		$str="Select fromName from tblFrom";
		$query=mysql_query($str) or die("Can not query the table.");
		while ($row=mysql_fetch_assoc($query)){
			$arrfromname[] = $row;
		}    
   		foreach ($arrfromname as $f)  echo "<OPTION>{$f['fromName']}</OPTION>\n"; 
   }
   
   
   
 ?>
<select name="cboFrom" style="color: #000; background: #EFEFEF; border: 2px solid #781351; width:200px"><? fromName(); ?></select>

shiran