Jump to content

Drummin

Members
  • Posts

    1,004
  • Joined

  • Last visited

Everything posted by Drummin

  1. See that's my point... What is your current code and what are you trying to do? The array building example I gave was based on a DB query using $modelID as the condition, which should result in building an array of images just for this model. IF this query is being nested within another query of "models" then this fact should be known and considered when building the array. Probably just adding the modelID as a key like so would build an array for this task. while($row=mysql_fetch_assoc($RecImage_query)){ $images[$modelID][]=$row["imageFile"]; } Then your foreach loop would need to add this KEY like so. <?php foreach($images[$modelID] as $image){ echo "<td><img src='../cms/models/content/$modelID/$image' width='70' height='116' border='0'></td>"; } ?> Again, a better explanation of what you're doing is needed.
  2. Probably time for a new look at your current code and explanation of what you are trying to do before continuing.
  3. You've already defined the modelID with the variable $modelID. The $images array is just holding the images. So as a simple example you would do. <?php foreach($images as $image){ echo "<td><img src='../cms/models/content/$modelID/$image' width='70' height='116' border='0'></td>"; } ?> Or if you just want the first image <?php echo "<td><img src='../cms/models/content/$modelID/$images[0]' width='70' height='116' border='0'></td>"; ?> ******************** IS the issue that you have different models on this page, each with a different modelID? If that's the case then the whole approach should be different in building the array in the first place.
  4. It's hard to fix a relative path problem without knowing WHERE this file is listed compared to where the image is. As for testing a path, you should be able to hard code a line to see an image then use it as an example. <img src='../cms/models/content/$modelID/valid_image.jpg' width='208' height='345' border='0' name='Limage' id='Limage'> NOTE: I noticed some missing spaces with the line above. The issue was though, is the proper image(s) being loaded into the array, which is why I wanted you to print_r the $images array. You said you DID print the array. Is it holding what it should be? The key for the first image should be zero. Is it?
  5. 1) Did you print the array as suggested? 2) Do you have image folders for each model named the modelID? 3) Have you verified that the images listed in the DB match those in the folder for this model?
  6. Yest they can. Lots of people do it. Well yes of course, but does it validate?
  7. Well it does seem to be a path issue and my last post was based on the model.php file you attached. Note images should not have periods in their name. If below the code where you build the $images array you add (temporarily) <?php echo "<pre>"; print_r($images); echo "</pre>"; ?> What does the show?
  8. OH, so these tables are holding many records with the same "color" value. Try wrapping the table field in DISTINCT() within your query. For example. $query="SELECT DISTINCT(q1) FROM surveys.SGID_satisfaction";
  9. Remember arrays start with the key of zero and not one, so try. <?php if (isset($images[0])){ echo "<img src='../cms/models/content/$modelID/{$images[0]}' width='208'height='345' border='0'name='Limage' id='Limage'></td>"; }else{ ?> <td><img src="../images/spacer.gif" width="208" height="345" border="0"></td> <?php } ?>
  10. Is $row["imageFile"] containing "models/content/$modelID/" without the image? I guess I don't understand how $images[]=$row["imageFile"]; ..can contain anything other than the path you specify in $row["imageFile"]. How are you using the $images array to show images? This more than likely is where the problem is.
  11. Closing php tag is ?> Opening is <?php As KevinM1 pointed out it's not a good idea to wrap html in a php bracket. You give the example of a function to show header. Personally I would make a new page called header.php and have in it. <html> <head> <title>Blah Blah Blah</title> </head> <body> Do the same for the footer. Then site pages would be something like this. <?php //include db connection include("access.php"); //Any processing code for user input goes above header and before any information is passed to browser// //Include header// include("header.php"); //Any content like forms or tables should be hard coded.// ?> <h2>Sample Content</h2> <?php //Any text content saved in DB can be echoed on the page.// echo "$pagecontent"; //Include footer// include("footer.php"); ?>
  12. Let me guess, year is next? If you need it. <select name="year"> <?php $cyear = date("Y"); foreach(range(1930,$cyear) as $year){ $selected_year=(isset($_POST['year']) && $_POST['year']==$year ? 'selected="selected"':''); echo "<option value=\"$year\" $selected_year>$year</option>"; } ?> </select>
  13. Array for months will work for this. <select name="month"> <?php $months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); foreach ($months as $month){ $selected_month=(isset($_POST['month']) && $_POST['month']==$month ? 'selected="selected"':''); echo "<option value=\"$month\" $selected_month>$month</option>"; } ?> </select>
  14. You can use range for this. <select name="day"> <?php $days = date("t"); foreach(range(1,$days) as $day){ $selected_day=(isset($_POST['day']) && $_POST['day']==$day ? 'selected="selected"':''); echo "<option value=\"$day\" $selected_day>$day</option>"; } ?> </select> Note: I suppose using days in current month might me confusing or not what you need. You can use range(1,31) for the foreach statement.
  15. Right xyph, I didn't read the question well enough. Possibly save selected values to session?
  16. Here's a few simple examples. <html> <body> <form method="post" action=""> <?php $genders=array("Male","Female"); foreach($genders as $gender){ $selected_gender=(isset($_POST['gender']) && $_POST['gender']==$gender ? 'checked="checked"':''); echo "<input type=\"radio\" name=\"gender\" value=\"$gender\" $selected_gender /> $gender "; } ?> <select name="fruit"> <?php $fruits=array("Apple","Bannana","Orange","Pear"); foreach($fruits as $fruit){ $selected_fruit=(isset($_POST['fruit']) && $_POST['fruit']==$fruit ? 'selected="selected"':''); echo "<option value=\"$fruit\" $selected_fruit>$fruit</option>"; } ?> </select> <input type="submit" value="submit" /> </form> </body> </html>
  17. Man I can't believe I didn't spot that those () in place of []. Try this. <html> <head> </head> <body> <?php //db connections or error returns $connect = mysql_connect(DELETED); if (!$connect) { exit('<p>Unable to connect to the server at this time.</p>'); } mysql_select_db("surveys"); if (!mysql_select_db("surveys")) { exit ('<p>Unable to locate the database at this time.</p>'); } //if the "submit" variable does not exist, the form has not been submitted - display initial page if (!isset($_POST['submit'])) { //form ?> <form name="sgid" id="sgid" method="post" action="sgidsurveyquery.php"> <h1>SGID Satisfaction Survey Results</h1> <h2>Results can be filtered by evaluation party and semester/year given.</h2></br> Please choose: <?php //pull evaluator drop down choices from db as array $query="SELECT q1 FROM surveys.SGID_satisfaction"; $result=mysql_query($query); $options=""; $options.="<option value=\"0\">Select</option>"; while ($row=mysql_fetch_array($result)){ $evaluator=$row['q1']; $options.="<option value=\"$evaluator\">$evaluator</option>"; } $options.="<option value=\"all\">All</option>"; $options.="<option value=\"test\">test</option>"; ?> <select name="evaluator"> <?php echo $options; ?> </select> for <?php //pull date drop down choices from db as array $query="SELECT q2 FROM surveys.SGID_satisfaction"; $result=mysql_query($query); $options=""; $options.="<option value=\"0\">Select</option>"; while ($row=mysql_fetch_array($result)){ $date=$row['q2']; $options.="<option value=\"$date\">$date</option>"; } $options.="<option value=\"all\">All</option>"; $options.="<option value=\"test2\">test</option>"; ?> <select name="date"> <?php echo $options; ?> </select> <input type="submit" name ="submit" value="Show Results"> </form> <?php } else { //display results print"<h2>SGID Satisfaction Survey Results</h2><br/>"; $evaluator = mysql_real_escape_string($_POST['evaluator']); $date = mysql_real_escape_string($_POST['date']); $search = array(); //run query $query = "SELECT q1, q2, q3, q4, q5 FROM surveys.SGID_satisfaction "; if ($evaluator!="0" && $evaluator!="all"){ $search[] ="q1='$evaluator'"; } if ($date!="0" && $date!="all"){ $search[] ="q2='$date'"; } if (count($search)>=1){ $query .= "WHERE "; $query .= implode(' AND ',$search); } $query .= " ORDER BY created"; echo "<h3>Results of SGID Satisfaction Survey performed by $evaluator during $date</h3></br>"; //display number of records returned $result = mysql_query ($query) or die(mysql_error()); $num_rows = mysql_num_rows($result); echo "Your query returned $num_rows responses."; //Start a table print "<table CELLPADDING=10 border =1 >"; print "<tr>"; print "<th style='width:150px'>Which organization did your SGID?</th>"; print "<th style='width:100px'>Please specify the semester and year the SGID was done.</th>"; print "<th style='width:300px'>What about this service was helpful for your teaching?</th>"; print "<th style='width:300px'>What about this service could be improved to support your teaching?</th>"; print "<th style='width:300px'>Would you be willing for us to contact you later about what, if anything, you have changed and how that has affected student learning?</th>"; print "</tr>"; while ($row = @mysql_fetch_array($result)) { print "<table CELLPADDING=10 border = 1>"; print "<tr>"; print "<td style='width:150px'>".$row['q1']."</td>"; print "<td style='width:100px'>".$row['q2']."</td>"; print "<td style='width:300px'>".$row['q3']."</td>"; print "<td style='width:300px'>".$row['q4']."</td>"; print "<td style='width:300px'>".$row['q5']."</td>"; print "</tr>"; print "</table>"; } //close results mysql_close(); } ?> </body> </html>
  18. Sorry I have not looked the attached file yet, but it seems you are just building an array of the image results. Wouldn't this be easier? <?php $SQLImage="SELECT * FROM tblImages INNER JOIN tblModel ON tblImages.modelID = tblModel.modelID WHERE tblImages.modelID = '".$modelID."' AND tblImages.imageTypeID = '2' OR tblModel.modelStatus <>'Offline'"; $RecImage_query=mysql_query($SQLImage,$oConn) or die("Error: ". mysql_error(). " with query ". $SQLImage); $images=array(); $cnt=mysql_num_rows($RecImage_query); if ($cnt>0){ while($row=mysql_fetch_assoc($RecImage_query)){ $images[]=$row["imageFile"]; } } ?>
  19. See how this works. (Untested) <html> <head> </head> <body> <?php //db connections or error returns $connect = mysql_connect(DELETED); if (!$connect) { exit('<p>Unable to connect to the server at this time.</p>'); } mysql_select_db("surveys"); if (!mysql_select_db("surveys")) { exit ('<p>Unable to locate the database at this time.</p>'); } //if the "submit" variable does not exist, the form has not been submitted - display initial page if (!isset($_POST['submit'])) { //form ?> <form name="sgid" id="sgid" method="post" action="sgidsurveyquery.php"> <h1>SGID Satisfaction Survey Results</h1> <h2>Results can be filtered by evaluation party and semester/year given.</h2></br> Please choose: <?php //pull evaluator drop down choices from db as array $query="SELECT q1 FROM surveys.SGID_satisfaction"; $result=mysql_query($query); $options=""; $options.="<option value=\"0\">Select</option>"; while ($row=mysql_fetch_array($result)){ $evaluator=$row("q1"); $options.="<option value=\"$evaluator\">$evaluator</option>"; } $options.="<option value=\"all\">All</option>"; ?> <select name="evaluator"> <?php echo $options; ?> </select> for <?php //pull date drop down choices from db as array $query="SELECT q2 FROM surveys.SGID_satisfaction"; $result=mysql_query($query); $options=""; $options.="<option value=\"0\">Select</option>"; while ($row=mysql_fetch_array($result)){ $date=$row("q2"); $options.="<option value=\"$date\">$date</option>"; } $options.="<option value=\"all\">All</option>"; ?> <select name="date"> <?php echo $options; ?> </select> <input type="submit" name ="submit" value="Show Results"> </form> <?php } else { //display results print"<h2>SGID Satisfaction Survey Results</h2><br/>"; $evaluator = mysql_real_escape_string($_POST['evaluator']); $date = mysql_real_escape_string($_POST['date']); $search = array(); //run query $query = "SELECT q1, q2, q3, q4, q5 FROM surveys.SGID_satisfaction "; if ($evaluator!="0" && $evaluator!="all"){ $search[] ="q1='$evaluator'"; } if ($date!="0" && $date!="all"){ $search[] ="q2='$date'"; } if (count($search)>=1){ $query .= "WHERE "; $query .= implode(' AND ',$search); } $query .= " ORDER BY created"; echo "<h3>Results of SGID Satisfaction Survey performed by $evaluator during $date</h3></br>"; //display number of records returned $result = mysql_query ($query) or die(mysql_error()); $num_rows = mysql_num_rows($result); echo "Your query returned $num_rows responses."; //Start a table print "<table CELLPADDING=10 border =1 >"; print "<tr>"; print "<th style='width:150px'>Which organization did your SGID?</th>"; print "<th style='width:100px'>Please specify the semester and year the SGID was done.</th>"; print "<th style='width:300px'>What about this service was helpful for your teaching?</th>"; print "<th style='width:300px'>What about this service could be improved to support your teaching?</th>"; print "<th style='width:300px'>Would you be willing for us to contact you later about what, if anything, you have changed and how that has affected student learning?</th>"; print "</tr>"; while ($row = mysql_fetch_array($result)) { print "<table cellpadding=10 border = 1>"; print "<tr>"; print "<td style='width:150px'>".$row['q1']."</td>"; print "<td style='width:100px'>".$row['q2']."</td>"; print "<td style='width:300px'>".$row['q3']."</td>"; print "<td style='width:300px'>".$row['q4']."</td>"; print "<td style='width:300px'>".$row['q5']."</td>"; print "</tr>"; print "</table>"; } //close results mysql_close(); } ?> </body> </html>
  20. Add a checkbox to your form for "all". Update DB query as follows. //run query $query = "SELECT q1, q2, q3, q4, q5 FROM surveys.SGID_satisfaction "; if (isset($_POST['all'])){ //run query without conditions $query .= "ORDER BY created"; }else( //run query with conditions $query .= "WHERE q1='$evaluator' AND q2= '$date' ORDER BY created"; } NOTE: Don't use short tags <? ?>. Use full tags <?php ?>
  21. Using empty() for the first checks is a better option as all fields will be posted. <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("login") or die(mysql_error()); $errors=""; $message=""; if (isset($_POST['submit'])) { if (empty($_POST['username']) || empty($_POST['pass']) || empty($_POST['pass2']) || empty($_POST['namelast']) || empty($_POST['namefirst']) || empty($_POST['namemi']) || empty($_POST['type']) || empty($_POST['gender']) || empty($_POST['course'])) { $errors .= "You did not complete all of the required fields"; } if (empty($errors)){ //continue //Check for valid type $allowed_types = array('student', 'faculty'); if (!in_array($_POST['type'],$allowed_types)){ $errors .= "Please select a valid account type."; }else{ $typecheck = $_POST['type']; } } if (empty($errors)){ //continue if ($_POST['course']=="na"){ $errors .= "Please select a course."; } } if (empty($errors)){ //continue if (get_magic_quotes_gpc()){ function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); } } if (empty($errors)){ if ($_POST['pass'] != $_POST['pass2']) { $errors .= "Your passwords did not match."; } } if (empty($errors)){ //continue query DB $_POST['pass'] = mysql_real_escape_string($_POST['pass']); $_POST['username'] = mysql_real_escape_string($_POST['username']); $_POST['namelast'] = mysql_real_escape_string($_POST['namelast']); $_POST['namefirst'] = mysql_real_escape_string($_POST['namefirst']); $_POST['namemi'] = mysql_real_escape_string($_POST['namemi']); $_POST['type'] = mysql_real_escape_string($_POST['type']); $_POST['gender'] = mysql_real_escape_string($_POST['gender']); $_POST['course'] = mysql_real_escape_string($_POST['course']); $pass = md5($_POST['pass']); $check = "SELECT fusername FROM $typecheck WHERE fusername = '" . $_POST['username'] . "'"; $result = mysql_query($check) or die(mysql_error()); $result_count = mysql_num_rows($result); if ($result_count == 1) { $errors .= "Sorry, the username " . $_POST['username'] . " is already in use."; } //Add New User else{ $insert = "INSERT INTO $typecheck (fusername, fpassword, fnamelast, fnamefirst, fnamemi, ftype, fgender, fcourse) VALUES ('".$_POST['username']."', '$pass', '".$_POST['namelast']."', '".$_POST['namefirst']."', '".$_POST['namemi']."' , '".$_POST['type']."', '".$_POST['gender']."', '".$_POST['course']."')"; $add_member = mysql_query($insert) or die(mysql_error()); if (mysql_affected_rows()==1){ $message .= "<h1>Registered</h1> <p>Thank you, you have registered - you may now <a href=\"login.php\">login</a>.</p>"; } } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Registration</title> </head> <body> <?php //Show success message else show form// if (!empty($message)){ echo "$message"; }else{ //echo any errors if (!empty($errors)){ echo "$errors";} ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr> <td>Username:</td> <td colspan="3"><input type="text" name="username" maxlength="60" value="<?php if(isset($_POST['username'])){ echo "{$_POST['username']}";} ?>" /></td> </tr> <tr> <td>Password:</td> <td colspan="3"><input type="password" name="pass" maxlength="10" value="<?php if(isset($_POST['pass'])){ echo "{$_POST['pass']}";} ?>" /></td> </tr> <tr> <td>Confirm Password:</td> <td colspan="3"><input type="password" name="pass2" maxlength="10" value="<?php if(isset($_POST['pass2'])){ echo "{$_POST['pass2']}";} ?>" /></td> </tr> <tr> <td>Name:</td> <td><input type="text" name="namelast" maxlength="15" value="<?php if(isset($_POST['namelast'])){ echo "{$_POST['namelast']}";} ?>" /></td> <td><input type="text" name="namefirst" maxlength="15" value="<?php if(isset($_POST['namefirst'])){ echo "{$_POST['namefirst']}";} ?>" /></td> <td><input type="text" name="namemi" maxlength="15" value="<?php if(isset($_POST['namemi'])){ echo "{$_POST['namemi']}";} ?>" /></td> </tr> <tr> <td> </td> <td>Last</td> <td>First</td> <td>Middle Name</td> </tr> <tr> <td>Course:</td> <td colspan="3"> <select name= "course"> <?php $courses = array( "na" => "---N.A.----", "bscs" => "B.S. Computer Science", "bsit" => "B.S. Information Technology", "bsba" => "B.S. Business Administration" ); foreach($courses as $key => $value){ $selected_course = (isset($_POST['course']) && $_POST['course']==$key ? 'selected="selected"' : ''); echo "<option value=\"$key\" $selected_course>$value</option>\r"; } ?> </select> </td> </tr> <tr> <td>Gender:</td> <td colspan="3"> <select name= "gender"> <?php $gender = array("Male","Female"); foreach($gender as $g){ $selected_gender = (isset($_POST['gender']) && $_POST['gender']==$g ? 'selected="selected"' : ''); echo "<option value=\"$g\" $selected_gender>$g</option>\r"; } ?> </select> </td> </tr> <tr> <td>Type of Account:</td> <td colspan="3"> <select name= "type"> <?php $atype = array( "student" => "Student", "faculty" => "Teacher" ); foreach($atype as $tkey => $tvalue){ $selected_type = (isset($_POST['type']) && $_POST['type']==$tkey ? 'selected="selected"' : ''); echo "<option value=\"$tkey\" $selected_type>$tvalue</option>\r"; } ?> </select> </td> </tr> <tr> <th colspan="4"><input type="submit" name="submit" value="Register" /></th> </tr> </table> </form> <?php } ?> </body> </html>
  22. See if this helps. <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("login") or die(mysql_error()); $errors=""; $message=""; if (isset($_POST['submit'])) { if (!$_POST['username'] || !$_POST['pass'] || !$_POST['pass2'] || !$_POST['namelast']| !$_POST['namefirst'] || !$_POST['namemi'] || !$_POST['type'] || !$_POST['gender'] || !$_POST['course'] ) { $errors .= "You did not complete all of the required fields"; } if (empty($errors)){ //continue //Check for valid type $allowed_types = array('student', 'faculty'); if (!in_array($_POST['type'],$allowed_types)){ $errors .= "Please select a valid account type."; }else{ $typecheck = $_POST['type']; } } if (empty($errors)){ //continue if ($_POST['course']=="na"){ $errors .= "Please select a course."; } } if (empty($errors)){ //continue if (get_magic_quotes_gpc()){ function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); } } if (empty($errors)){ if ($_POST['pass'] != $_POST['pass2']) { $errors .= "Your passwords did not match."; } } if (empty($errors)){ //continue query DB $_POST['pass'] = mysql_real_escape_string($_POST['pass']); $_POST['username'] = mysql_real_escape_string($_POST['username']); $_POST['namelast'] = mysql_real_escape_string($_POST['namelast']); $_POST['namefirst'] = mysql_real_escape_string($_POST['namefirst']); $_POST['namemi'] = mysql_real_escape_string($_POST['namemi']); $_POST['type'] = mysql_real_escape_string($_POST['type']); $_POST['gender'] = mysql_real_escape_string($_POST['gender']); $_POST['course'] = mysql_real_escape_string($_POST['course']); $pass = md5($_POST['pass']); $check = "SELECT fusername FROM $typecheck WHERE fusername = '" . $_POST['username'] . "'"; $result = mysql_query($check) or die(mysql_error()); $result_count = mysql_num_rows($result); if ($result_count == 1) { $errors .= "Sorry, the username " . $_POST['username'] . " is already in use."; } //Add New User else{ $insert = "INSERT INTO $typecheck (fusername, fpassword, fnamelast, fnamefirst, fnamemi, ftype, fgender, fcourse) VALUES ('".$_POST['username']."', '$pass', '".$_POST['namelast']."', '".$_POST['namefirst']."', '".$_POST['namemi']."' , '".$_POST['type']."', '".$_POST['gender']."', '".$_POST['course']."')"; $add_member = mysql_query($insert) or die(mysql_error()); if (mysql_affected_rows()==1){ $message .= "<h1>Registered</h1> <p>Thank you, you have registered - you may now <a href=\"login.php\">login</a>.</p>"; } } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Registration</title> </head> <body> <?php //Show success message else show form// if (!empty($message)){ echo "$message"; }else{ //echo any errors if (!empty($errors)){ echo "$errors";} ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr> <td>Username:</td> <td colspan="3"><input type="text" name="username" maxlength="60" value="<?php if(isset($_POST['username'])){ echo "{$_POST['username']}";} ?>" /></td> </tr> <tr> <td>Password:</td> <td colspan="3"><input type="password" name="pass" maxlength="10" value="<?php if(isset($_POST['pass'])){ echo "{$_POST['pass']}";} ?>" /></td> </tr> <tr> <td>Confirm Password:</td> <td colspan="3"><input type="password" name="pass2" maxlength="10" value="<?php if(isset($_POST['pass2'])){ echo "{$_POST['pass2']}";} ?>" /></td> </tr> <tr> <td>Name:</td> <td><input type="text" name="namelast" maxlength="15" value="<?php if(isset($_POST['namelast'])){ echo "{$_POST['namelast']}";} ?>" /></td> <td><input type="text" name="namefirst" maxlength="15" value="<?php if(isset($_POST['namefirst'])){ echo "{$_POST['namefirst']}";} ?>" /></td> <td><input type="text" name="namemi" maxlength="15" value="<?php if(isset($_POST['namemi'])){ echo "{$_POST['namemi']}";} ?>" /></td> </tr> <tr> <td> </td> <td>Last</td> <td>First</td> <td>Middle Name</td> </tr> <tr> <td>Course:</td> <td colspan="3"> <select name= "course"> <?php $courses = array( "na" => "---N.A.----", "bscs" => "B.S. Computer Science", "bsit" => "B.S. Information Technology", "bsba" => "B.S. Business Administration" ); foreach($courses as $key => $value){ $selected_course = (isset($_POST['course']) && $_POST['course']==$key ? 'selected="selected"' : ''); echo "<option value=\"$key\" $selected_course>$value</option>\r"; } ?> </select> </td> </tr> <tr> <td>Gender:</td> <td colspan="3"> <select name= "gender"> <?php $gender = array("Male","Female"); foreach($gender as $g){ $selected_gender = (isset($_POST['gender']) && $_POST['gender']==$g ? 'selected="selected"' : ''); echo "<option value=\"$g\" $selected_gender>$g</option>\r"; } ?> </select> </td> </tr> <tr> <td>Type of Account:</td> <td colspan="3"> <select name= "type"> <?php $atype = array( "student" => "Student", "faculty" => "Teacher" ); foreach($atype as $tkey => $tvalue){ $selected_type = (isset($_POST['type']) && $_POST['type']==$tkey ? 'selected="selected"' : ''); echo "<option value=\"$tkey\" $selected_type>$tvalue</option>\r"; } ?> </select> </td> </tr> <tr> <th colspan="4"><input type="submit" name="submit" value="Register" /></th> </tr> </table> </form> <?php } ?> </body> </html>
  23. Not sure if this applies to this. From http://php.net/manual/en/language.types.boolean.php
  24. If you're using TRUE/FALSE, then I suggest you also use that in your IF condition. <?php $preview=TRUE; if ($preview==TRUE){ echo '<div id="boxPreview"> <h3>Preview</h3> <p>' . (isset($comments) ? nl2br(str2htmlentities($comments)) : "") . '</p> </div>'; } ?>
×
×
  • 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.