Server Side Scripts

Three is a magic number. We have the three client side technologies HTML, CSS and Javascript. And er there are three letters in the acronym PHP and a lot more than three server side script to choose from but this section will look at the wonderful world of PHP.


  1. Suresh kamal
    Aug 21, 2012 @ 08:35:22

    Could you please help me . I have a doubt in php MySQL. The doubt is how to insert a fixed variable in front of an auto increment field of a table . like Ref001,Ref002,Ref003 etc...

    thank you
    Suresh kamal


    • admin
      Aug 21, 2012 @ 09:33:13

      The autoIncrement field in the mySQL would need to stay as a number - it can't be a string. On the output you could concatenate the 'ref' prefix but you would need to do some calculations to add the double or single zeros as required. You do this with conditional logic seeing if the number was less than 10, greater that 99.


      if($myAutoIncrement < 10){
      $displayID = "ref00."$myAutoIncrement;
      if($myAutoIncrement >= 10 && $myAutoIncrement <= 99){
      $displayID = "ref0."$myAutoIncrement;
      if($myAutoIncrement > 99){
      $displayID = "ref."$myAutoIncrement;

      Hope that helps.


Leave a Reply