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

Link to comment
Share on other sites

	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();

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.