Jump to content

june_c21

Members
  • Posts

    280
  • Joined

  • Last visited

    Never

Everything posted by june_c21

  1. i want to stop enter the row into database when user didn't input anything. How to do so? For example, there is 8 rows, if user enter 5 rows. it will store 5 rows in the database only. mrdamien, sorry. but your code didn't work.
  2. Please help me with this!!! thanks in advance
  3. i try to run this code but the result is INSERT INTO list (name,age) VALUES ('', '') how to make it insert to the database?? my html code <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Name</title> </head> <body> <form method="POST" action="index2.php"> <!--webbot bot="SaveResults" U-File="C:\wamp\www\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" --> <table border="1" width="100%"> <tr> <td>Name</td> <td>Age</td> </tr> <tr> <td><input type="text" name="name1" size="20"></td> <td><input type="text" name="age1" size="20"></td> </tr> <tr> <td><input type="text" name="name2" size="20"></td> <td><input type="text" name="age2" size="20"></td> </tr> <tr> <td><input type="text" name="name3" size="20"></td> <td><input type="text" name="age3" size="20"></td> </tr> <tr> <td><input type="text" name="name4" size="20"></td> <td><input type="text" name="age4" size="20"></td> </tr> <tr> <td><input type="text" name="name5" size="20"></td> <td><input type="text" name="age5" size="20"></td> </tr> <tr> <td><input type="text" name="name6" size="20"></td> <td><input type="text" name="age6" size="20"></td> </tr> <tr> <td><input type="text" name="name7" size="20"></td> <td><input type="text" name="age7" size="20"></td> </tr> </table> <p> </p> <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form> </body> </html> <?php session_start(); $host = 'localhost'; $user = 'root'; $password = ''; $dbase = 'project'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $name = $_POST['name']; $age = $_POST['age']; if (strlen('$name')> 0 ){ $query= "INSERT INTO list (name,age) VALUES ('$name', '$age')"; echo $query; $result = mysql_query($query,$dblink); } ?> please help me. i m new with this. thanks
  4. WHy my code can't loop when name = empty . what should i put in the while statement? <?php session_start(); $host = 'localhost'; $user = 'root'; $password = ''; $dbase = 'project'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $sname = $_POST['name']; $age = $_POST['age']; While ($name=NULL){ $query= "INSERT INTO list(name,age) VALUES ('$name', '$age')"; $result = mysql_query($query,$dblink); } ?>
  5. i still facing the same problem error : Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\example.php on line 19 $query= "INSERT INTO report (name),(name),(name),(name),(name) VALUES ('$b[]'),('$b1[]'),('$b2[]'),('$b3[]'),('$b4[]')";
  6. i trying to insert data into multiple rows. when i run the code i got this error when run this code " Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\example.php on line 18 " please help. thanks in advance Html code <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action="example.php"> <label></label> <p> <label></label> Name <label></label> </p> <table width="200" border="1"> <tr> <td><input type="text" name="b[]" /></td> </tr> <tr> <td><input type="text" name="b1[]" /></td> </tr> <tr> <td><input type="text" name="b2[]" /></td> </tr> <tr> <td><input type="text" name="b3[]" /></td> </tr> <tr> <td><input type="text" name="b4[]" /></td> </tr> </table> <p> <label></label> </p> <p> <label></label> </p> <p> <label> <input type="submit" name="Submit" value="Submit" /> </label> </p> </form> </body> </html> php code <?php $host = 'localhost'; $user = 'root'; $password = ''; $dbase = 'example'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $b[] = $_POST['name']; /*$b1[] = $_POST['name']; $b2[] = $_POST['name']; $b3[] = $_POST['name']; */ # Create the query $query = "INSERT INTO report (name) VALUES('$b[]')"; # Add each text box value to the query foreach($_POST['myTextboxArray'] as $text) { $query .= " ('". addslashes($text) ."'),"; } # Remove the last comma from the query $query[strlen($query)-1] = ""; ?>
  7. how to write that code? do you have any idea?
  8. Hi, i wrote a code that extract real time data and put it in the website . the problem is how to show the latest real time value without refreshing the page?
  9. ya, i am using mysql 5 $query = "SELECT staff_no, eventdate,event FROM calendars "; $result1 = mysqli_query($query, $dblink); while { } i don't know how to write the code in the while loop where it will output the event according to dd,mm,yyyy and link with the calendar i created.
  10. i just made an event calendar where user can input their event and store in database. i am stuck with these select statement where i need to pull the data from the database and show it accoring to the date,month,year in the calendar. $query = "SELECT staff_no, eventdate,event FROM calendars "; $result1 = mysql_query($query, $dblink); while { }
  11. i want user to input staff no, date and event. after click on submit, it will show in the calendar that on the same date there is an event. user can then click to see the details. how to do that? thanks
  12. try this php code <?php $host = "localhost"; $user = "root"; $password = ""; $dbase = "guestbook"; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $query = "INSERT INTO guestbook_example (name, comment) VALUES ('$name','$comment')"; $result1 = mysql_query($query, $dblink); ?> html code <form name="form1" method="post" action=""> <p>Name <input type="text" name="name"> </p> <p>Comment <label> <input type="text" name="comment"> </label> </p> </form>
  13. http://www.devarticles.com/c/a/MySQL/Creating-a-Voting-Poll-With-PHP-And-MySQL-Part-1/ try to read this . hopefully it can help you .
  14. $x = 1; $y = 12; for( $i = $x; $i <= $y; $i++ ) change to for( $i = 0; $i <= 12; $i++ )
  15. kindly help me with this. thanks
  16. hi, i had made this event calendar but the problem is how to link the date (user input) to the calendar table. So when user click on the date, it will list down the event. here is my code <?php $host = 'localhost'; $user = 'root'; $password = ''; $dbase = 'calendars'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $m = (!$m) ? date("m",mktime()) : "$m"; $y = (!$y) ? date("Y",mktime()) : "$y"; if ($_SERVER['REQUEST_METHOD'] == "POST") { $eventdate = $_POST['eventdate']; $event = $_POST['event']; $staff_no = $_POST['staff_no']; $query= "INSERT INTO calendars( event,eventdate,staff_no) VALUES ('$event','$eventdate','$staff_no') "; $result = mysql_query($query,$dblink); echo "<br />"; echo "<h2>Staff Attendance</h2>"; // echo "This is a demo. We are not saving the event to the calendar, but you could.<br /><br />"; // echo "We are demo-ing building the calendar, and interacting with it.<br /><br />"; echo "<b>Staff No : </b> $staff_no </br>"; echo "<b>Event:</b> $event<br />"; echo "<b>Date:</b> $eventdate<br />"; echo "</br>"; echo "</br>"; echo "<a href =calendar.php> Home </a>"; exit(); } ?> <html> <head> <title>Staff Attendance</title> </head> <body bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC"> <h2>KEV Staff Attendance</h2> <blockquote> <table> <tr> <td valign="top"><?php mk_drawCalendar($_GET['m'],$_GET['y']); ?></td> <td width="25" nowrap><br /></td> <form name="f" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table cellpadding="0" cellspacing="0" border="0" bgcolor="#000000"><tr><td> <table cellpadding="4" cellspacing="1" border="0 "bgcolor="#FFFFFF"> <tr><td colspan="2" bgcolor="#000000"><font size="+1" color="#FFFFFF"><b>Add New Event</b></font></td></tr> <tr><td><b>Staff No :</b></td><td><input type="text" name="staff_no" size="10" maxlength="10"></td></tr> <tr><td><b>Event Date: </b></td><td><input type="text" name="eventdate" value="" size="12"> <font size="2">mm/dd/yyyy</font></td></tr> <tr><td><b>Event:</b></td><td><input type="text" name="event" size="35" maxlength="128"></td></tr> <tr><td colspan="2" align="center" bgcolor="#CCCCCC"><input type="submit" value="Add Event"></td></tr> </table></td></tr></table></form> </td> </tr></table> </blockquote> </body> </html> <?php //********************************************************* // DRAW CALENDAR //********************************************************* /* Draws out a calendar (in html) of the month/year passed to it date passed in format mm-dd-yyyy */ function mk_drawCalendar($m,$y) { if ((!$m) || (!$y)) { $m = date("m",mktime()); $y = date("Y",mktime()); } /*== get what weekday the first is on ==*/ $tmpd = getdate(mktime(0,0,0,$m,1,$y)); $month = $tmpd["month"]; $firstwday= $tmpd["wday"]; $lastday = mk_getLastDayofMonth($m,$y); ?> <table cellpadding="2" cellspacing="0" border="1"> <tr><td colspan="7" bgcolor="#CCCCDD"> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr><th width="20"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m-1)<1) ? 12 : $m-1 ?>&y=<?=(($m-1)<1) ? $y-1 : $y ?>"><<</a></th> <th><font size=2 ><?="$month $y"?></font></th> <th width="20"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>">>></a></th> </tr></table> </td></tr> <tr><th width=22 class="tcell">Sun</th><th width=22 class="tcell">Mon</th> <th width=22 class="tcell">Tues </th><th width=22 class="tcell">Wed</th> <th width=22 class="tcell">Thrus</th><th width=22 class="tcell">Fri</th> <th width=22 class="tcell">Sat</th></tr> <?php $d = 1; $wday = $firstwday; $firstweek = true; /*== loop through all the days of the month ==*/ while ( $d <= $lastday) { /*== set up blank days for first week ==*/ if ($firstweek) { echo "<tr>"; for ($i=1; $i<=$firstwday; $i++) { echo "<td><font size=2> </font></td>"; } $firstweek = false; } /*== Sunday start week with <tr> ==*/ if ($wday==0) { echo "<tr>"; } /*== check for event ==*/ echo "<td class='tcell'>"; echo "<a href=\"#\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>"; echo "</td>\n"; /*== Saturday end week with </tr> ==*/ if ($wday==6) { echo "</tr>\n"; } $wday++; $wday = $wday % 7; $d++; } ?> </tr></table> Click on a date to select it and to populate the event date field on the bottom <br /> <?php /*== end drawCalendar function ==*/ } /*== get the last day of the month ==*/ function mk_getLastDayofMonth($mon,$year) { for ($tday=28; $tday <= 31; $tday++) { $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); if ($tdate["mon"] != $mon) { break; } } $tday--; return $tday; } ?>
  17. this might help http://www.roscripts.com/AJAX_PHP_rating_script-145.html
  18. i am using joomla. any particular things you would like to know? the code is not so complex once u understand it.
  19. SOLVED !! Thanks l0ve2hat3
  20. SELECT title FROM drawings WHERE gf='gf1' LIKE'%oko%' . it display all the data. how to write a query where gf=gf1 && text='user input' ?
  21. i got error when i run this lines of code. mysql_fetch_array(): supplied argument is not a valid MySQL result mysql_num_rows(): supplied argument is not a valid MySQL result $data = mysql_query("SELECT title FROM drawings WHERE upper($field) LIKE'%$find%'"); echo "<table border=3 align=center width=100%>"; while($result = mysql_fetch_array( $data )) //And we display the results { echo "<tr><td align=center>" . $myrow1[0] . "</td></tr>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches =mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; }
  22. hi, i got problem when i click on the option value in 1st drop down, the 2nd drop down menu didn't appear. Anything wrong in my php code ? html code <html> <head> <title>My Page</title> <script type="text/javascript"> // SharpAJAX initialization // Create AJAX object based on browser if (navigator.appName == "Microsoft Internet Explorer") { sharpajax = new ActiveXObject("Microsoft.XMLHTTP"); } else { sharpajax = new XMLHttpRequest(); } // Initialize sharpajax.abort(); </script> <script type="text/javascript"> // My Function function filter(value) { // Resets state sharpajax.abort(); // Send command sharpajax.open("GET","filter.php?filter="+value); // Create input trapping function sharpajax.onreadystatechange=function() { if (sharpajax.readyState == 4) { eval(sharpajax.responseText); } } // Send output sharpajax.send(""); } </script> <script type="text/javascript"> function createDropdown(container, id) { document.getElementById(container).innerHTML = ''+ '<select name="'+id+'" id="'+id+'">'+ '</select>'; } function addDropdownItem(container, value, caption) { document.getElementById(container).innerHTML = ''+ document.getElementById(container).innerHTML + '<option value="'+value+'">'+caption+'</option>'; } </script> </head> <body> <div id="filters_1"> <select name="filter1" id="filter1" onChange="javascript:filter(this.value);"> <option value="name">Name</option> <option value="birthdate">Birthdate</option> </select> </div> <div id="filters_2"></div> </body> </html> php code <?php $myfilter = $_GET['filter']; // SQL query statements goes here $host = 'localhost'; $user = 'root'; $password = ''; $dbase = 'drawing'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $filters_2 = $_POST['title']; $query = "SELECT title FROM drawings "; $result1 = mysql_query($query, $dblink); while($myrow1 = mysql_fetch_row($result1)) { printf("createDropdown('filters_2','filter_2');"); printf("addDropdownItem('filter_2','filtervalue',' filtercaption'"); } ?>
×
×
  • 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.