mobiius Posted April 13, 2011 Share Posted April 13, 2011 Hello, I'm trying to create a form with multiple graphical buttons from a php DB. (The DB works fine by the way ) The below code works, but creates a standard button. (It posts $MyCars['CarID'] correctly and showmods.php displays as intended. I know that the below code is formatted for a graphical button with the type changed to submit rather than image, this is just an example of the code working as expected.) print( " <form enctype='multipart/form-data' action='showmods.php' method='post'>\n" ); $GetCars = mysql_query( "SELECT * FROM Car" ); while ( $MyCars = mysql_fetch_array( $GetCars, MYSQL_ASSOC ) ) //Iterate through all Cars.. { print( " <input type='submit' src='".$MyCars['CarHeaderImage']."' name='SelectCar' value='".$MyCars['CarID']."'><br>\n" ); } print( " </form>\n" ); What I want to do, is change the standard button for an image, (which is populated from a DB), which when clicked, posts a variable to showmods.php. The below code does not function as expected: print( " <form enctype='multipart/form-data' action='showmods.php' method='post'>\n" ); $GetCars = mysql_query( "SELECT * FROM Car" ); while ( $MyCars = mysql_fetch_array( $GetCars, MYSQL_ASSOC ) ) //Iterate through all Cars.. { print( " <input type='image' src='".$MyCars['CarHeaderImage']."' name='SelectCar' value='".$MyCars['CarID']."'><br>\n" ); } print( " </form>\n" ); The images work correctly, when clicked they open the showmods.php file correctly, but do not pass the intended variable. The only $_POST data I get is SelectCar_X and SelectCar_Y, and not the actual data which should be held in the value field. (Which is what I want) Can anyone think of a way to get the graphical button to actually post the contents of it's 'value' field and not just the X/Y coords of the mouse click? Google searching has not provided any working answers. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/233612-creating-a-form-with-multiple-graphical-buttons/ Share on other sites More sharing options...
mobiius Posted April 14, 2011 Author Share Posted April 14, 2011 lol, thanks for all the help, but I solved it myself by removing the form completely, and passing the required variable through the URL as in the example. $GetCars = mysql_query( "SELECT * FROM Car" ); while ( $MyCars = mysql_fetch_array( $GetCars, MYSQL_ASSOC ) ) //Iterate through all Cars.. { print( " <a href='showmods.php?SelectCar=".$MyCars['CarID']."'><img src='".$MyCars['CarHeaderImage']."' border=0></a><br>\n" ); } Quote Link to comment https://forums.phpfreaks.com/topic/233612-creating-a-form-with-multiple-graphical-buttons/#findComment-1201628 Share on other sites More sharing options...
cssfreakie Posted April 14, 2011 Share Posted April 14, 2011 I hope you do realize, that the code you posted is serverside, and html is a clientside ,the same is for css. Quote Link to comment https://forums.phpfreaks.com/topic/233612-creating-a-form-with-multiple-graphical-buttons/#findComment-1201661 Share on other sites More sharing options...
mobiius Posted April 14, 2011 Author Share Posted April 14, 2011 Which code? The before or the after? The 'before' code works when set to buttons and not images, and the 'after' code just works? Quote Link to comment https://forums.phpfreaks.com/topic/233612-creating-a-form-with-multiple-graphical-buttons/#findComment-1201665 Share on other sites More sharing options...
cssfreakie Posted April 14, 2011 Share Posted April 14, 2011 never mind, they are both serverside scripts. this is the html forum. html is a markup language for the clientside Quote Link to comment https://forums.phpfreaks.com/topic/233612-creating-a-form-with-multiple-graphical-buttons/#findComment-1201728 Share on other sites More sharing options...
mobiius Posted April 15, 2011 Author Share Posted April 15, 2011 I know. I posted here because the code I posted was for an html form. The serverside bit was irrelevant as it was how I was using the submit button in the form. Replacing the form with images within links and using a url parameter worked. Quote Link to comment https://forums.phpfreaks.com/topic/233612-creating-a-form-with-multiple-graphical-buttons/#findComment-1202067 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.