Jump to content

php variable in a button


what

Recommended Posts

I created a varialble to hold a path to a file folder but I'm having problems integrating it into my button. Can someone please advise?

 

Below I want to replace '/admin/files/' with $files but my attempts just generate errors.

 

<input type="button" name="View" value="View" OnClick="location.href=\'/admin/files/'.$row["file"].'\'" class="button_60">

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/153685-php-variable-in-a-button/
Share on other sites

Hi thanks..

I think something is still missing? I was getting the following errors:

 

Warning: Unexpected character in input: '\' (ASCII=92) state=1

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'

 

I thought I saw where it was missing a tick from your example (after ["file"] ?), but even though I added it and then I was able to see my page without errors, the button did not work when I clicked on it.

	while ($row = mysql_fetch_array($result)) { 
	echo '<tr><td width="98%">'.$row["title"].'</td>
<td width="1%"><input type="button" name="View" value="View" OnClick="location.href=\'/admin/files/'.$row["file"].'\'" class="button_60"></td>
<td width="1%"><input type="button" name="Download" value="Download" OnClick="location.href=\'file.php?file='.$row["id"].'\'" class="button_60"></td>
</tr>';	
}
@mysql_close();

try...

<input type="button" name="View" value="View" OnClick="location.href=\'.$files.$row["file"].'\'" class="button_60">

 

Regards, ACE

Should read:

<input type="button" name="View" value="View" OnClick="location.href=\''.$files.$row["file"].'\'" class="button_60">

 

Using a syntax highlighter would help:

echo '<input type="button" name="View" value="View" OnClick="location.href=\''.$files.$row["file"].'\'" class="button_60">';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.