I have a form and it has field and it`s name is application no. these is a auto increment number. i create a simple code for generate this number. now it should be show 1,2,3,4.....etc...but now i want to attach normal text to before this number...like "LN/SS- my unique id" how can i developed it! i post my code.. someone help me to solve this error. $insert_id is my variable name and i already echo in my text field(application_no)
<?php
$query2 = "SELECT * FROM tbl_loan_application ORDER BY application_id DESC LIMIT 1";
$result2 = mysql_query($query2,$conn);
$row = mysql_fetch_array($result2);
$last_id = $row['application_id'];
//$insert_id = $last_id + 1;
$insert_id = ++$last_id;
?>
I can't quite tell what you're asking for here, but I assume you mean concatenation. In that case, either of the following would work:
echo "<text>" . $var;
or
echo "<text>{$var}";
Replace
<text>
with the text you want added.
Something like this:
$var = "test";
echo "Value: {$var}";
or:
$var = "test";
echo "Value: " . $var;
would both return:
Value: test
Edit because I saw your comment: Using the escape in a double-quoted string creates a new line. Use that if you want your data to be printed across multiple lines. I.E:
echo "<text>{$var}
";
echo "<text>{$var}
";
would return
(text)(value of $var)
(text((value of $var)
Note the new line that is created.
You should use parenthesis $insert_id = "LN/SS".(++$last_id);
<?php
$query2 = "SELECT * FROM tbl_loan_application ORDER BY application_id DESC LIMIT 1";
$result2 = mysql_query($query2,$conn);
$row = mysql_fetch_array($result2);
$last_id = $row['application_id'];
//$insert_id = $last_id + 1;
$insert_id = "LN/SS".(++$last_id);
?>