David83
David83

Reputation: 45

passing data using php and html

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

Upvotes: 1

Views: 97

Answers (2)

user863317
user863317

Reputation:

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

Upvotes: 0

Anonymous
Anonymous

Reputation: 3689

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>
';

Upvotes: 7

Related Questions