girlzz Posted July 28, 2008 Share Posted July 28, 2008 if there any easiest way to make dynamic form just using php coding??? i had a problem which is if i insert matric_no then if the matric_no that i had insert exist in the database,the name of the student that hold the matric_no automatically appear... i want to do with php and ajax but i not familiar with ajax.. can some one help me with this problem...?? i prefer php coding... thanks... Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/ Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 You need to describe your actual problem sorry. Your post doesn't make allot of sense from here. Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601698 Share on other sites More sharing options...
girlzz Posted July 28, 2008 Author Share Posted July 28, 2008 sorry... i had 2 textfield which contain id and name... my problem is.. when i insert id, i want textfield name automatic detect the id that i had inserted... Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601720 Share on other sites More sharing options...
papaface Posted July 28, 2008 Share Posted July 28, 2008 http://uk2.php.net/manual/en/function.mysql-insert-id.php Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601729 Share on other sites More sharing options...
girlzz Posted July 28, 2008 Author Share Posted July 28, 2008 sorry..what i means is for example.. Â id :______ (this id will be key in by user) name:________ (when user key in id, then automatic appear the name)... Â i found lot of ajax script but i'm not familiar with ajax eventhough i had read it several time, so i prefer if my problem can be solve by php languange.... Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601751 Share on other sites More sharing options...
samshel Posted July 28, 2008 Share Posted July 28, 2008 getname.php <?php //replce DB credentials and name here $db = mysql_connect("db_server", "db_user_name", "db_password"); mysql_select_db("db_name"); if($_POST['submit']) { Â $sql = "select `name` from student where id = '".mysql_escape_string($_POST['id'])."'"; Â $res = mysql_query($sql); Â if(mysql_num_rows($res)>0) { Â Â $row = mysql_fetch_array($res); Â Â $strName = $row['name']; Â } else { Â Â $strName = "No Student with this id.."; Â } } ?> <form method="POST" action="getname.php"> <input type="text" name="id" value="<?php echo $_POST['id'] ?>" /><br/> <input type="text" name="student" value="<?php echo $strName; ?>" /> <input type="submit" name="submit" value="Submit" /> </form> Â something like this ?? Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601763 Share on other sites More sharing options...
girlzz Posted July 28, 2008 Author Share Posted July 28, 2008 yup but your script look like if you enter the submit button just then the name will appear,right?? correct me if i'm wrong Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601767 Share on other sites More sharing options...
samshel Posted July 28, 2008 Share Posted July 28, 2008 correct...page will refresh..if you dont want that to happen, you need to use AJAX Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601770 Share on other sites More sharing options...
girlzz Posted July 28, 2008 Author Share Posted July 28, 2008 still need to use ajax..?? thanks for your information.. Quote Link to comment https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601775 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.