Jump to content


Photo

PHP adding value help


  • Please log in to reply
3 replies to this topic

#1 hustler

hustler
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 27 October 2006 - 11:24 PM

hi,
i have a form in admin panel from where we add quote for username, at the moment it gives an option to select the username and then enter the details for him.
But i want an extra field with select box wher i can enter the username directly to enter his records.

here is the code
<?php
if(!empty($req_form_action)){
    if($req_form_action=="addQuickQuote"){
        //check for valid reference number
        $strQuery="SELECT count(*) FROM master_quotes WHERE reference_number LIKE '".$req_ref_num."'";
        if($dbConn->getValue($dbConn->executeQuery($strQuery),0)>0){                
            //insert
            $strSQL="INSERT INTO quick_quotes VALUES (    NULL,
                                                        ".$req_member_id.",
                                                        '".$req_contact_name."',
                                                        '".$req_group_id."',
                                                        '".$req_ref_num."')";

            //echo $strSQL;                                    
            if($dbConn->executeQuery($strSQL))
                $log="Quote Added<br>";            
            else
                $log=mysql_error();
        }
        else{
            $log="The reference number: <b>".$req_ref_num."</b> does not exists in master database.";
        }        

    }        
}
if(!empty($log)) echo "<font color=red>".$log."</font><br>";
//list    groups
$strSQL="SELECT * FROM groups ORDER By groupname";
$res=$dbConn->executeQuery($strSQL);
$groups=array();
while($group=$dbConn->getRecords($res)){
    $groups[]=$group;
}        

if(count($groups)==0)
    echo "No groups were found. <a href=admin.php?c=addGroup>Click here</a> to create group first.<br>";
else{            
?>
<form method=post>
    <input type=hidden name="form_action" value="addQuickQuote">
    
    <table cellspacing=0 cellpadding=0 width=90% border=1>
    <?php
    
        //list    members    
        require_once("includes/class.member.php");
        $objMember=new Member();        
        $arrMemberList=$objMember->getMembers("on");
        if(count($arrMemberList)==0)
            echo "No activated members were found.<br>";    
        else{
    
     ?>
        <tr>
            <td>Select Member</td>
            <td>
            
                <select name=member_id class=fieldbox>
<?php
            while($member=array_pop($arrMemberList)){
                echo "<option value='".$member["id"]."'>".$member["username"]."\n";    
            }
?>                    
                </select>
            </td>            
        </tr>
<?php
        }    
?>    
        <tr>
            <td>Contact name</td>
            <td>
                <INPUT size=19 name="contact_name" type=text class=fieldbox>
            </td>
        </tr>    
        <tr>
            <td>Group</td>
            <td>
                <select name=group_id class=fieldbox>
<?php
while($group=array_pop($groups)){
    echo "<option value='".$group["id"]."'>".$group["groupname"]."\n";
}
?>                    
                </select>
            </td>            
        </tr>    
        <tr>
            <td>Reference Name</td>
            <td>
                <INPUT size=19 name="ref_num" type=text class=fieldbox>
            </td>            
        </tr>    
        <tr>            
            <td colspan=2 align=center><input type=submit value="Add Quick Quote" class=fieldbox></td>
        </tr>        
    </table>
</form>        
<?php    
}
?> 

you experianced people can figure it out very easily but being having very little php knowledge i cant figure it out.

what i want is just an option with the select box where i can enter the username directly rather than selecting it.

This is current what it is

Select member :_____ (this is drop down, which shows all members)
Contact name: ____-
Group:_________
Reference number:___________-

I want it like this
Select member :_____ (this is drop down) or Enter Member name______
Contact name: ____
Group:_________
Reference number:___________

all help appreciated!

#2 hustler

hustler
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 27 October 2006 - 11:47 PM

ok can anyone guide me for

Just replacing the
<select> box which shows usernames to select 
to
Input box where i can enter the username directly

Thanx


#3 hustler

hustler
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 28 October 2006 - 07:10 AM

that means this is a part which shows select box with all usernames

<?php
    
        //list    members    
        require_once("includes/class.member.php");
        $objMember=new Member();        
        $arrMemberList=$objMember->getMembers("on");
        if(count($arrMemberList)==0)
            echo "No activated members were found.<br>";    
        else{
    
     ?>
        <tr>
            <td>Select Member</td>
            <td>
            
                <select name=member_id class=fieldbox>
<?php
            while($member=array_pop($arrMemberList)){
                echo "<option value='".$member["id"]."'>".$member["username"]."\n";    
            }
?>                    
                </select>

but i want a simple input box where i can enter username myself instead of selecting.

Thanx


#4 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 28 October 2006 - 12:56 PM

try
<form method=post>
    <input type=hidden name="form_action" value="addQuickQuote">
    
    <table cellspacing=0 cellpadding=0 width=90% border=1>
    <?php
    
        //list    members    
        require_once("includes/class.member.php");
        $objMember=new Member();        
        $arrMemberList=$objMember->getMembers("on");
        if(count($arrMemberList)==0)
            echo "No activated members were found.<br>";    
        else{
    
     ?>
        <tr>
            <td>Select Member</td>
            <td>
            
                <select name=member_id class=fieldbox>
<?php
            while($member=array_pop($arrMemberList)){
                echo "<option value='".$member["id"]."'>".$member["username"]."\n";    
            }
?>                    
                </select>
            </td>  
            <td>
            	or Enter Member name:<input type="text" name="UserName" />
            </td>          
        </tr>
<?php
        }    
?>    
        <tr>
            <td>Contact name</td>
            <td colspan="2">
                <INPUT size=19 name="contact_name" type=text class=fieldbox>
            </td>
        </tr>    
        <tr>
            <td>Group</td>
            <td colspan="2">
                <select name=group_id class=fieldbox>
<?php
while($group=array_pop($groups)){
    echo "<option value='".$group["id"]."'>".$group["groupname"]."\n";
}
?>                    
                </select>
            </td>            
        </tr>    
        <tr>
            <td>Reference Name</td>
            <td colspan="2">
                <INPUT size=19 name="ref_num" type=text class=fieldbox>
            </td>            
        </tr>    
        <tr>            
            <td colspan="3" align=center><input type=submit value="Add Quick Quote" class=fieldbox></td>
        </tr>        
    </table>
</form>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users