Jump to content

Post without a Submit button


markvaughn2006

Recommended Posts

I'm making a custom forum, the below code displays all of a user's favorite boards with a submit button next to it to take them to that board. How could i get rid of the submit button and make the board title be clickable and post the value $rowfav['board']?? thanks in advance!!

 

<?php

$resultfav = mysql_query("SELECT * FROM favorites WHERE owner='$username'")

  or die(mysql_error());

while ($rowfav = mysql_fetch_array($resultfav)) {

echo '<form target="_self" method="post" action="board.php"><input type="submit" value="Go" />'." - ".ShortenText($rowfav['board']).'<input type="hidden" name="equip" value="'.$rowfav['item_name'].'" /></form>';

}

 

So ideally, it would display all the board titles and when you click the title, it will take them to board.php which will display info about the board and will know what board it is through posting the board title

 

?>

Link to comment
https://forums.phpfreaks.com/topic/189887-post-without-a-submit-button/
Share on other sites

I think you are trying to do this?

 

<?php
$resultfav = mysql_query("SELECT * 
                          FROM favorites 
                          WHERE owner='$username'
                          ");

$result = mysql_query($resultfav) or die(mysql_error());

     echo "<a href='{$result['item_name']}' >{$result['board']}</a>";

  
?>

whoops...

here is the code

<?php

$resultfav = mysql_query("SELECT * FROM favorites WHERE owner='$username'")

  or die(mysql_error());

while ($rowfav = mysql_fetch_array($resultfav)) {

echo '<form target="_self" method="post" action="board.php"><input type="submit" value="Go" />'." - ".ShortenText($rowfav['board']).'<input type="hidden" name="boardtitle" value="'.$rowfav['board'].'" /></form>';

}

 

?>

What I'm trying to do is make it like if you click on my name on phpfreaks it will take you to my profile, so.. you click on the board title on my site and it will take you to that board, but there is no url to take you directly there so it will have to go to board.php and use the posted board title to select * from that board and display it.

you can use $_GET variables for that. you can simply make a link like so

<a href="where.php?id=5&name=mike">Clicky</a>

 

in where.php you can access those values in the $_GET array. for example, the value of 5 (sent in the variable "id") can be accessed via $_GEt['id']

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.