Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109

    Unanswered: A very minor problem but doesn't seen

    i have a very serious problem with this i make a form
    and i have a table called std_info
    there is 3 records with the stnd_id column name
    11
    12
    13

    these are the records
    PHP Code:
    $quer1="select max(stnd_code) from std_info";

    $quexe=mysql_query($quer1);

    while(
    $row=mysql_fetch_assoc($quexe)){
                                 
    $plus=$row['stnd_code'];

    echo 
    $plus+1;

    i need that it increase 1 after max id but it returns only 1

    nothing increament and no max id selection please help that

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    $quer1="SELECT MAX(stnd_code) AS max_code FROM std_info";

    $plus=$row['max_code'];
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109
    Thanks and another one problem is that whenever i insert phone number here it doesn't insert phone contact to here

    the structures are as follow
    PHP Code:
    $student_code=$_POST['std_code'];
    $family_code=$_POST['std_fcode'];
    $student_name=$_POST['std_name'];
    $student_fname=$_POST['std_fname'];
    $student_fnic=$_POST['std_fnic'];
    $student_mname=$_POST['std_mname'];
    $student_mnic=$_POST['std_mnic'];
    $student_address=$_POST['std_add'];
    $student_dobd=$_POST['std_dobd'];
    $student_dobm=$_POST['std_dobm'];
    $student_doby=$_POST['std_doby'];
    $student_gender=$_POST['std_gen'];
    $student_phone=$_POST['std_ph'];
    $student_mobile=$_POST['std_mob'];
    $student_jdate=$_POST['std_jdate'];
    $student_fees=$_POST['std_fee'];
    $student_class=$_POST['std_class'];
    $student_dob=$student_doby."-".$student_dobm."-".$student_dobd;
    $sql="insert into std_info values('$student_code','$family_code','$student_name','$student_fname','$student_fnic','$student_mname','$student_mnic','$student_address','$student_dob','$student_gender','$student_phone','$student_mobile','$student_jdate','$student_fees','$student_class')";
    $query=mysql_query($sql);
    if(!
    $query){
        echo 
    "Query doesn't Executed Re-register Student";
    }
    else
    {
        echo 
    "Student Register Successfully ";

    it register student succesfully but doesn't insert phone number just only insert 0

    tell me what problem is that and the table structure is as follow

    PHP Code:
    CREATE TABLE std_info(stnd_code intstnd_fcode intstnd_name varchar50 NOT NULL stnd_fname varchar50 NOT NULL stnd_fnic varchar25 ) , stnd_mname varchar50 NOT NULL stnd_mnic varchar25 ) , stnd_add varchar100 NOT NULL stnd_dob datestnd_gender varcharNOT NULL stnd_ph intstnd_mob intstnd_jdate datestnd_fees int stnd_class varchar(10NOT NULL 

  4. #4
    Join Date
    Jun 2010
    Posts
    6
    Querys seem correctly.
    Check whether you wrote wrong name of the field in the array POST and whether $student_phone contain the value wich is posted in phone field in form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •