raysefo Posted June 6, 2013 Share Posted June 6, 2013 Hello, I have a table as follows; echo " <form method='get'> <center><img border='0' src='contest_winner.jpg' alt='test' width='452' height='384' class='center'></center> <table class='imagetable center'> <tr> <th>5/36</th> <th>6/40</th> </tr> <tr> <td> <select name='game1'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> <td> <select name='game2'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> </tr> <tr> <td> <input name='send1' type='submit' value='Check'> </td> <td> <input name='send2' type='submit' value='Check'> </td> </tr> <tr> <td> <-------- image here -----------> </td> <td> <-------- image here -----------> </td> </tr> </table> </form>"; I would like to add an image between TD's at the last TR of the table. How can I do it dynamically? Best Regards. Quote Link to comment Share on other sites More sharing options...
cpd Posted June 6, 2013 Share Posted June 6, 2013 (edited) What do you mean dynamically? You're being quite vague. If you want to display a different image each time you'll need to use PHP to choose the image and then echo it out... ... <td><img src="<?=$imageURL;?>" /></td> ... Edited June 6, 2013 by cpd Quote Link to comment Share on other sites More sharing options...
raysefo Posted June 6, 2013 Author Share Posted June 6, 2013 Hi, Here is my sample code, but I am getting Parse error: syntax error, unexpected '?' in C:\wamp\www\test.php on line 72 <?php function form(){ echo " <form method='get'> <center><img border='0' src='contest_winner.jpg' alt='test' width='452' height='384' class='center'></center> <table class='imagetable center'> <tr> <th>5/36</th> <th>6/40</th> </tr> <tr> <td> <select name='game1'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> <td> <select name='game2'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> </tr> <tr> <td> <input name='send1' type='submit' value='Check'> </td> <td> <input name='send2' type='submit' value='Check'> </td> </tr> <tr> <td> <img border='0' src="<?=$imageURL;?>" width='24' height='24' > </td> <td> <img border='0' src="<?=$imageURL;?>" width='24' height='24' > </td> </tr> </table> </form>"; Quote Link to comment Share on other sites More sharing options...
raysefo Posted June 6, 2013 Author Share Posted June 6, 2013 Now it is OK but no images, probably path problem? <?php function form($imageURL){ echo " <form method='get'> <center><img border='0' src='contest_winner.jpg' alt='test' width='452' height='384' class='center'></center> <table class='imagetable center'> <tr> <th>5/36</th> <th>6/40</th> </tr> <tr> <td> <select name='game1'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> <td> <select name='game2'> <option value='1'>111111</option> <option value='2'>222222</option> </select> </td> </tr> <tr> <td> <input name='send1' type='submit' value='Check'> </td> <td> <input name='send2' type='submit' value='Check'> </td> </tr> <tr> <td> <img border='0' src='<?=$imageURL;?>' width='24' height='24' > </td> <td> <img border='0' src='<?=$imageURL;?>' width='24' height='24' > </td> </tr> </table> </form>"; } $imageURL = "Circle-apply-icon.png"; form($imageURL); Quote Link to comment Share on other sites More sharing options...
cpd Posted June 6, 2013 Share Posted June 6, 2013 (edited) Why have you wrapped a very specific form in a function called "form"? Just write the HTML as you would normally, above that open PHP tags and set the image URL. E.g. <?php // Do some stuff // Set the image $imageURL = ... ?> <html> <head> </head> <body> <form> <img ... /> </form> </body> </html> I assume you're not going to actually set the image URL like that? And yes its probably a path issue. Assuming you've uploaded the image properly, use the URL you would to view the image in a browser. Edited June 6, 2013 by cpd Quote Link to comment Share on other sites More sharing options...
raysefo Posted June 6, 2013 Author Share Posted June 6, 2013 Hi, I checked over the browser, the image is at http://127.0.0.1:8080/Circle-apply-icon.png Quote Link to comment Share on other sites More sharing options...
cpd Posted June 6, 2013 Share Posted June 6, 2013 That's your localhost, we cant see that. Are you testing everything at your localhost? Quote Link to comment Share on other sites More sharing options...
raysefo Posted June 6, 2013 Author Share Posted June 6, 2013 yep, right now I am doing it on localhost and the image is under C:\wamp\www with the php file. Quote Link to comment Share on other sites More sharing options...
raysefo Posted June 6, 2013 Author Share Posted June 6, 2013 grrrr it was just semicolon!! Quote Link to comment Share on other sites More sharing options...
l0gic Posted June 6, 2013 Share Posted June 6, 2013 grrrr it was just semicolon!! Is that all it was, really? Quote Link to comment Share on other sites More sharing options...
DavidAM Posted June 6, 2013 Share Posted June 6, 2013 I don't see how a semicolon change would fix it ... <?php function form($imageURL){ echo " <form method='get'> <center><img border='0' src='contest_winner.jpg' alt='test' width='452' height='384' class='center'></center> <table class='imagetable center'> <tr> <th>5/36</th> <th>6/40</th> </tr> ... <tr> <td> <img border='0' src='<?=$imageURL;?>' width='24' height='24' > </td> <td> <img border='0' src='<?=$imageURL;?>' width='24' height='24' > </td> </tr> </table> </form>"; } Lines 14 & 17: You are ALREADY in PHP, you can't jump back into PHP, remove the <?= and ;?> characters and you should be OK since you are just trying to imbed a variable into a string you are echoing. Quote Link to comment 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.