j3rmain3 Posted October 26, 2006 Share Posted October 26, 2006 Is it possible to add an IF statement in a table? My situation is, i want an image (Thumbnail) to appear depending on what filetype the file is. so i have radio buttons which return a value. I want to do an if statement so if for example 1 appears in the field, a word file icon will appear in the table.Here is the coding for the form[code]echo "<tr>";echo "<td><font face=Verdana size=-1><input type=radio value=1 name=filetype>  .doc<br><input type=radio value=2 name=filetype>  .pdf<br><input type=radio value=3 name=filetype>  .jpg<br><input type=radio value=4 name=filetype>  .bmp</td>";echo "</tr>"[/code]Here is the coding for the table[code]while ($row=mysql_fetch_row($result)){echo "<td>".$row[3]."</td>";echo "<td> (This is where i do not understand how to place the IF statement) </td> ";echo "<tr>";[/code]Do i just create a if statment elsewhere, save the answer in a variable and then place the variable in the cell.such as[code]if ($filetype == 1){echo "<img src=word.gif alt=word icon>";} else {echo "<img src=adobeReader.gif alt=pdf icon>";}[/code]But then how do i save this into a variable.I have no idea how to work around thisHelp ???ThanksJ3rmain3 Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 26, 2006 Share Posted October 26, 2006 [code]<?php//Get the file types.$x=array('doc','pdf','jpg','bmp');//Get the filetypes outforeach($x as $filetype){// put the file types with in a radio button.echo "<tr><td><font face=Verdana size=-1><input type=radio value=1 name=$filetype>  $filetype<br></tr>";// Pull the radio button file types out.foreach($filetype as $file){// query the database for the filetype $query="select * from files where filetype='$file'";$result="mysql_query($query);while($row=mysql_fetch_assoc($result)){// show the file types from the database.echo"<img src=" ".$record['filetype']." "></img>";} } }?>[/code] 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.