Page 1 of 1

Help in php code logic

Posted: Tue Feb 12, 2008 7:17 pm
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. :(

Re: Help in php code logic

Posted: Tue Feb 12, 2008 7:19 pm
by Benjamin

Re: Help in php code logic

Posted: Tue Feb 12, 2008 7:27 pm
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

Re: Help in php code logic

Posted: Tue Feb 12, 2008 7:33 pm
by Benjamin
Can you clarify your question?

Re: Help in php code logic

Posted: Tue Feb 12, 2008 7:45 pm
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?

Re: Help in php code logic

Posted: Tue Feb 12, 2008 7:52 pm
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.

Re: Help in php code logic

Posted: Tue Feb 12, 2008 7:55 pm
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.

Re: Help in php code logic

Posted: Tue Feb 12, 2008 8:00 pm
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]

Re: Help in php code logic

Posted: Tue Feb 12, 2008 8:24 pm
by Benjamin
2nd result on google when I searched for "ajax examples" http://www.ajaxdaddy.com/

Re: Help in php code logic

Posted: Tue Feb 12, 2008 9:11 pm
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/