Jump to content

[SOLVED] dynamic php


girlzz

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/
Share on other sites

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....

Link to comment
https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601751
Share on other sites

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 ??

Link to comment
https://forums.phpfreaks.com/topic/116999-solved-dynamic-php/#findComment-601763
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.