Help in php code logic

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
oregonsv
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:58 pm

Help in php code logic

Post by oregonsv »

Hello i'm new in web programming (php), and i'm doing a form thats take the following information:

Product id:


Qty:

but what i need is to make a query to the database when the user type(input data into) the field Product ID. to know if the Product Id exist or not, If exist then show the Description of the product .
this query i need to execut it before input the data into the Qty field.

example:
product id:
if $product_id = product_id
echo "product ID Description"
endIF
Qty :

Thank u for your help. :(
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Help in php code logic

Post by Benjamin »

oregonsv
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:58 pm

Re: Help in php code logic

Post by oregonsv »

Thank u, but my question is, may i put the condition after the field Product_id?
and not after the submit button?

astions wrote:Welcome to phpDN. Have a look at http://www.php.net/manual/en/language.c ... ctures.php
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Help in php code logic

Post by Benjamin »

Can you clarify your question?
oregonsv
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:58 pm

Re: Help in php code logic

Post by oregonsv »

Ok, what i want to do, is to verify in the database, if exist the Product_id that the user is typing, this verification i want to do it after the user type the data into the field 'codigo'
if the data exist in the database i going to show the Descripcion of the codigo.
but when i try to it, it does not work.

example
<td width="7%"><div align="left">Codigo</div></td>
<td width="12%"><div align="left">
<input name="codigo" type="text" size="15" />
</div></td>
<?php
if ($v_codigo =$codigos):
echo "codigo found in to the database";
else:
echo "it does not exist";
exit;
endif;
?>
<td width="2%">&nbsp;</td>
<td colspan="3"><div align="left">
<input name="descrip" type="text" size="70" id="descrip" value="<?php echo $lineactualiza['codigo']?>" />
</div></td>
<td width="2%">&nbsp;</td>
</tr>
<tr>
<th scope="row">&nbsp;</th>
<td colspan="2"><div align="left">Existencia Actual </div></td>
<td>&nbsp;</td>
<td width="18%"><div align="left">
<input type="text" name="existencia" id="existencia" value="<?php echo $lineactualiza['existencia']?>" />


astions wrote:Can you clarify your question?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Help in php code logic

Post by Benjamin »

PHP is a server side language. It does not get executed in the browser. Therefore you will either need to have the user press the submit button and process the request on the server, or you can integrate AJAX into your webpage. With AJAX you can use event handlers to automatically send a request to the server and display it on the existing webpage. A quick search for "AJAX Tutorials" should bring up some good places to start.
oregonsv
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:58 pm

Re: Help in php code logic

Post by oregonsv »

thank u so much, i'm going to look for AJAX Tutorials...

thanks.
astions wrote:PHP is a server side language. It does not get executed in the browser. Therefore you will either need to have the user press the submit button and process the request on the server, or you can integrate AJAX into your webpage. With AJAX you can use event handlers to automatically send a request to the server and display it on the existing webpage. A quick search for "AJAX Tutorials" should bring up some good places to start.
oregonsv
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:58 pm

Re: Help in php code logic

Post by oregonsv »

Do you have an example how to do it?

astions wrote:PHP is a server side language. It does not get executed in the browser. Therefore you will either need to have the user press the submit button and process the request on the server, or you can integrate AJAX into your webpage. With AJAX you can use event handlers to automatically send a request to the server and display it on the existing webpage. A quick search for "AJAX Tutorials" should bring up some good places to start.
[/quote]
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Help in php code logic

Post by Benjamin »

2nd result on google when I searched for "ajax examples" http://www.ajaxdaddy.com/
oregonsv
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:58 pm

Re: Help in php code logic

Post by oregonsv »

Thank u so much, right now i'm checking the AJAX Tutorial and its very help full,
i really apreciate you.
Sure i going to check the search you did. thank u.

astions wrote:2nd result on google when I searched for "ajax examples" http://www.ajaxdaddy.com/
Post Reply