Jump to content

jushiro

Members
  • Posts

    60
  • Joined

  • Last visited

    Never

Everything posted by jushiro

  1. I have a sql statement w/c suppose to output only those records w/c has a name of seller. But, it keeps showing all the records. <?php session_start(); if(isset($_SESSION['name']) || ($_SESSION['contact']) || ($_SESSION['address']) ) { ini_set('display_errors', 0); $name = $_SESSION['name']; $contact = $_SESSION['contact']; $address = $_SESSION['address']; ?> <div id="apDiv1"> <?php echo "Name : $name"; echo "</br>"; echo "Name : $contact"; echo "</br>"; echo "Name : $address"; ?> <div id="apDiv2"> <?php $host="localhost"; $username="root"; $password=""; $db_name="feedbackdb"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM Feedbacks WHERE Seller = $name"; $result=mysql_query($sql); echo "<table border=\"5\" width=\"600\" >"; echo "<tr><th>Feedbacks</th><th>From</th><th> To </th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "" .$row['Feedback']."<br></td>"; echo "<td>".$row['From']."<br></td>"; echo "<td>".$row['Seller']."<br></td>"; echo "</tr>"; } } else { echo "<tr><td align=\"center\"> No Feedback</td></tr>"; } ?></div> </div> <?php } else { header("location:loginpage.php");; } ?>
  2. I dont know why my code is not inserting the values.. Someone help pls. <?php session_start(); if(isset($_SESSION['owner']) ) { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("feedbackdb", $con); $from = $_POST['from']; $type = $_POST['type']; $feedback = $_POST['feedback']; $owner = $_SESSION['owner']; $from = stripslashes($from); $type = stripslashes($type); $feedback = stripslashes($feedback); $owner = stripslashes($owner); $from = mysql_real_escape_string($from); $type = mysql_real_escape_string($type); $feedback = mysql_real_escape_string($feedback); $owner = mysql_real_escape_string($owner); mysql_query("INSERT INTO Feedbacks (Feedback, From, To, Type,) VALUES ('$feedback', '$from', '$owner','$type')") or die(mysql_error); /*echo '<script type="text/javascript"> {alert("Feedback successfully Added");} </script>'; //echo '<meta http-equiv="REFRESH" content="0;url=Profilepage.php">';*/ } else { header("location:buysection.php");; } ?>
  3. I dont know how to say it but. To simplify this : I want to know how can i put values on the button? what i did is make a array to output those values and have buttons. here. if($result){ while($row = mysql_fetch_assoc($result)) { $itemname = $row['itemname']; $itemprice= $row['itemprice']; $owner =$row['owner']; $items[] = array($itemname,$itemprice,$owner); } } echo("<form action=\"buy.php\" method=\"post\">\n"); for ($i=0;$i<count($items);$i++) { echo("".$items[$i][0]."<br>\n"); echo("".$items[$i][1]."<br>\n"); echo("".$items[$i][2]."<br>\n"); echo "<input type=\"submit\" value=\"BUY\" name =\"buy\">"; echo "<input type=\"submit\" value=\"POST FEEDBACK\" name=\"name\"></br><br></form>"; } I succeeded in making those queries and button. but my problem is' The button "POST FEEDBACK" i want it to have the value of $items[$i][2].. So that when i turn to the next page i can echo the value of that POST FEEDBACK.
  4. What do you mean? But what i want is to query just those 3 values from my database and have button for that.
  5. Im having trouble making a code for a feedback system. Can anyone help me to make a code like this. I have a table w/c contains -------------------------------------------- | Itemname | Itemprice | Seller | Laptop | 15000 | Name Phone | 5000 | Name ----------------------------------- Then.. i want a code that will query those values.. And have a button : [bUY] and after the values. Then after clicking POST FEEDBACK it will show the values of the SELLER name in another page. HELP ME PLS
  6. Hi, Im making a form that contains 3 textboxes.. now i want my textboxes to contain only letters.. i used is_numeric for the validation but when i put' like.. "JUSHIRO1" my code will still accept it. can someone help me make a code that will validate my textbox to only accept letters. and one more.. when the user input in the textbox with a number a popup box will appear.
  7. Hmm.. i dont know how can i do a standalone that can be the same output to what i want to do but' here.. i just want to make a loop that outputs a dropdown list depending on how much quantity the user input.. Like if i put '2' as my quantity then it will output a 2 dropdown list that contains my values in my database.. can you help me make a code for that sir?
  8. I think this is the problem sir. but not quite sure where. for($i = 0; $i < $q; $i++){ echo "Bottle Number :"; echo "<select name=\"bottlenum[]\" onChange=\"this.name\"> <option>Select</option>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<option>" .$row['BottleNumber']. "</option>"; } echo "</select>"; } else { echo "<option>No Customer Encoded</option></select>"; } This code will suppose to dropdown the BottleNumbers in my database' well since i create 1 bottlenumber w/c is "1111" the output of my dropdown would be "SELECT / 1111" well it works fine but when the code looped and created 2 pairs of the dropdown. the 2nd dropdown only output "SELECT".. Help me please sir.
  9. I've made a loop here.. <form name="formdeliver" method="post" action="addOrder.php" onSubmit="return confirm('Are you Sure the data inputed are correct? Click Ok to continue.')"> <div id="apDiv2" style="overflow:auto "> <?php $host="localhost"; $username="root"; $password=""; $db_name="SEdatabase"; $tbl_name="bottlenumbers"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $name = $_SESSION['customername']; $q = $_SESSION['quantity']; echo "<table border='1'> <tr> <td><font size = '2'>Customer Name : $name </font></td></tr><tr> <td><font size = '2'>Quantity : $q </font></td> </tr> </table><br>"; for($i = 0; $i < $q; $i++){ echo "Bottle Number :"; echo "<select name=\"bottlenum[]\" onChange=\"this.name\"> <option>Select</option>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<option>" .$row['BottleNumber']. "</option>"; } echo "</select>"; } else { echo "<option>No Customer Encoded</option></select>"; } echo "<font size = 2 >Type :</font> <select name=\"bottletype[]\" onChange=\"this.name\"'>'; <option selected>Select .. </option> <option> Slim </option> <option> Round </option> </select><br>"; } ?> <br> <input type="image" src="continue.png" width="100" height="25" name="login" border="0" /> </div> </form> So what it basically do is.. User will input some data w/c i included as $_POST['customername'] and $_POST['quantity'] So when the user will input 5 quantity.. i want my loop to have 5 pairs of 2 drop down list.. well i suceeded there. but, my problem is the 1st pair will output the .$row['BottleNumber']. w/c i included at the loop, and then the rest will have no output.. when i clicked them the dropdown list will only show the Select one. but for the 1st pair its working fine. Sorry for the bad english.. someone help me pls
  10. Can anyone help me to make a countdown timer in php? so basically i've made a quiz.. but i want it to have a time of 1 hour 30 mins.. but i dont have any idea of how to make a timer
  11. Are you using SQL?.. Try this. SELECT * FROM 1 , 2 , 3 Where A='x' AND B='y' AND C='z'
  12. I have a table in my php Mysql which contains some values.. Is it possible to get those values then export them to MS word with formatting? and make it like a table? Help pls. :'(
  13. I've Got here a code.. it can upload pdf file. but it doesnt accept word documents and powerpoints And i dont know the problem.. Here's The code.. <?php session_start(); if(isset($_SESSION['uname2'])){ if($_POST['lesson']!=""){ if (($_FILES["Mapfile"]["type"] == "application/acrobat") ||($_FILES["Mapfile"]["type"] == "application/x-pdf") || ($_FILES["Mapfile"]["type"] == "application/pdf") || ($_FILES["Mapfile"]["type"] == "text/pdf") || ($_FILES["Mapfile"]["type"] == "application/powerpoint") || ($_FILES["Mapfile"]["type"] == "application/msword") || ($_FILES["Mapfile"]["type"] == "text/x-pdf") && ($_FILES["Mapfile"]["size"] < 50000)) { if ($_FILES["Mapfile"]["error"] > 0) { echo "Error: " . $_FILES["Mapfile"]["error"] . "<br />"; } else { if (file_exists("upload/" . $_FILES["Mapfile"]["name"])) { echo '<script type="text/javascript"> {alert("'.$_FILES["Mapfile"]["name"] .' already exist");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=uploadlesson.php">'; } else { move_uploaded_file($_FILES["Mapfile"]["tmp_name"], "upload/" . $_FILES["Mapfile"]["name"]); echo '<script type="text/javascript"> {alert("File Uploaded!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=uploadlesson.php">'; $host="localhost"; $username="root"; $password=""; $db_name="dbprof"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $user = $_SESSION['uname2']; $sql="SELECT * FROM registeredprof where Username = '$user'"; $result=mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $fullname = $row['fullname']; } $title = $_POST['lesson']; $filename = $_FILES['Mapfile']['name']; mysql_query("INSERT INTO lessondb (author, title, filename, status) VALUES ('$fullname', '$title', '$filename', 'offline')"); } } } else { echo '<script type="text/javascript"> {alert("Invalid File! ");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=uploadlesson.php">'; } } else { echo '<script type="text/javascript"> {alert("Fill out Title!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=uploadlesson.php">'; } } ?> Help pls.
  14. I've got here a code.. So basically this code is for deleting.. i want to set a Confimation popup box With yes or no.. then' When the user click yes, it will redirect to the next page. and if its a no. it would be at the same page. Here's my code. <form name="formnew" method="post" action="valdelsec.php"> <?php $host="localhost"; $username="root"; $password=""; $db_name="dbsection"; $tbl_name="sections"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); echo '<select style="position:absolute; top:307px; left:302px; width: 254px; height: 21px; font-size:10px;" name="section" onChange="this.name">'; echo "<option size =30 selected>Select</option>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<option>" .$row['Sname']. "</option>"; } echo "</select>"; } else { echo "<option>No Section Present</option></select>"; } ?> <div id="apDiv11"><input type="image" src="images/delete.png" name="Image9" width="170" height="35" border="0" ></div> </form> .. Hoping for your help.. thx!
  15. Here's the screenshot for mozilla.. [attachment deleted by admin]
  16. I think our script has a problem, here's the code.. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" href="Slider/css/style.css" type="Slider/text/css" media="screen" charset="utf-8" /> <script type="text/javascript" src="Slider/js/jquery-1.2.6.js"></script> <script type="text/javascript" src="Slider/js/startstop-slider.js"></script> <link rel="stylesheet" type="superfish/text/css" href="superfish/css/superfish.css" media="screen"> <script type="superfish/text/javascript" src="superfish/js/jquery-1.2.6.min.js"></script> <script type="superfish/text/javascript" src="superfish/js/hoverIntent.js"></script> <script type="superfish/text/javascript" src="superfish/js/superfish.js"></script> <script type="superfish/text/javascript"> jQuery(function(){ jQuery('ul.sf-menu').superfish(); }); </script> There, so basically when i run it at Chrome, the designs is at their places. But when we tested it at chrome.. Their were exploded. xD Here i attach the screen shots .. [attachment deleted by admin]
  17. Were having a problem in coding in jquery.. its working perfectly in Chrome.. pls look at my code, its not working in mozilla and i dont know why.. This is my code.. <?php session_start(); ?> <?php include('../MOWS/Connections/Config.php'); ?> <?php if (isset($_SESSION["Username"]) && isset($_SESSION["accesstype"])) { $Email = $_SESSION["Username"]; $accesstype = $_SESSION["accesstype"]; } else { $accesstype = "3"; } if ($accesstype == "3") { header('Location:../MOWS/Login/Login_Index.php'); } ?> <!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>Welcome</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" href="Slider/css/style.css" type="Slider/text/css" media="screen" charset="utf-8" /> <script type="text/javascript" src="Slider/js/jquery-1.2.6.js"></script> <script type="text/javascript" src="Slider/js/startstop-slider.js"></script> <link rel="stylesheet" type="superfish/text/css" href="superfish/css/superfish.css" media="screen"> <script type="superfish/text/javascript" src="superfish/js/jquery-1.2.6.min.js"></script> <script type="superfish/text/javascript" src="superfish/js/hoverIntent.js"></script> <script type="superfish/text/javascript" src="superfish/js/superfish.js"></script> <script type="superfish/text/javascript"> jQuery(function(){ jQuery('ul.sf-menu').superfish(); }); </script> <link rel="stylesheet" href="Navi/css/style.css" type="Navi/text/css" charset="utf-8"/> <script type="text/javascript" src="Navi/jquery-1.3.2.js"></script> <script type="text/javascript"> $(function() { var d=300; $('#navigation a').each(function(){ $(this).stop().animate({ 'marginTop':'-80px' },d+=150); }); $('#navigation > li').hover( function () { $('a',$(this)).stop().animate({ 'marginTop':'-2px' },200); }, function () { $('a',$(this)).stop().animate({ 'marginTop':'-80px' },200); } ); }); </script> <style type="text/css"> <!-- body { background-color: #000025; background-repeat: repeat-x; } .header { width:600px; height:56px; position:absolute; top:50%; left:10px; background:#fff url(title.png) no-repeat center; } a.back{ width:256px; height:73px; position:absolute; bottom:15px; right:15px; background:#fff url(codrops_back.png) no-repeat center; } a.dry{ position:absolute; bottom:15px; left:15px; text-align:left; font-size:12px; color:#ccc; text-transform:uppercase; text-decoration:none; } --> </style> <link href="Slider/CSS/layout.css" rel="stylesheet" type="text/css" /> <link href="/MOWS/MOWS/CSS/layout.css" rel="stylesheet" type="text/css" /> <style type="text/css"> a:link { color: #FFF; } a:visited { color: #FFF; } a:hover { color: #000; } a:active { color: #999; } </style> </head> <body> <div class="header"> <p align="right"><a href="/MOWS/MOWS/Login/Login_Logout.php">Logout</a></p> </div> <div class="content" id="page-wrap"> <div align="center"> <ul class="sf-menu"> <li> <a href="../MOWS/Pagecheck/homecheck.php">Home</a> </li> <li class="current"> <ul> <li> <a href="#aa">Mabalacat</a> </li> <li class="current"> <a href="#ab">Officials</a> </li> </ul> </li> <li> <a href="../MOWS/Pagecheck/departmentcheck.php">Deparment</a> </li> <li> <a href="../MOWS/Pagecheck/officialcheck.php">Officials</a> </li> </li> <li> <a href="../MOWS/Pagecheck/locationcheck.php">Locations</a> </li> <li> <a href="../MOWS/Pagecheck/announcementcheck.php">Announcement</a> </li> <li> <a href="../MOWS/Pagecheck/eventscheck.php">Event</a> </li> <li> <a href="../MOWS/Pagecheck/hotlinescheck.php">Hot Lines</a> </li> <li> <a href="../MOWS/Pagecheck/aboutuscheck.php">About us</a> </li> </ul> <br> </div> <div id="slider"> <div id="mover"> <div id="slide-1" class="slide"> <h1>MABALACAT Municipality </h1> <p> Mabalacat is a 1st Class Municipality vying to become the second component city of the Province of Pampanga. Mabalacat became a town in the year 1712. It was named after the Balacat tree (Zyzyphus Zonulata Blco.), which is a forth class timber. The word Mabalacat means "full of balacat". <a href="#"><img src="/MOWS/MOWS/images Slider/51520492.jpg" width="240" height="159" alt="Read More" /></a> </p> </div> <div class="slide"> <h1>Mayor Marino "Boking"<br> Morales</h1> <p>Donec gravida posuere arcu. Nulla facilisi. Phasellus imperdiet. Vestibulum at metus. Integer euismod. Nullam placerat rhoncus sapien. Ut euismod. Praesent libero. Morbi pellentesque libero sit amet ante. Maecenas tellus.</p> <a href="#"><img src="images Slider/boking.jpg" alt="learn more" width="227" height="130" /></a> </div> </div> </div> <table width="758" height="347" border="0"> <tr> <td width="41" height="343" bgcolor="#FFFFFF"> </td> <td width="351" bgcolor="#FFFFFF"><table width="355" height="159" border="0"> <tr> <td width="171" height="155" class="insidebgSmall"><table width="171" height="138" border="0"> <tr> <td width="165" height="22" class="Header_content">Job seach</td> </tr> <tr> <td height="86"><a href="../MOWS/Pagecheck/jobsearchcheck.php"><img src="images/jobsearch.png" width="165" height="86" alt="jobsearch_pic" /></a></td> </tr> </table></td> <td width="171" class="insidebgSmall"><table width="171" height="138" border="0"> <tr> <td width="165" height="22">HotSpots</td> </tr> <tr> <td height="86"><a href="hotspot(view).html"><img src="images/hotspot.png" width="165" height="86" /></a></td> </tr> </table></td> </tr> </table> <table width="350" height="144" border="0"> <tr> <td height="22" class="insidebgLarge">Announcements</td> </tr> <tr> <td class="Text_content"><div> <hr /> <?php $con = mysql_connect("localhost","root",""); mysql_select_db("mab_db", $con); $flag=1; $switch=1; $result=(mysql_query("select * from announcements_tbl ORDER BY Announcements_num DESC")); while($row=mysql_fetch_array($result)) { if($flag <= 5) { if ($switch == 1) { $switch = 2; ?> <div> <?php } else { $switch = 1; ?> <div> <?php } echo " $row[Announcements_name] <br> $row[Announcements_date] <br> $row[Announcements_from] <br> $row[Announcements_loc] <br> $row[Announcements_Desc] <br>"; ?> <hr /> </div> <?php $flag ++; } else { break; } } ?> </div> </td> </tr> </table></td> <td width="352" bgcolor="#FFFFFF"><table width="347" height="332" border="0"> <tr> <td height="226" class="insidebgLarge"><table width="339" height="329" border="0"> <tr> <td height="22">Events</td> </tr> <tr> <td height="157" class="Text_content"> <div> <hr /> <p> <?php $con = mysql_connect("localhost","root",""); mysql_select_db("mab_db", $con); $flag=1; $switch=1; $result=(mysql_query("select * from events_tbl ORDER BY Events_Num DESC")); while($row=mysql_fetch_array($result)) { if($flag <= 5) { if ($switch == 1) { $switch = 2; ?> </p> <div> <?php } else { $switch = 1; ?> <div> <?php } echo " $row[Events_Title] <br> $row[Events_Date] <br> $row[Events_loc] <br> $row[Events_desc] <br><br>"; ?> <hr /> </div> <?php $flag ++; } else { break; } } ?> </div></td> </tr> </table></td> </tr> </table></td> </tr> </table> <table width="759" border="0"> <tr> <td width="753" bgcolor="#FFFFFF"> </td> </tr> </table> <table width="761" height="143" border="0"> <tr> <td width="34" bgcolor="#FFFFFF"> </td> <td width="717" bgcolor="#FFFFFF"><table width="709" height="137" border="0"> <tr> <td width="348"><table width="356" height="138" border="0"> <tr> <td width="165" height="22" class="insidebg">HotLines</td> <td width="174" height="22" class="insidebg">Other Related links</td> </tr> <tr> <td height="86" class="insidebgSmall"><a href="Hotlines.html"><img src="images/hot lines.png" alt="" width="165" height="86" /></a></td> <td height="86"><img src="images/Otherlinks.png" width="165" height="86" /> <td width="10"> </tr> </table></td> <td width="351"><table width="345" height="132" border="0"> <tr> <td height="22" class="insidebg">Photos</td> <td class="insidebg">videos</td> </tr> <tr> <td> </td> <td> </td> </tr> </table></td> </tr> </table></td> </tr> </table> </div> </div> </div> </body>
  18. Yea thx for that! i noticed that too.. so i edited it. and replace $appr = 0; $reje = 0; TO $appr = 1; $reje = 1; Because when user checked 1 values.. a blank page will show. Hey! thx a lot for the help..
  19. I've made a code here.. It can create a quiz. It consist of a question and a 4 choices.. But my problem here is. when i inserted only 2 values for the choices, there would still be 4 radio button(Choices). Can someone help me. i want my code to be like : When user inputs 4 values. there would be 4 choices, but when user insert 2 values, there would be 2 values.. Here's my code for the form <form name="formupload" method="post" action="setdate.php"> <div id="apDiv10"><input type="image" src="images/setdate.png" name="Image9" width="170" height="35" border="0" ></div> </form><form name="formupload" method="post" action="valdeactiveass.php"> <div id="apDiv8"><input type="image" src="images/deacass.png" name="Image9" width="170" height="35" border="0" ></div> </form><form name="formupload" method="post" action="valactiveass.php"> <div id="apDiv7"><input type="image" src="images/activeass.png" name="Image9" width="170" height="35" border="0" ></div> </form><form name="formupload" method="post" action="quiz_preview.php"> <div id="apDiv3"><input type="image" src="images/preview.png" name="Image9" width="170" height="35" border="0" ></div> </form> <form name="form2" method="post" action="delques.php"> <div id="apDiv9"><input type="image" src="images/delques.png" name="Image8" width="170" height="35" border="0" ></div> </form><form name="formupload" method="post" action="validatequiz.php"> <input type="text" style="position:absolute; top:160px; left:101px; width: 576px; height: 31px; font-size:10px;" name="question" id="question" /> <input type="text" style="position:absolute; top:244px; left:109px; width: 567px; height: 19px; font-size:10px;" name="c1" id="c1" /> <input type="text" style="position:absolute; top:297px; left:108px; width: 567px; height: 19px; font-size:10px;" name="c2" id="c2" /> <input type="text" style="position:absolute; top:350px; left:109px; width: 567px; height: 19px; font-size:10px;" name="c3" id="c3" /><input type="text" style="position:absolute; top:396px; left:110px; width: 567px; height: 19px; font-size:10px;" name="c4" id="c4" /> <select style="position:absolute; top:463px; left:309px; width: 80px; height: 23px; font-size:10px;" name="answer" id="answer"> <option value="Select">Select</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select><div id="apDiv2"><input type="image" src="images/submit.png" name="Image8" width="170" height="35" border="0" ></div> </form> And this of the quiz maker.. <?php if (isset($_POST['sent'])) { for ($i=0;$i<count($questions);$i++) { if ($_POST['q2'.$i]=="w") { $score++; } else { } } $percent = number_format(($score/count($questions))*100,2,".",","); echo("<br>".$score." out of ".count($questions)." (".$percent."% right)<br>\n"); } else { echo("<form action=\"#\" method=\"post\">\n"); echo("<input type=\"hidden\" name=\"sent\">\n"); for ($i=0;$i<count($questions);$i++) { echo("<b>".$questions[$i][0]."</b><br><br>\n"); if ($questions[$i][5]==1) { echo("<input type=\"radio\" name=\"q2".$i."\" value=\"c\"> ".$questions[$i][1]."<br>\n"); } else { echo("<input type=\"radio\" name=\"q2".$i."\" value=\"w\"> ".$questions[$i][1]."<br>\n"); } if ($questions[$i][5]==2) { echo("<input type=\"radio\" name=\"q2".$i."\" value=\"c\"> ".$questions[$i][2]."<br>\n"); } else { echo("<input type=\"radio\" name=\"q2".$i."\" value=\"w\"> ".$questions[$i][2]."<br>\n"); } if ($questions[$i][5]==3) { echo("<input type=\"radio\" name=\"q2".$i."\" value=\"c\"> ".$questions[$i][3]."<br>\n"); } else { echo("<input type=\"radio\" name=\"q2".$i."\" value=\"w\"> ".$questions[$i][3]."<br>\n"); } if ($questions[$i][5]==4) { echo("<input type=\"radio\" name=\"q2".$i."\" value=\"c\"> ".$questions[$i][4]."<br><br>\n"); } else { echo("<input type=\"radio\" name=\"q2".$i."\" value=\"w\"> ".$questions[$i][4]."<br><br>\n"); } } echo("<input type=\"submit\" value=\"Submit Exam\"></form>"); } ?>
  20. Hey! thx a lot for helping Really appreciate it a lot.. I found what's wrong with my code.. I edited it and its working' xD.. srry for that.. but i was still studying php.. so i dont know yet the best method of what to use. so i just write what i know. but anyway. its fixed! thx for the help
  21. Because i use PHP for this.. anyway this is the whole code. <?php session_start(); if(isset($_SESSION['uname2']) || ($_SESSION['section'])){ $con = mysql_connect("localhost","root",""); if(isset($_POST['approve_x'], $_POST['approve_y'])) { mysql_select_db("dbreg", $con); foreach ($_POST['list'] as $checkbox) { $sql="SELECT * FROM account WHERE Username='$checkbox'"; $result=mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $username = $row['Username']; $password = $row['Password']; $gname = $row['gname']; $mname = $row['mname']; $famname = $row['famname']; $sec = $row['sec']; $studnum = $row['studnum']; $fullname = $row['fullname']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $gname = stripslashes($gname); $famname = stripslashes($famname); $gname = mysql_real_escape_string($gname); $famname = mysql_real_escape_string($famname); $mname = stripslashes($mname); $mname = mysql_real_escape_string($mname); mysql_query("INSERT INTO dbaccount (Username, Password,gname,famname,mname,sec,studnum,fullname) VALUES ('$checkbox', '$password', '$gname', '$famname', '$mname', '$sec', '$studnum', '$fullname')") or die(mysql_error); mysql_query("DELETE FROM account WHERE Username='$checkbox'") or die(mysql_error); echo '<script type="text/javascript"> {alert("Approved!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } } } elseif(isset($_POST['reject_x'], $_POST['reject'])) { mysql_select_db("dbreg", $con); foreach ($_POST['list'] as $checkbox) { $sql="SELECT * FROM account WHERE Username='$checkbox'"; $result=mysql_query($sql); if(mysql_num_rows($result)) { mysql_query("DELETE FROM account WHERE Username='$checkbox'") or die(mysql_error); echo '<script type="text/javascript"> {alert("Rejected!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } } } else { header("location:failunautho.php");; } } ?>
  22. Im having a problem in popup box.. i made a checkbox in a loop.. then after a success loop ive set a code for a popupbox. echo '<script type="text/javascript"> {alert("Rejected!");} </script>'; But when a user checked 2 check boxes.. it would also popup a 2 popup box.. How can i make my code only popup once even if it selects multiple checkboxes?
  23. hmm thx for the kind reply guys. .. the reason why i want to have a checkbox of multiple value because.. i want to have a form with a checkbox that reflects values on database.. then when a checkbox is checked then the checked values will be place again in the database in a different table.. so i used INSERT INTO for that.. Here look at my code. hope you could gelp me. <?php <form name="formapprove" method="POST" action="valval3.php" > <div id="apDiv12"><input type="image" src="images/Approve.png" name="approve" value="approve" width="170" height="35" border="0" > </div> <div id="apDiv11"> <input type="image" src="images/reject.png" name="reject" width="170" height="35" border="0" value="reject"> </div> <div id="apDiv14">'; $host="localhost"; $username="root"; $password=""; $db_name="dbreg"; $tbl_name="account"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); echo "<table border=\"5\" width=\"400\" >"; echo "<tr><th>List of Student to be approve</th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "<input type='checkbox' name='list[]' value='".$row['Username']."'>".$row['famname'].",".$row['gname']. ",".$row['mname']. ".<br/></td>"; echo "</tr></input>"; } } else { echo "<tr><td align=\"center\"> No Student to be Approve / Reject </td></tr>"; } </form> ?> Then the values will be passed to "valval3.php" and here's my code.. <?php session_start(); if(isset($_SESSION['uname2']) || ($_SESSION['section'])){ $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } if(isset($_POST['approve_x'], $_POST['approve_y'])) { mysql_select_db("dbreg", $con); $uname = $_SESSION['uname2']; $sec = $_SESSION['section']; $sql="SELECT * FROM account where sec='$sec'"; $result=mysql_query($sql); if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $fullname = "" .$row['famname']. ", " .$row['gname']. " " .$row['mname']. "."; } foreach ($_POST['list'] as $checkbox) { $sql="SELECT * FROM account WHERE sec='$sec'"; } $result=mysql_query($sql); if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $username = $row['Username']; $password = $row['Password']; $gname = $row['gname']; $mname = $row['mname']; $famname = $row['famname']; $sec = $row['sec']; $studnum = $row['studnum']; $fullname = "" .$row['famname']. ", " .$row['gname']. " " .$row['mname']. "."; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $gname = stripslashes($gname); $famname = stripslashes($famname); $gname = mysql_real_escape_string($gname); $famname = mysql_real_escape_string($famname); $mname = stripslashes($mname); $mname = mysql_real_escape_string($mname); foreach ($_POST['list'] as $checkbox) { mysql_query("INSERT INTO dbaccount (Username, Password, gname, famname, mname, sec, studnum, fullname) VALUES ('$username', '$password', '$gname', '$famname', '$mname', '$sec', '$studnum', '$checkbox')") or die(mysql_error); mysql_query("DELETE FROM account WHERE sec='$sec'") or die(mysql_error); } echo '<script type="text/javascript"> {alert("Approved!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; mysql_close($con); } } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } }elseif(isset($_POST['reject_x'], $_POST['reject'])) { mysql_select_db("dbreg", $con); foreach ($_POST['list'] as $checkbox) { $sql="SELECT * FROM account WHERE sec='$sec'"; } $result=mysql_query($sql); if(mysql_num_rows($result)) { foreach ($_POST['list'] as $checkbox) { mysql_query("DELETE FROM account WHERE sec='$sec'") or die(mysql_error); } echo '<script type="text/javascript"> {alert("Rejected!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } } } else { header("location:failunautho.php");; } ?> So basically.. when there's only one checked values' it will be successful.. but when you checked two values.. The values inserted in the database will be the same(even if you input different values). except for the username.. cause i put a value on the checked box..
  24. Is is possible to give multiple values in a single checkbox? i need to have a checkbox that holds multiple values. Help Anyone..
  25. Hi, i mange to solve my problem.. Thx everyone for the reply.. Anyway, this is how i done it. I tried to use the GET method and i notice there are 2 variable outputted. so i return it to POST and made this code if(isset($_POST['approve_x'], $_POST['approve_y'])) { Instead of switch.. hmm idk why.. but i think old browser like mozilla and IE doesnt have that automatic catch for variables? xD.. but anyway. THX AGAIN!
×
×
  • 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.