1

I am trying to pass a certain data which I found in my table using the search to another php page . here is my code

echo "
1<form action="adm_edit.php?product_code=$record[0]" method="POST">
2<input type=submit value=Edit>
3</form>
4<form action="adm_edit.php?product_code=$record[0]" method="POST">
5<input type=submit value=Delete>
6</form>
";

my search function is working fine and record[0] is contain desired data but I am getting this error when I run this code:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in search.php on line 1

I put numbers on lines in above code for ease of reading So could you please help me? Thank you

2 Answers 2

7

Take care when using quotes from html elements in echos, also when using variables! When using ' instead of ", you also have to put quotes in front of the variable and that way you stop echoing a string and can start with echoing a variable. You need to concatenate the var and the string with a . !

This will work :

echo '
<form action="adm_edit.php?product_code='.$record[0].'" method="POST">
<input type=submit value=Edit>
</form>
<form action="adm_edit.php?product_code='.$record[0].'" method="POST">
<input type=submit value=Delete>
</form>
';
Sign up to request clarification or add additional context in comments.

Comments

0
<form action="adm_edit.php?product_code=<?php echo $record[0]; ?>" method="POST">
<input type=submit value=Edit>
</form>
<form action="adm_edit.php?product_code=<?php echo $record[0]; ?>" method="POST">
<input type=submit value=Delete>
</form>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.