jasonhardwick Posted May 14, 2008 Share Posted May 14, 2008 ok here is my question i have a page that displays images that a user has uploaded what i need to do is read the filename and if it is a music file i need to load the music player (code below) i think this can be done with an if else statment but it is getting too complex for me to completely understand. any help would be awsome. view post file code: <?php session_start(); //$_SESSION['username'] = "Joe Shmo"; if(!isset($_SESSION['username'])) { header("location:index1.php"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>My Creative Process</title> <style type="text/css"> <!-- .style1 {color: #666666} --> </style> <link href="/css/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 { color: #f73602; font-weight: bold; } .style3 { color: #FFFFFF } .style4 {color: #F15A25} --> </style> </head> <body> <table width="972" border="0" cellspacing="0" cellpadding="5"> <tr> <td><div align="right">Logged in as: <? echo $_SESSION['username'];?></div></td> </tr> </table> <table width="972" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#F73602" id="frame"> <tr bordercolor="#F15A25"> <td colspan="4"><div align="center"> <p><img src="/images/header.jpg" width="942" height="84" /></p> <table width="902" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="728"><p><span class="style1"><a href="/index.php">home</a> | <a href="/main_forum.php">review</a> | <a href="/create_topic.php">post</a> | <a href="/mindgames.php">mindgames</a> | <a href="/archive.php">archive</a> | <a href="/brainstorm.php">brainstorm</a> | <a href="/my_account.php">my account</a> | <a href="/suggestion_box.php">suggestion box</a></span></p> </td> <td colspan="-1"><div align="right"> <? //echo "You've been logged in since" . $_SESSION['time'] . "<br>"; echo '<a href="logout.php">Click here to logout</a>'; //echo "<br>"; // echo '<a href="' .$_SERVER['PHP_SELF']. '?action=change"> Change Password</a>'; ?> <? // $action=$_GET['action']; $action="sdfasdfasdfa"; if($action=="change"){ changepw($_SESSION['username']); update($newpass,$_SESSION['username']); }else{ } ?> </div></td> </tr> </table> <table width="902" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="728" valign="top"><p> <?php include "config.php"; $tbl_name="forum_question"; $id=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> </p> <table width="10" border="2" align="center" cellpadding="5" cellspacing="0" bordercolor="#E99979"> <tr> <td><?php $img_path = "file/".$rows ['file']; $image_t = getimagesize($img_path); //edited this $wh = imageResize($image_t[0], $image_t[1], 600); function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } //and this echo "<img src=\"$img_path\" $wh />"; ?> </td> </tr> </table> <p> <? $tbl_name2="forum_answer"; $type= $rows['file_type']; ?> </p> <table width="95%" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td width="10%" rowspan="3" valign="top" bgcolor="#E99979"><b><? echo $rows['username']; ?></b></td> <td height="20" valign="top" bgcolor="#E99979"><strong><? echo $rows['topic']; ?></strong></td> <td valign="top" bgcolor="#E99979"><div align="right"><b> <?php $c_avg =("SELECT AVG(a_concept) FROM $tbl_name2 WHERE question_id='$id'"); $c_avg1 = mysql_query($c_avg) or die ("Error in query: $query1. ".mysql_error()); $query_data_c=mysql_fetch_row($c_avg1); $c_avgrows = $query_data_c[0]; if ($c_avgrows >= "6") {echo "Execution Grade: A+";} if ($c_avgrows >= "5.5" && $c_avgrows <= "5.99") {echo "Concept Grade: A";} if ($c_avgrows >= "5" && $c_avgrows <= "5.49") {echo "Concept Grade: A-";} if ($c_avgrows >= "4.5" && $c_avgrows <= "4.99") {echo "Concept Grade: B+";} if ($c_avgrows >= "4" && $c_avgrows <= "4.49") {echo "Concept Grade: B";} if ($c_avgrows >= "3.5" && $c_avgrows <= "3.99") {echo "Concept Grade: B-";} if ($c_avgrows >= "3" && $c_avgrows <= "3.49") {echo "Concept Grade: C+";} if ($c_avgrows >= "2.5" && $c_avgrows <= "2.99") {echo "Concept Grade: C";} if ($c_avgrows >= "2" && $c_avgrows <= "2.49") {echo "Concept Grade: C-";} if ($c_avgrows >= "1.5" && $c_avgrows <= "1.99") {echo "Concept Grade: D+";} if ($c_avgrows >= "1" && $c_avgrows <= "1.49") {echo "Concept Grade: D";} if ($c_avgrows >= ".5" && $c_avgrows <= ".99") {echo "Concept Grade: D-";} //echo "Concept Grade: $c_avgrows"; ?> <?php $e_avg =("SELECT AVG(a_execution) FROM $tbl_name2 WHERE question_id='$id'"); $e_avg1 = mysql_query($e_avg) or die ("Error in query: $query1. ".mysql_error()); $query_data_e=mysql_fetch_row($e_avg1); $e_avgrows = $query_data_e[0]; if ($e_avgrows >= "6") {echo "Execution Grade: A+";} if ($e_avgrows >= "5.5" && $e_avgrows <= "5.99") {echo "Execution Grade: A";} if ($e_avgrows >= "5" && $e_avgrows <= "5.49") {echo "Execution Grade: A-";} if ($e_avgrows >= "4.5" && $e_avgrows <= "4.99") {echo "Execution Grade: B+";} if ($e_avgrows >= "4" && $e_avgrows <= "4.49") {echo "Execution Grade: B";} if ($e_avgrows >= "3.5" && $e_avgrows <= "3.99") {echo "Execution Grade: B-";} if ($e_avgrows >= "3" && $e_avgrows <= "3.49") {echo "Execution Grade: C+";} if ($e_avgrows >= "2.5" && $e_avgrows <= "2.99") {echo "Execution Grade: C";} if ($e_avgrows >= "2" && $e_avgrows <= "2.49") {echo "Execution Grade: C-";} if ($e_avgrows >= "1.5" && $e_avgrows <= "1.99") {echo "Execution Grade: D+";} if ($e_avgrows >= "1" && $e_avgrows <= "1.49") {echo "Execution Grade: D";} if ($e_avgrows >= ".5" && $e_avgrows <= ".99") {echo "Execution Grade: D-";} //echo "Execution Grade: $e_avgrows"; ?> </b></div></td> </tr> <tr> <td colspan="2"><? echo $rows['detail']; ?></td> </tr> <tr> <td colspan="2"><div align="right"> <hr /> Posted: <? echo $rows['datetime']; ?></div></td> </tr> </table> <p> <?php $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'"; $result2=mysql_query($sql2); while($rows=mysql_fetch_array($result2)){ ?> </p> <table width="95%" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td width="10%" rowspan="3" valign="top" bgcolor="#E9CB9E"><b><? echo $rows['a_name']; ?></b></td> <td height="20" valign="top" bgcolor="#E9CB9E"><strong> Review #<? echo $rows['a_id']; ?></strong></td> <td valign="top" bgcolor="#E9CB9E"><div align="right"> Concept Grade: <b> <? $concept = $rows['a_concept']; if ($concept == "6") {echo "A+";} if ($concept == "5.5") {echo "A";} if ($concept == "5") {echo "A-";} if ($concept == "4.5") {echo "B+";} if ($concept == "4") {echo "B";} if ($concept == "3.5") {echo "B-";} if ($concept == "3") {echo "C+";} if ($concept == "2.5") {echo "C";} if ($concept == "2") {echo "C-";} if ($concept == "1.5") {echo "D+";} if ($concept == "1") {echo "D";} if ($concept == ".5") {echo "D-";} ?> </b> Execution Grade: <b> <? $execution = $rows['a_execution']; if ($execution == "6") {echo "A+";} if ($execution == "5.5") {echo "A";} if ($execution == "5") {echo "A-";} if ($execution == "4.5") {echo "B+";} if ($execution == "4") {echo "B";} if ($execution == "3.5") {echo "B-";} if ($execution == "3") {echo "C+";} if ($execution == "2.5") {echo "C";} if ($execution == "2") {echo "C-";} if ($execution == "1.5") {echo "D+";} if ($execution == "1") {echo "D";} if ($execution == ".5") {echo "D-";} ?> </b> </div></td> </tr> <tr> <td colspan="2"><? echo $rows['a_answer']; ?> <div align="right"></div></td> </tr> <tr> <td colspan="2"><div align="right"> <hr /> Posted: <? echo $rows['a_datetime']; ?></div></td> </tr> </table> <p> <? } $sql3="SELECT view FROM $tbl_name WHERE id='$id'"; $result3=mysql_query($sql3); $rows=mysql_fetch_array($result3); $view=$rows['view']; // if have no counter value set counter = 1 if(empty($view)){ $view=1; $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'"; $result4=mysql_query($sql4); } // count more value $addview=$view+1; $sql5="update $tbl_name set view='$addview' WHERE id='$id'"; $result5=mysql_query($sql5); mysql_close(); ?> <br /> </p> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="add_answer.php" method="post" name="form1" id="form1"> <td><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Post a Review on this Creative Piece <hr /> </strong></td> </tr> <tr> <td width="18%" valign="top"><strong>Review</strong></td> <td width="3%" valign="top">:</td> <td width="79%" valign="top"><input name="a_name" type="hidden" id="a_name" value="<?php echo $_SESSION['username']; ?>" size="45" /> <textarea name="a_answer" cols="60" rows="8" id="a_answer"></textarea></td> </tr> <tr> <td width="18%"> </td> <td width="3%"> </td> <td> </td> </tr> <tr> <td colspan="3"><strong>Grade This Creative Piece <hr /> </strong></td> </tr> <tr> <td width="18%" valign="top"><strong>Concept Grade</strong></td> <td width="3%" valign="top">:</td> <td valign="top"><label> <select name="a_concept" size="1" id="a_concept"> <option value="6">A+</option> <option value="5.5">A</option> <option value="5">A-</option> <option value="4.5">B+</option> <option value="4">B</option> <option value="3.5">B-</option> <option value="3">C+</option> <option value="2.5" selected="selected">C</option> <option value="2">C-</option> <option value="1.5">D+</option> <option value="1">D</option> <option value=".5">D-</option> <option value="0">F</option> </select> </label></td> </tr> <tr> <td valign="top"><p><strong>Execution Grade</strong></p></td> <td valign="top">:</td> <td valign="top"><select name="a_execution" size="1" id="a_execution"> <option value="6">A+</option> <option value="5.5">A</option> <option value="5">A-</option> <option value="4.5">B+</option> <option value="4">B</option> <option value="3.5">B-</option> <option value="3">C+</option> <option value="2.5" selected="selected">C</option> <option value="2">C-</option> <option value="1.5">D+</option> <option value="1">D</option> <option value=".5">D-</option> <option value="0">F</option> </select></td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> <td> </td> </tr> <tr> <td> </td> <td><input name="id" type="hidden" value="<? echo $id; ?>" /></td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table></td> </form> </tr> </table> <p> </p> <p></p></td> <td valign="top"><table width="150" border="1" align="right" cellpadding="5" cellspacing="0" bordercolor="#F73602"> <tr bordercolor="#F15A25" bgcolor="#CCCCCC"> <td bordercolor="#F15A25" bgcolor="#F15A25"></td> </tr> </table></td> </tr> </table> <p> </p> <p> </p> </div></td> </tr> </table> <p> </p> </body> </html> music player code: <? include "config.php"; $id = $_GET['id']; $tbl_name="forum_question"; //$dbcnx = mysql_connect("localhost", "root", "password"); mysql_select_db("database"); $result = @mysql_query("SELECT * FROM $tbl_name WHERE id=$id"); if (!$result) { echo("<b>Error performing query: " . mysql_error() . "</b>"); exit(); } while ($row = mysql_fetch_array($result) ) { $id = $row['id']; $artist = $row['username']; $song = $row['file']; $title = $row['topic']; echo("<center><font size=1 face=verdana>Listening To $title by $artist"); ?> <br><br><embed src="<? echo"$song"; ?>" width="250" height="40" autostart="true" loop="false"> </embed> <? } ?> Link to comment https://forums.phpfreaks.com/topic/105606-if-else-help/ Share on other sites More sharing options...
Skittalz Posted May 14, 2008 Share Posted May 14, 2008 This should work <?php $file_ext = strrchr($filename, '.'); /* This gets the string after the last occurrence of a dot which includes the dot */ if($file_ext == '.mp3' || $file_ext == '.wav') { // put the extensions you allow here Do music player code } else { Do other code } ?> Link to comment https://forums.phpfreaks.com/topic/105606-if-else-help/#findComment-541070 Share on other sites More sharing options...
jasonhardwick Posted May 14, 2008 Author Share Posted May 14, 2008 Ok Thanks... my music is now working but im gettint this error when i choose an image post. "Fatal error: Call to undefined function: imageresize() in /home/content/j/a/s/jasonhardwick/html/view_topic.php on line 113" here is my entire code: <?php session_start(); if(!isset($_SESSION['username'])) { header("location:index1.php"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>My Creative Process</title> <style type="text/css"> <!-- .style1 {color: #666666} --> </style> <link href="/css/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 { color: #f73602; font-weight: bold; } .style3 { color: #FFFFFF } .style4 {color: #F15A25} --> </style> </head> <body> <table width="972" border="0" cellspacing="0" cellpadding="5"> <tr> <td><div align="right">Logged in as: <? echo $_SESSION['username'];?></div></td> </tr> </table> <table width="972" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#F73602" id="frame"> <tr bordercolor="#F15A25"> <td colspan="4"><div align="center"> <p><img src="/images/header.jpg" width="942" height="84" /></p> <table width="902" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="728"><p><span class="style1"><a href="/index.php">home</a> | <a href="/main_forum.php">review</a> | <a href="/create_topic.php">post</a> | <a href="/mindgames.php">mindgames</a> | <a href="/archive.php">archive</a> | <a href="/brainstorm.php">brainstorm</a> | <a href="/my_profile.php">my profile</a> | <a href="user_network">my network</a> | <a href="/suggestion_box.php">suggestion box</a></span></p> </td> <td colspan="-1"><div align="right"> <? echo '<a href="logout.php">Click here to logout</a>'; ?> <? $action="sdfasdfasdfa"; if($action=="change"){ changepw($_SESSION['username']); update($newpass,$_SESSION['username']); }else{ } ?> </div></td> </tr> </table> <table width="902" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="728" valign="top"><p> <?php include "config.php"; $tbl_name="forum_question"; $id=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); $filename=$rows['file'] ?> </p> <table width="10" border="2" align="center" cellpadding="5" cellspacing="0" bordercolor="#E99979"> <tr> <td> <?php $file_ext = strrchr($filename, '.'); if($file_ext == '.mp3' || $file_ext == '.wav') { $result = @mysql_query("SELECT * FROM $tbl_name WHERE id=$id"); if (!$result) { echo("<b>Error performing query: " . mysql_error() . "</b>"); exit(); } while ($row = mysql_fetch_array($result) ) { $id = $row['id']; $artist = $row['username']; $song = $row['file']; $title = $row['topic']; echo("<center><font size=1 face=verdana>Listening To $title by $artist"); ?> <br><br><embed src="<? echo"file/$song"; ?>" width="250" height="40" autostart="true" loop="false"> </embed> <? } } else { $img_path = "file/".$rows ['file']; $image_t = getimagesize($img_path); $wh = imageResize($image_t[0], $image_t[1], 600); function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } echo "<img src=\"$img_path\" $wh />"; }?> </td> </tr> </table> <p> <? $tbl_name2="forum_answer"; $type= $rows['file_type']; ?> </p> <table width="95%" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td width="10%" rowspan="3" valign="top" bgcolor="#E99979"><b><? echo $rows['username']; ?></b></td> <td height="20" valign="top" bgcolor="#E99979"><strong><? echo $rows['topic']; ?></strong></td> <td valign="top" bgcolor="#E99979"><div align="right"><b> <?php $c_avg =("SELECT AVG(a_concept) FROM $tbl_name2 WHERE question_id='$id'"); $c_avg1 = mysql_query($c_avg) or die ("Error in query: $query1. ".mysql_error()); $query_data_c=mysql_fetch_row($c_avg1); $c_avgrows = $query_data_c[0]; if ($c_avgrows >= "6") {echo "Execution Grade: A+";} if ($c_avgrows >= "5.5" && $c_avgrows <= "5.99") {echo "Concept Grade: A";} if ($c_avgrows >= "5" && $c_avgrows <= "5.49") {echo "Concept Grade: A-";} if ($c_avgrows >= "4.5" && $c_avgrows <= "4.99") {echo "Concept Grade: B+";} if ($c_avgrows >= "4" && $c_avgrows <= "4.49") {echo "Concept Grade: B";} if ($c_avgrows >= "3.5" && $c_avgrows <= "3.99") {echo "Concept Grade: B-";} if ($c_avgrows >= "3" && $c_avgrows <= "3.49") {echo "Concept Grade: C+";} if ($c_avgrows >= "2.5" && $c_avgrows <= "2.99") {echo "Concept Grade: C";} if ($c_avgrows >= "2" && $c_avgrows <= "2.49") {echo "Concept Grade: C-";} if ($c_avgrows >= "1.5" && $c_avgrows <= "1.99") {echo "Concept Grade: D+";} if ($c_avgrows >= "1" && $c_avgrows <= "1.49") {echo "Concept Grade: D";} if ($c_avgrows >= ".5" && $c_avgrows <= ".99") {echo "Concept Grade: D-";} ?> <?php $e_avg =("SELECT AVG(a_execution) FROM $tbl_name2 WHERE question_id='$id'"); $e_avg1 = mysql_query($e_avg) or die ("Error in query: $query1. ".mysql_error()); $query_data_e=mysql_fetch_row($e_avg1); $e_avgrows = $query_data_e[0]; if ($e_avgrows >= "6") {echo "Execution Grade: A+";} if ($e_avgrows >= "5.5" && $e_avgrows <= "5.99") {echo "Execution Grade: A";} if ($e_avgrows >= "5" && $e_avgrows <= "5.49") {echo "Execution Grade: A-";} if ($e_avgrows >= "4.5" && $e_avgrows <= "4.99") {echo "Execution Grade: B+";} if ($e_avgrows >= "4" && $e_avgrows <= "4.49") {echo "Execution Grade: B";} if ($e_avgrows >= "3.5" && $e_avgrows <= "3.99") {echo "Execution Grade: B-";} if ($e_avgrows >= "3" && $e_avgrows <= "3.49") {echo "Execution Grade: C+";} if ($e_avgrows >= "2.5" && $e_avgrows <= "2.99") {echo "Execution Grade: C";} if ($e_avgrows >= "2" && $e_avgrows <= "2.49") {echo "Execution Grade: C-";} if ($e_avgrows >= "1.5" && $e_avgrows <= "1.99") {echo "Execution Grade: D+";} if ($e_avgrows >= "1" && $e_avgrows <= "1.49") {echo "Execution Grade: D";} if ($e_avgrows >= ".5" && $e_avgrows <= ".99") {echo "Execution Grade: D-";} ?> </b></div></td> </tr> <tr> <td colspan="2"><? echo $rows['detail']; ?></td> </tr> <tr> <td colspan="2"><div align="right"> <hr /> Posted: <? echo $rows['datetime']; ?></div></td> </tr> </table> <p> <?php $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'"; $result2=mysql_query($sql2); while($rows=mysql_fetch_array($result2)){ ?> </p> <table width="95%" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td width="10%" rowspan="3" valign="top" bgcolor="#E9CB9E"><b><? echo $rows['a_name']; ?></b></td> <td height="20" valign="top" bgcolor="#E9CB9E"><strong> Review #<? echo $rows['a_id']; ?></strong></td> <td valign="top" bgcolor="#E9CB9E"><div align="right"> Concept Grade: <b> <? $concept = $rows['a_concept']; if ($concept == "6") {echo "A+";} if ($concept == "5.5") {echo "A";} if ($concept == "5") {echo "A-";} if ($concept == "4.5") {echo "B+";} if ($concept == "4") {echo "B";} if ($concept == "3.5") {echo "B-";} if ($concept == "3") {echo "C+";} if ($concept == "2.5") {echo "C";} if ($concept == "2") {echo "C-";} if ($concept == "1.5") {echo "D+";} if ($concept == "1") {echo "D";} if ($concept == ".5") {echo "D-";} ?> </b> Execution Grade: <b> <? $execution = $rows['a_execution']; if ($execution == "6") {echo "A+";} if ($execution == "5.5") {echo "A";} if ($execution == "5") {echo "A-";} if ($execution == "4.5") {echo "B+";} if ($execution == "4") {echo "B";} if ($execution == "3.5") {echo "B-";} if ($execution == "3") {echo "C+";} if ($execution == "2.5") {echo "C";} if ($execution == "2") {echo "C-";} if ($execution == "1.5") {echo "D+";} if ($execution == "1") {echo "D";} if ($execution == ".5") {echo "D-";} ?> </b> </div></td> </tr> <tr> <td colspan="2"><? echo $rows['a_answer']; ?> <div align="right"></div></td> </tr> <tr> <td colspan="2"><div align="right"> <hr /> Posted: <? echo $rows['a_datetime']; ?></div></td> </tr> </table> <p> <? } $sql3="SELECT view FROM $tbl_name WHERE id='$id'"; $result3=mysql_query($sql3); $rows=mysql_fetch_array($result3); $view=$rows['view']; if(empty($view)){ $view=1; $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'"; $result4=mysql_query($sql4); } $addview=$view+1; $sql5="update $tbl_name set view='$addview' WHERE id='$id'"; $result5=mysql_query($sql5); mysql_close(); ?> <br /> </p> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="add_answer.php" method="post" name="form1" id="form1"> <td><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Post a Review on this Creative Piece <hr /> </strong></td> </tr> <tr> <td width="18%" valign="top"><strong>Review</strong></td> <td width="3%" valign="top">:</td> <td width="79%" valign="top"><input name="a_name" type="hidden" id="a_name" value="<?php echo $_SESSION['username']; ?>" size="45" /> <textarea name="a_answer" cols="60" rows="8" id="a_answer"></textarea></td> </tr> <tr> <td width="18%"> </td> <td width="3%"> </td> <td> </td> </tr> <tr> <td colspan="3"><strong>Grade This Creative Piece <hr /> </strong></td> </tr> <tr> <td width="18%" valign="top"><strong>Concept Grade</strong></td> <td width="3%" valign="top">:</td> <td valign="top"><label> <select name="a_concept" size="1" id="a_concept"> <option value="6">A+</option> <option value="5.5">A</option> <option value="5">A-</option> <option value="4.5">B+</option> <option value="4">B</option> <option value="3.5">B-</option> <option value="3">C+</option> <option value="2.5" selected="selected">C</option> <option value="2">C-</option> <option value="1.5">D+</option> <option value="1">D</option> <option value=".5">D-</option> <option value="0">F</option> </select> </label></td> </tr> <tr> <td valign="top"><p><strong>Execution Grade</strong></p></td> <td valign="top">:</td> <td valign="top"><select name="a_execution" size="1" id="a_execution"> <option value="6">A+</option> <option value="5.5">A</option> <option value="5">A-</option> <option value="4.5">B+</option> <option value="4">B</option> <option value="3.5">B-</option> <option value="3">C+</option> <option value="2.5" selected="selected">C</option> <option value="2">C-</option> <option value="1.5">D+</option> <option value="1">D</option> <option value=".5">D-</option> <option value="0">F</option> </select></td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> <td> </td> </tr> <tr> <td> </td> <td><input name="id" type="hidden" value="<? echo $id; ?>" /></td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table></td> </form> </tr> </table> <p> </p> <p></p></td> <td valign="top"><table width="150" border="1" align="right" cellpadding="5" cellspacing="0" bordercolor="#F73602"> <tr bordercolor="#F15A25" bgcolor="#CCCCCC"> <td bordercolor="#F15A25" bgcolor="#F15A25"></td> </tr> </table></td> </tr> </table> <p> </p> <p> </p> </div></td> </tr> </table> <p> </p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/105606-if-else-help/#findComment-541084 Share on other sites More sharing options...
Skittalz Posted May 14, 2008 Share Posted May 14, 2008 put the function above the line where u call it Link to comment https://forums.phpfreaks.com/topic/105606-if-else-help/#findComment-541087 Share on other sites More sharing options...
jasonhardwick Posted May 14, 2008 Author Share Posted May 14, 2008 like so? <?php } } else { //function imageResize(){}; $img_path = "file/".$rows ['file']; $image_t = getimagesize($img_path); function imageResize($width, $height, $target) { $wh = imageResize($image_t[0], $image_t[1], 100); if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } echo "<img src=\"$img_path\" $wh />"; }?> i dont get my image to show up now Link to comment https://forums.phpfreaks.com/topic/105606-if-else-help/#findComment-541133 Share on other sites More sharing options...
Skittalz Posted May 15, 2008 Share Posted May 15, 2008 function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } that all needs to be together Link to comment https://forums.phpfreaks.com/topic/105606-if-else-help/#findComment-542230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.