calling a php function within a html form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ramya
Forum Newbie
Posts: 1
Joined: Mon Aug 07, 2006 4:27 am

calling a php function within a html form

Post 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
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

Post 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
Post Reply