Jump to content

Drummin

Members
  • Posts

    1,004
  • Joined

  • Last visited

Everything posted by Drummin

  1. You can add the domain name to the iframe path. <?php if(isset($_GET['frame']) && $_GET['frame'] != ""){ $frame = $_GET['frame']; } else { $frame = "./"; } ?> <iframe src="website1one.com/<?php echo $frame;?>" border="0" framespacing="0" marginheight="0" marginwidth="0" vspace="0" hspace="0" frameborder="0" height="100%" scrolling="yes" width="100%"></iframe>
  2. if ($i == 0) { $bal = $row[6] + 0.00; } else { $bal = $row[6] + $bal;}
  3. Wrap the echo in the if statement you have above. if ($file != "." && $file != "..") {
  4. I would learn about floats. One common div would float left inside a wrapper div.
  5. You've got an extra \" in there. echo "<a href=\"http://mysite.com/". $dir . $file."\"><img src='" . $dir . $file . "' width=\"75\" height=\"75\" /></a>\n";
  6. echo "<img src='" . $dir . $file . "' />\n";
  7. You would just add a simple IF statement to set what you want. if (isset($_GET['img'])){ $image = $_GET['img']; } else{ $image =1; //Your default image id }
  8. Rather than hard coding each division I would have the display within the looping query so that for each image, the id is applied to the div and image is shown. At the top of the page I would define the base number of the images to be shown on the page and in the query add "limit 8" to only show eight images. A simple "Next" link could be added to show the next set. So you'd have something like this at the top. <?php if (isset($_GET['basenumber']) && is_numeric($_GET['basenumber'])){ $basenumber=$_GET['basenumber']; } else{ $basenumber=2; } ?> And then for the display section, something like this. <?php $sql = mysql_query("SELECT id, link FROM products WHERE id>='$basenumber' limit 8"); while($row = mysql_fetch_array($sql)){ $imageid = $row['id']; $image2 = $row['link']; ?> <div id="apDiv<?php echo $imageid;?>"><img src="<?php echo $image2;?> " width="300" /></div> <?php } ?>
  9. NOTE: The radio buttons I named "staff" (and I missed one) should be "friendliness" to match SubmitSurvey.php. <!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>Airline Survey</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> </head> <body> <h2>Please enter the following details</h2> <form method="post" action="SubmitSurvey.php"> <p>Name <input type="text" name="name" /></p> <p>Age <input type="text" name="age" /></p> <p>Flight Number <input type="text" name="flt_no" /></p> <p>Flight Date <input type="text" name="flt_date" /></p> <p>Flight Time <input type="text" name="flt_time" /></p><br /><br /> <p>Friendliness of customer staff</p><br /> <input type="radio" name="friendliness" value="No Opinion" />No Opinion<br /> <input type="radio" name="friendliness" value="Poor" />Poor<br /> <input type="radio" name="friendliness" value="Fair" />Fair<br /> <input type="radio" name="friendliness" value="Good" />Good<br /> <input type="radio" name="friendliness" value="Excellent" />Excellent<br /><br /> <p>Space for luggage storage</p><br /> <input type="radio" name="storage" value="No Opinion" />No Opinion<br /> <input type="radio" name="storage" value="Poor" />Poor<br /> <input type="radio" name="storage" value="Fair" />Fair<br /> <input type="radio" name="storage" value="Good" />Good<br /> <input type="radio" name="storage" value="Excellent" />Excellent<br /><br /> <p>Comfort of seating</p><br /> <input type="radio" name="comfort" value="No Opinion" />No Opinion<br /> <input type="radio" name="comfort" value="Poor" />Poor<br /> <input type="radio" name="comfort" value="Fair" />Fair<br /> <input type="radio" name="comfort" value="Good" />Good<br /> <input type="radio" name="comfort" value="Excellent" />Excellent<br /><br /> <p>Cleanliness of aircraft</p><br /> <input type="radio" name="cleanliness" value="No Opinion" />No Opinion<br /> <input type="radio" name="cleanliness" value="Poor" />Poor<br /> <input type="radio" name="cleanliness" value="Fair" />Fair<br /> <input type="radio" name="cleanliness" value="Good" />Good<br /> <input type="radio" name="cleanliness" value="Excellent" />Excellent<br /><br /> <p>Noise level of aircraft</p><br /> <input type="radio" name="noise" value="No Opinion" />No Opinion<br /> <input type="radio" name="noise" value="Poor" />Poor<br /> <input type="radio" name="noise" value="Fair" />Fair<br /> <input type="radio" name="noise" value="Good" />Good<br /> <input type="radio" name="noise" value="Excellent" />Excellent<br /><br /> <p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p> </form> <p><a href="ShowPastResults.php">Show Past Survey Results</a></p> </body> </html>
  10. You need to change Surveys.php so radio fields match for each group. Not sure if there are any other issues. <!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>Airline Survey</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> </head> <body> <h2>Please enter the following details</h2> <form method="POST" action="SubmitSurvey.php"> <p>Name <input type="text" name="name" /></p> <p>Age <input type="text" name="age" /></p> <p>Flight Number <input type="text" name="flt_no" /></p> <p>Flight Date <input type="text" name="flt_date" /></p> <p>Flight Time <input type="text" name="flt_time" /></p><br /><br /> <p>Friendliness of customer staff</p><br /> <input type="radio" name="staff" value="No Opinion" />No Opinion<br /> <input type="radio" name="staff" value="Poor" />Poor<br /> <input type="radio" name="staff" value="Fair" />Fair<br /> <input type="radio" name="staff" value="Good" />Good<br /> <input type="radio" name="exc" value="Excellent" />Excellent<br /><br /> <p>Space for luggage storage</p><br /> <input type="radio" name="storage" value="No Opinion" />No Opinion<br /> <input type="radio" name="storage" value="Poor" />Poor<br /> <input type="radio" name="storage" value="Fair" />Fair<br /> <input type="radio" name="storage" value="Good" />Good<br /> <input type="radio" name="storage" value="Excellent" />Excellent<br /><br /> <p>Comfort of seating</p><br /> <input type="radio" name="comfort" value="No Opinion" />No Opinion<br /> <input type="radio" name="comfort" value="Poor" />Poor<br /> <input type="radio" name="comfort" value="Fair" />Fair<br /> <input type="radio" name="comfort" value="Good" />Good<br /> <input type="radio" name="comfort" value="Excellent" />Excellent<br /><br /> <p>Cleanliness of aircraft</p><br /> <input type="radio" name="cleanliness" value="No Opinion" />No Opinion<br /> <input type="radio" name="cleanliness" value="Poor" />Poor<br /> <input type="radio" name="cleanliness" value="Fair" />Fair<br /> <input type="radio" name="cleanliness" value="Good" />Good<br /> <input type="radio" name="cleanliness" value="Excellent" />Excellent<br /><br /> <p>Noise level of aircraft</p><br /> <input type="radio" name="noise" value="No Opinion" />No Opinion<br /> <input type="radio" name="noise" value="Poor" />Poor<br /> <input type="radio" name="noise" value="Fair" />Fair<br /> <input type="radio" name="noise" value="Good" />Good<br /> <input type="radio" name="noise" value="Excellent" />Excellent<br /><br /> <p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p> </form> <p><a href="ShowPastResults.php">Show Past Survey Results</a></p> </body> </html>
  11. First try replacing all short tags with full, i.e. <?php instead of <?
  12. Give it a try. SUM(weight) should add up the weight of the queried rows.
  13. Might I suggest $sql = "SELECT `auth_users`,`f_name`,`l_name` FROM auth_users LIMIT 0, 30";
  14. Are you talking about different table fields? Or the same "weight" field? If it's the same field then you will get the sum using the same as posted above. If you need several column fields then get the sum for each and add them together.
  15. You would use SUM(weight) in your query. $sql = "SELECT SUM(weight) FROM store WHERE id LIKE $id"
  16. Hey sorry about that. Glad you got a good laugh. I don't see where you are setting $_SESSION['login_time']. Maybe??? $_SESSION['login_time']=date(strtotime('now')); IF that's the case, try if ($_SESSION['login_time'] < strtotime('now - 60 minutes')) { session_destroy(); header("Location: signup.php"); exit(); }
  17. If you are using include_once at the top of each of your pages, I believe this is fine for constants or variables but I'm not sure about session_start(); which is required on each page that uses a SESSION. Hey, maybe I'm wrong. I always use include() for DB connection and session_start. Maybe require_once() would be a better option in your case.
  18. Drummin

    Advice

    <?php //$search=value searching for $search=35; $user_items=array(13,12,11,9,27,15,16,22,21,23,24,26,29,30,31,32,33); $in_array=in_array($search, $user_items); if($in_array==1){ echo "Has item"; } else{ echo "Item not found"; } ?>
  19. I know this is php and not JS or ajax but this will create the variable called whatever you define $name as. <?php $name="stevengoh"; $$name="$name"; echo "$stevengoh"; ?>
  20. Not sure if a css fix will work. echo "<span style=\"white-space:nowrap;\">"; while($getpostid_result=mysql_fetch_array($getpostid)) { $postusername=$getpostid_result['username']; echo $postusername.";"; } echo "</span>";
  21. This sample page shows two options for using checkboxes. The big difference is in whether you use a form for each student or process all students at once. In this sample I used arrays for testing and demonstrating and pull out the values using a "foreach" statement. You will replace these foreach statements with mysql queries. Sample queries and inserts into DB are provided (commented out). <?php //Just for testing I'm creating arrays to hold student id and name. I'm also creating an array to hold activities. //It's expected that these will be removed as well as the foreach statement shown in the forms below and replaced with mysql queries where the foreach code is. $StudentIDs=array(5 => "Mark Flinn", 7 => "Mary Smith", 8 => "Robert Moss", 11 => "Jimmy Griffen", 12 => "Hanna Major"); $activities=array("Basketball", "Baseball", "Chess Team", "Volleyball", "Football"); //using this count in the lower form. $arraycount=count($activities); $arraycount2=count($activities)+1; //Process top form that posts each user individually if(isset($_POST['submit'])){ $studentID=$_POST['stuID']; foreach($_POST as $key => $value){ if($value=="yes"){ //echo values for testing echo "<br />$studentID $key"; /*Sample insert $studentID = mysql_real_escape_string($studentID); $key = mysql_real_escape_string($key); mysql_query("INSERT INTO `stuactivities` SET studentID='$studentID', activity='$key'");*/ } } } ///*******/// //Process bottom form that posts all users at the same time if(isset($_POST['submit2'])){ foreach($_POST as $key => $value){ if($value!="Submit"){ foreach($value as $studentID => $value2){ //echo values for testing echo "<br />$studentID $key"; /*Sample insert $studentID = mysql_real_escape_string($studentID); $key = mysql_real_escape_string($key); mysql_query("INSERT INTO `stuactivities` SET studentID='$studentID', activity='$key'");*/ } } } } //For testing I'm using foreach statements to pull values from the above arrays. Replace each foreach statement below with your mysql query ?> <html> <body> <?php foreach ($StudentIDs as $stuID => $stuname){ /*Sample query $getnames = mysql_query("SELECT name,studentID FROM students"); WHILE($userinfo = mysql_fetch_array($getnames)){ $stuID=$userinfo['studentID']; $stuname=$userinfo['name']; */ ?> <table border=0 summary="" cellpadding="0" style="background:#E9E9E9;"> <tr> <td> <form method="post" action="" style="padding:0; margin:0"> <div style="width:150px;float:left">Student: <?php echo "$stuname";?> <input type="hidden" name="stuID" value="<?php echo "$stuID";?>" /></div> <?PHP foreach ($activities as $activity){ /*Sample query $getactivities = mysql_query("SELECT activity FROM activities"); WHILE($gtactivities = mysql_fetch_array($getactivities)){ $activity=$gtactivities['activity']; */ echo "<div style=\"width:100px;float:left;text-align:center\">$activity <input type=\"checkbox\" name=\"$activity\" value=\"yes\" /></div>"; } ?> <input type="submit" name="submit" value="Submit" /> </form></td> </tr> </table> <?PHP } ?> <br /><br /> <form method="post" action=""> <table border=0 summary="" cellpadding="3" style="background:#E9E9E9"> <tr> <td>Student Name</td><td colspan="<?php echo "$arraycount";?>" align="center">Activities</td></tr> <?PHP foreach ($StudentIDs as $stuID => $stuname){ /*Sample query $getnames = mysql_query("SELECT name,studentID FROM students"); WHILE($userinfo = mysql_fetch_array($getnames)){ $stuID=$userinfo['studentID']; $stuname=$userinfo['name']; */ ?> <tr> <td><?php echo "$stuname";?></td> <?PHP foreach ($activities as $activity){ /*Sample query $getactivities = mysql_query("SELECT activity FROM activities"); WHILE($gtactivities = mysql_fetch_array($getactivities)){ $activity=$gtactivities['activity']; */ echo "<td>$activity";?> <input type="checkbox" name="<?php echo "$activity";?>[<?php echo "$stuID";?>]" value="yes" /> </td> <?PHP } echo "</tr>"; } ?> <tr> <td colspan="<?php echo "$arraycount2";?>"><input type="submit" name="submit2" value="Submit" /></td> </tr> </table> </form> </body> </html>
  22. Instead of creating table fields for each type of activity as those will change, I would just have StudentID and Activities. Then for each posted (checkbox) activity insert studentID and the activity. You'd have something like this in your table assuming id is 5. StudentID | Activities 5 | Basketball 5 | Baseball 5 | Chess Team Then to show records you query for for student id and it would pull up all names listed under Activities where the student id matches. If you wanted to show all all students that for example are in Basketball, you would search for that.
  23. The code I posted is saving item id as key and quantity as value. You'll do something like this. $cart = $_SESSION['cart']; foreach ($cart as $id => $quantity) { echo "ID:". $id . "Quantity:". $quantity. "<br>"; }
  24. Upon successful form processing and validation set some value to session and at the top of the file download page check for this session value and if not found use header("location: register.php"); to send folks back if session is not found.
  25. So you snag the code from the other guys post and then expect someone to configure it to suit your needs? Try reading the code line-by-line and understand what's going on. Who knows, you might even figure out where you need to make changes and even attempt to write the section to save info to the DB. I would say, after attempting this and creating the DB table for saving the info and testing then write a post if you run into problems.
×
×
  • 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.