PHP - Php Script For Datepicker To Slect And Diaplay Database From Mysql Required
After spending 3 days on internet and struggling with so many different forums , i have found this forum where i believe i will get the solution for my problem.
Friends, I am zero in PHP, but still i have managed to do something to fulfill my requirement. I am stuck with one thing now..So i need help on.... I am using one html+php form to submit database into mysql. I created a display of that table through php script on a webpage. Now i want a datepicker option on that displayed page by which i should able to select the date range and display the data of that date range from my mysql table. And then take a export of data displayed of selected date range in excel. This displayed page is login protected, so i want after login the next thing comes in should show a sate selection option which should be fromdate to to date , and then records should displayed from the database and i can take export of those displayed results in excel file. The code i am using on this page is below which do not have any thing included for excel export and datepicker script, I am pasting the code here and request you to please include the required code in it as required. Thanks In advance <?php //database connections $db_host = 'localhost'; $db_user = '***********'; $db_pwd = '*************'; $database = 'qserves1_uksurvey'; $table = 'forms'; $file = 'export'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("SELECT * FROM {$table} ORDER BY date desc"); if (!$result) { die("Query to show fields from table failed"); } $num_rows = mysql_num_rows($result); $fields_num = mysql_num_fields($result); echo "$num_rows"; echo "<h1></h1>"; echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?> </body></html> Similar TutorialsCan we create a backup of database entered data in PHPMYADMIN? As you know if we are using locally any database through php then in case of system crash or the like our all the enterred saved data in the database will gonna be lost i want to know that is it possible to create a back up for our saved data in the database and if is it possible then how can we do it???? I am trying to create a simple calendar where a user can add/remove their availability date. This part works so far. Now what I am having trouble with is highlighting the already selected dates that are fetched from a MySQL database.
Here's my code. // HTML <div id="datetimepicker1"></div> // Jquery/Ajax <script> $(document).ready(function () { $('#datetimepicker1').datepicker({ dateFormat: "yy-mm-dd", multidate: true, onSelect: function () { var getDate = $("#datetimepicker1").val(); $.ajax({ type: "POST", //or GET. Whichever floats your boat. url: "snippets/adapter-set.php", data: { date: getDate }, success: function(data) { // alert(data); }, error: function() { alert("Error."); } }); } }); }); </script> // PHP // adapter-set.php $post_date = $_POST['date']; $find_query = $db->prepare("SELECT user_id FROM user_dates WHERE date_available = :date_available"); $find_query->bindParam(':date_available', $post_date); $find_query->execute(); $result_find = $find_query->fetchAll(PDO::FETCH_ASSOC); if(count($result_find) > 0) { foreach($result_find as $row) { $user_id = $row['user_id']; } $delete_query = $db->prepare("DELETE FROM user_dates WHERE user_id = :user_id"); $delete_query->bindParam(':user_id', $user_id); $delete_query->execute(); $result_delete = $delete_query->execute(); if($result_delete == false) { echo 'delete false'; } else { echo 'delete success'; } } else { $insert_query = $db->prepare("INSERT INTO user_dates(date_available) VALUES(:date_available)"); $insert_query->bindParam(':date_available', $post_date); $result_insert = $insert_query->execute(); if($result_insert == false) { echo 'insert false'; } else { echo 'insert success'; } }
The above code works fine. It inserts and deletes a date row in MySQL database table based on a click. Now what I would like to do is to highlight all the "available" dates that are already inserted into the database; so that the user knows which dates he has already selected. This is my code for that. But it doesn't seem to be working. No errors. It's just not highlighting the inserted dates. Can you tell me what I'm doing wrong? // JQUERY <script> $(document).ready(function() { $.post('snippets/adapter-fetch.php', {}, function(data){ $("#datetimepicker1").datepicker({ datesEnabled : data.datesEnabled }); }, 'json'); }); </script> // PHP // adapter-fetch.php $global_user_id = 5; $find_query = $db->prepare("SELECT date_available FROM user_dates WHERE user_id = :user_id"); $find_query->bindParam(':user_id', $global_user_id); $find_query->execute(); $result_find = $find_query->fetchAll(PDO::FETCH_ASSOC); if(count($result_find) > 0) { foreach($result_find as $row) { $date_available = $row['date_available']; echo $date_available; } } else { echo 'not dates available'; }
Hi, Im just in the middle of creating an update script for my mysql database but don't know why it's not working. p.s. I'm a little new to PHP, but know quite a bit, it's probably something really small.. *facepalm* Here's the script: the form (update.php) <? // Connect to the database $link = mysql_connect('###', '###', '###'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('###', $link); $id = $_GET['id']; // Ask the database for the information from the links table $query="SELECT * FROM orders WHERE id='$id'"; $result = mysql_query("SELECT * FROM orders"); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $name=mysql_result($result,$i,"Name"); $location=mysql_result($result,$i,"Location"); $fault=mysql_result($result,$i,"Fault"); ?> <form action="updated.php" method="post"> <input type="hidden" name="ud_id" value="<? echo "$id";?>"> Name: <input type="text" name="ud_name" value="<? echo "$name"?>"><br> Location: <input type="text" name="ud_location" value="<? echo "$location"?>"><br> Fault: <input type="text" name="ud_fault" value="<? echo "$fault"?>"><br> <input type="Submit" value="Update"> </form> <? ++$i; } ?> ------------------------------------------------------ (processor) updated.php <?php // Connect to the database $link = mysql_connect('###', '###', '###'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('###', $link); $query="UPDATE orders SET Name='" . $_POST['ud_name'] . "', Location='" . $_POST['ud_location'] . "', Fault='" . $_POST['ud_fault'] . "' WHERE $id='" . $_POST['ud_id'] . "'"; echo $query; $checkresult = mysql_query($query); if ($checkresult) echo '<p>update query succeeded'; else echo '<p>update query failed'; mysql_close(); ?> ------------------------------------------------------ Every time I want to update, it comes up with: UPDATE orders SET Name='TEST', Location='TEST', fault='jbjh' WHERE ='' update query failed Any help would be appreciated. $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; $date = date("Y-m-d", time(0,0,0,$month, $day, $year)); $sql="INSERT INTO child_info (first_name,middle_name,first_family_name,second_family_name, gender,birthdate,mother_living,father_living,brothers,sisters,resident_time,dorm,school,grade_level,school_subject,speak_english,food,medical_allergies,physical_limits,future,instrument,work,social,special_people,hobby,sponsor) VALUES ('$_POST[first_name]','$_POST[middle_name]','$_POST[first_family_name]','$_POST[second_family_name]','$_POST[gender]','$_POST[date]','$_POST[mother_living]','$_POST[father_living]','$_POST[brothers]','$_POST[sisters]','$_POST[resident_time]','$_POST[dorm]','$_POST[school]','$_POST[grade_level]','$_POST[school_subject]','$_POST[speak_english]','$_POST[food]','$_POST[medical_allergies]','$_POST[physical_limits]','$_POST[future]','$_POST[instrument]','$_POST[work]','$_POST[social]','$_POST[special_people]','$_POST[hobby]','$_POST[sponsor]')"; Hi I don't know exactly what to do to see correct date of birth into my sql database. I have following code i.e. $month=$_POST['month']; $year=$_POST['year']; $date=$_POST['date']; $date_value="$month/$date/$year"; echo"YYYY-mm-dd format:$date_value"; and sql insert statement is like this $sql = "INSERT INTO table_name(fname, lname, gender, add1, add2, city, state, zip, country, email, phone, cellphone, dob, photo1) VALUES('$fname','$lname','$gender','$add1','$add2','$city','$state','$zip','$country','$email','$phone','$cellphone', '$date_value','" . $image['name'] . "')"; I don't know what exactly I need to do? Even though I changed the setting in php ini to register_globals = On I would appreciate any kind of help regarding this matter. Thanks Smita Hi, this is my first post:) pretty sure i will be posting here in the future. Anyway i am having trouble with a php script which downloads a file from a mysql database. This php script works for text files and should work for most files from what i understand. When downloading a text file, the whole file is downloaded from the server. When downloading an mp3 file, only 16kb are downloaded and the file does not play. When looking at the data in the database, it displays that the full file is there (correct amount of bytes, so there is nothing wrong with my upload php script). Does anyone have any suggestions as to what I can change to make this work? Code: [Select] <?php if(isset($_GET['id'])) { // if id is set then get the file with the id from database $link=mysql_connect('localhost', 'root', ''); @mysql_select_db('filemgr') or die ("<p>Could not connect to mysql!</p>"); $id = $_GET['id']; $query = "SELECT name, type, size, content " . "FROM upload WHERE id = '$id'"; $result = mysql_query($query) or die('Error, query failed'); list($name, $type, $size, $content) = mysql_fetch_array($result); header("Content-length: $size"); header("Content-type:$type"); header("Content-Disposition: attachment; filename=$name"); echo $content; mysql_close($link); exit; } ?> Hi there, I am using this code to send the users email address to the database. That works fine, but i keep getting blank info added to the database. Does anyone know how i can stop this? <?php $con = mysql_connect("*","*","*"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ogs_mailinglist1", $con); $sql="INSERT INTO mailinglist (email) VALUES ('$_POST[rec_email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?> Thanks, Hi All, I've searched long and hard accross the web for an answer to this and finnally given in and requesting help. Here's what i have, i have a database setup and working fine. What i would like to do is for an administrator to be able to update my users details. It may sound odd, why don't you let your users update their own details? Well the administrators are dispatchers if you like, and my users are the 'dispatchees', for want of a better word. So i would like my administrators to be able to dispatch my users with routes and my users be able to see the routes that have been dispatched to them. I've setup a login area and a page that pulls there routes off the database, depending on their login details, i.e. jack will see his routes and jill will see her's independantly. This works by me editing the appropriate columns/rows of my database using phpmyadmin. What i'd like now is for administrators (who are directed to a seperate page, with more controls) to be able to do the same as me (updating the database) but by using a php form/script. I'd like to be able to select the routes from a second table on the same database if possible, to try and keep everything tidy. So my dispatcher would select Route001 from a drop down list, this would fill in the text fields next to the route field with From To, so my dispatcher would know what route001 actually is from/ too, choose a username (now being driven from my other table) and hit dispatch. My user would login to their area, hit view dispatched routes and it would display Route 001 with the correct information. The login area was a downloaded script i modified to suit and is called Login-Redirect_v1.31_FULL Many thanks in advance, hope you can sort of understand what i want Josh PHP/MySQL ability:Novice Hey Friends,
I am new to this forum, and does not know anything about programming. And I require very small help from the experts of forum. I have downloaded free image hosting script from web & it is not working fine, it gets stuck at basic.php (one of the file in script). I am sharing the script here also sharing the website. My website : bsm1313.5gbfree.com
Note : I have uploaded a rar file. Kindly change extension to .rar from .php. as it was not allowing me to upload the rar file.
Any kind of help is highly highly appreciated. Thanks a ton in advance.
Attached Files
easyimagehoster_1.32.php 35.46KB
5 downloads Is there a way or function that stops the execution of a required script but continues to execute the parent script, for example: if this is a.php <?php echo "<br>Good morning"; // function to stop execution of only this script to appear here echo "<br>Good Afternoon"; ?> and then this is b.php <?php require("a.php'); echo "<br>Good Evening"; ?> So if the file b.php is called it is supposed to display: Good morning Good evening So it has to skip "Good afternoon" because of the anonymous function which I need i want a script which should be easily integrated with the website and should fully customizable like cutephp.. the problem with cutephp is that it can't handle large data since it stores all the news articles in one .txt file on the server.. as the number of articles grow.. the size of .txt file increases and it becomes impossible for the server to handle the script.. i want a script which should be easily integrated into the website and should have the following features. - article categories - admin panel to add news - should use mySQL to store articles or it should create .htm files for articles.. i hope you get the point.. by the way if i want to write my own script.. what is the easiest way to write a script which should have categories, show news on webpages, have admin password protected add news area.. should create seperate files on the server or use mysql..nothing complicated.. simple news posting script.. Hello, Im trying to create a simple voting script for my site, i been trying different things but cannot get it too function properly. The idea is you click the 'thumbs up' image to add 1 to the 'likes' value and thumbs down to add '1' to the dislikes. Sound simple but its giving me headaches. Would really appreciate it if someone could take a quick look at my script. The table is called 'youtube_rating' (because thats the look i was going for) and in the table is 4 columns, id (aut0_increment), liked (counts liked votes), disliked (counts dislikes) and item_num which is the id for teh product the rating is for. Code: [Select] <? if ( $row['rating'] == 'YES' ) { require ("../rating/voting/dbcon.php"); $result1 = mysql_query("select * from youtube_rating WHERE item_num='".$page_id."'"); $row = mysql_fetch_array($result1); $dislike = $row['dislike']; $like = $row['liked']; if (isset($_POST['submitted'])) { require_once ("../database/functions.php"); $userip = $_SERVER['REMOTE_ADDR']; $id = safe($_POST['id']); $vote = '1'; // check if user already voted $result = mysql_query("SELECT * FROM youtube_ip WHERE userip='$userip' AND item_num ='".$id."'"); $num = mysql_num_rows($result); // if already voted show error if (isset($_POST['submitted']) && ($num > 0)) { echo '<div class="alreadyvoted">You have already voted!</div>'; } // add like if (isset($_POST['submitted']) && ($_POST['submitted'] == 'like') && ($num == 0)) { // add 1 to value $liked_value = mysql_query("SELECT liked FROM youtube_ip WHERE item_num ='".$id."'"); $liked_total = $liked_value + $vote; $query = "update youtube_rating set liked = '".$liked_total."' where item_num ='".$id."'"; echo '<div class="ilikethis">You like this!</div>'; } // add dislike if (isset($_POST['submitted']) && ($_POST['submitted'] == 'dislike') && ($num == 0)) { // add 1 to value $dislike_value = mysql_query("SELECT dislike FROM youtube_ip WHERE item_num ='".$id."'"); $dislike_total = $dislike_value + $vote; $query = "update youtube_rating set dislike = '".$dislike_total."' where item_num ='".$id."'"; echo '<div class="idislikethis">You Dislike this!</div>'; } // log ip // if (isset($_POST['submitted']) && ($num == 0)) // { // mysql_query ("insert into youtube_ip (userip, item_num) values ('".$userip."', '".$id."')"); // } } ?> <table width="50%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="48%" align="center"> <form action="" method="post"> <input name="id" type="hidden" value="<? echo $page_id ?>" /> <input name="submitted" type="hidden" value="like" /> <button type="submit" class="like_button" name="like" id="like" > <img src="../rating/voting/pixel-vfl73.gif" alt=""> <span><?php echo $like?></span> </button> </form> </td> <td width="52%"> <form action="" method="post"> <input name="id" type="hidden" value="<? echo $page_id ?>" /> <input name="submitted" type="hidden" value="dislike" /> <button type="submit" class="dislike_button" name="dislike" id="dislike" > <img src="../rating/voting/pixel-vfl73.gif" alt=""> <span><? echo $dislike?></span> </button> </form> </td> </tr> </table> <? } ?> The problem is the vote does not add up or update the database, also it doesn't seem to be checking if the user has voted or not, it just attempts (but fails) to add a vote no matter what Thanks for any help. Hello: I have a SELECT dropdown menu that works like this: Code: [Select] <?php $states_arr = array('AL'=>"Alabama",'AK'=>"Alaska",'AZ'=>"Arizona",'AR'=>"Arkansas",'CA'=>"California",'CO'=>"Colorado",'CT'=>"Connecticut",'DE'=>"Delaware",'DC'=>"District Of Columbia",'FL'=>"Florida",'GA'=>"Georgia",'HI'=>"Hawaii",'ID'=>"Idaho",'IL'=>"Illinois", 'IN'=>"Indiana", 'IA'=>"Iowa", 'KS'=>"Kansas",'KY'=>"Kentucky",'LA'=>"Louisiana",'ME'=>"Maine",'MD'=>"Maryland", 'MA'=>"Massachusetts",'MI'=>"Michigan",'MN'=>"Minnesota",'MS'=>"Mississippi",'MO'=>"Missouri",'MT'=>"Montana",'NE'=>"Nebraska",'NV'=>"Nevada",'NH'=>"New Hampshire",'NJ'=>"New Jersey",'NM'=>"New Mexico",'NY'=>"New York",'NC'=>"North Carolina",'ND'=>"North Dakota",'OH'=>"Ohio",'OK'=>"Oklahoma", 'OR'=>"Oregon",'PA'=>"Pennsylvania",'RI'=>"Rhode Island",'SC'=>"South Carolina",'SD'=>"South Dakota",'TN'=>"Tennessee",'TX'=>"Texas",'UT'=>"Utah",'VT'=>"Vermont",'VA'=>"Virginia",'WA'=>"Washington",'WV'=>"West Virginia",'WI'=>"Wisconsin",'WY'=>"Wyoming"); function showOptionsDrop($array){ $string = ''; foreach($array as $k => $v){ $string .= '<option value="'.$k.'"'.$s.'>'.$v.'</option>'."\n"; } return $string; } ?> <form> <select name="states"> <option value="0">Choose a state</option> <?php echo showOptionsDrop($states_arr); ?> </select> </form> I would like to show all the towns/zipcodes for each individual state with an "onchange" from the SELECT menu. The table is called "zip_codes" and the City/Zip Codes are called "city" and "zip" What I would like to do is display them as links, so a user can click into each town and either create a new entry (a restaurant) or update an existing entry. What would be the best approach for this? I appreciate the help. Hello everyone. I recently coded a Minecraft Voting for Diamonds script. Basically, you enter your username, you vote on the sites, then click "Get Reward". The reward then goes through a RCON script, and rewards the user with their diamonds in-game. the full script works fine, and I am happy with it, but there is one small problem; and that is users being able to abuse the system. If they wanted to, they could just refresh the page, and click Get Rewarded again, and again. I want to make something like this: It has a countdown on the link, which is started upon click, and then the link re-activates when the timer is done. My script already has "disabled=..." tags, so you have to click all links, this way would make sure a user cannot click the link until the timer is done. I'm pretty new to PHP, and please forgive me if it is not 100% PHP, but this place seemed extremely helpful. I am also pretty new to PHP, so make it for dummies xD Thanks everyone! At the moment I am creating a search function for my website. The approach I have in mind is a pseudo-PHP database. To give an example: A HTML form will submit the results to a PHP file. HTML FORM - Colour: Black PHP RESULT PAGE - if ($_POST['color'] == 'Black') {readfile("./products/black/*.html");} HTML FORM - Price: <$50 PHP RESULT PAGE - if ($_POST['Price'] == '<$50') {readfile("./products/less50/*.html");} The problem here is if there is an item that is black and costs less than $50, then its going to be listed twice. There is probably some code I can write to ommit the listing of duplicate entries, but it is probably going to be messy, so I am wondering if its better to use a centralized MySQL database, rather than a pseudo-PHP database? I've never used MySQL and don't know much about it and this is my first real attempt at using PHP.
Hi! Top Good evening,
I have a jQuery datepicker that I am trying to insert different date values into different textboxes based on the user's selection. The original box displays the standard date format, input box 2 displays the date format suited for mysql, input box 3 needs to display the Month based on user selection, input box 4 displays the Year, and input box 5 needs to display the Month and the Year. The problem I am having is when I try to add multiple altField, it will only update the last id indicated. Here's my code.
Thanks in advanced,
Demeritrious
HTML
<input type="text" id="Goal" name="Goal" value="<?php echo $Goal; ?>"> <input type="text" id="GoalDate" name="GoalDate" value="<?php echo $GoalDate; ?>"> <input type="text" id="MyBillsMonth" name="Month" value="<?php echo $Month; ?>"> <input type="text" id="MyBillsYear" name="Year" value="<?php echo $Year; ?>"> <input type="text" id="MyBillsMonthYear" name="MonthYear" value="<?php echo $MonthYear; ?>">JQUERY I've tried this $( "#Goal" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'mm-dd-yy', altField: "#GoalDate, #MyBillsMonth, #MyBillsYear, #MyBillsMonthYear", altFormat: "yy-mm-dd, MM, yy, MM yy" });AND This $( "#Goal" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'mm-dd-yy', altField: "#GoalDate", altFormat: "yy-mm-dd", altField: "#MyBillsMonth", altFormat: "MM", altField: "#MyBillsYear", altFormat: "yy", altField: "#MyBillsMonthYear", altFormat: "MM yy" }); I have a mysql database where users enter their data using a form that includes a rundate input field that generates a calendar date in this type of format: xx/xx/xxxx into a mysql database field called rundate. I would like to query the database to search a string of dates that are in the database, such as 01/01/2011, 01/02/2011, 01/03/2011 but I'm not sure on how to code this into my search.php. I have attached the search page to this post. Any suggestions would be greatly appreciate, and if you need me to be more expanded on my explanation, just let me know....i try to keep it very simplistic. [attachment deleted by admin] How would I go about doing the following: I have a csv like this Quote "Division","Section","Group","Product Code","Description","Description + Secondary Description" "Division 1","Section 1","Group 1","BMSLPL25","Test Name","Test Description" "Division 1","Section 1","Group 2","BMSLPL26","Test Name 2","Test Description 2" "Division 2","Section 2","Group 2","BMSLPL27","Test Name 3","Test Description 3" I have a database structured like this Quote Divisions --- id name parent_id Groups --- id name division_id Products --- id code description secondary_description Section is a sub division. What is the best way to get the information from CSV into this database? Should I have another table and store the CSV data as is and then query that to make the other tables. Any help much appreciated. |