tags:

views:

732

answers:

3
echo "<a href=User_list.php?id=$row[1]&sec=$row[5]&subj=$row[6]&type=viewrec2&Year=$row[12]&faci=$row[9]>LIST</a></td>";

how can i convert this code into a button? and make the button as an image button that i made.

+1  A: 

Try

<input type="button" onclick="window.location = 'User_list.php?id=$row[1]&sec=$row[5]&subj=$row[6]&type=viewrec2&Year=$row[12]&faci=$row[9]'" class="myButton" />

You can use CSS to style your button's background image accordingly

nduplessis
I first thought about this, but it won't work when JavaScript is disabled.
Hosam Aly
+1  A: 

To add an image to a HTML form button, try this:

<button name="somebutton" type="button" value="somevalue" onclick="alert('Hello World!');">
  <img src="someimage.gif" alt="someimage">
</button>

From: SelfHTML (German)

furtelwart
+3  A: 

Try this:

echo "<form action=\"User_list.php?id=$row[1]&sec=$row[5]&subj=$row[6]&type=viewrec2&Year=$row[12]&faci=$row[9]\">";
echo "  <button type=\"submit\" value=\"LIST\">";
echo "    <img src=\"image.gif\" alt=\"LIST\"/>";
echo "  </button>";
echo "</form>";

(Thanks to @guerda for his answer on how to include the image.)

You'll have to escape the '&' characters, but I don't know how you do it in PHP.

Note that this can have a side effect if you have other forms in the same page.

Hosam Aly
You're welcome. :) Good example for the wiki style answering: First person gives an idea, second person uses it and it's the perfect answer :)
furtelwart
Stewart