Jump to content

Search the Community

Showing results for tags 'mysql'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 249 results

  1. So my goal is now to have a table list read from the database. The content of the table is supposed to be put in an <SELECT> <OPTION VALUE> form for a dropdown menu having the user select only 1 value. $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SHOW TABLES"; if (!$result = $conn->query($sql)){ die('There was an error running the query[' .$conn->error. ']'); } foreach($row = $result->fetch_assoc()){ echo "<center>"; $reeks = implode(" " , $row); // echo $reeks; // echo "<br>"; echo "</center>"; ?> <center> <form name = "inpform" method="post" action="Add-succ7.php"> <SELECT > <option value = "<?php echo $reeks; ?>" > </option> </SELECT> </center> <?php } mysqli_close($conn); ?> Do I have to do this with foreach or while? (or something else?) In the checkbox version I use while but when doing that I get a list of 8 checkboxes without any value. I see the dropdown menu is placed in the loop of while so another condition (like foreach) seems to be the first thing to think about. But what kinda solutions would you have for the script above?
  2. id | mid | pid | owgh | nwgh |1 3 12 1.5 0.62 3 12 1.5 0.33 3 14 0.6 0.44 3 15 1.2 1.15 4 16 1.5 1.06 4 17 2.4 1.27 3 19 3.0 1.4 Select mid , COUNT(distinct pid) as cpid , SUM(nwgh) as totalnwgh from test GROUP BY mid sqlfiddle : link of below result with above query mid cpid totalnwgh3 4 3.84 2 2.2 But above i need one more column that's as below : **totowgh** mid cpid totalnwgh totowgh3 4 3.8 6.3 (DISTINCT value as per pid column)4 2 2.2 3.9 where totowgh = 6.3 come by DISTINCT value as per pid columnthat's mid = 3 has count 5 but distinct pid = 4 for mid=3 same way "distinct" owgh = 6.3 for mid=3 and distinct pid.As pid=12 is count 1 time hence,1.5 + 0.6 + 1.2 + 3 = 6.3 ( please not this is as per DISTINCT value of pid )Please note : i need owgh value as per distinct pid or group by pid .. because if i replace value of owgh 0.6 with 1.5 then it will be 5.7 instead of 7.2 but value of owgh 0.6 belong to pid = 14 and not pid = 12 hence totalcount of owgh change ...but i need is 7.2SEE WHAT I MEANS : sqlfiddle.com/#!9/2a53c/6
  3. Bookmark system

    Hi to all. I'm new in php development. I'm trying to do a bookmark system. I have an intern search engine that extract data from a database table build in MYSQL that show as link and the user can click on and appear es text html. I want to give the possibility to add a star button near these link and when the user click on to bookmark. I found 2 ways to do this, but I'm sure that exist more solution that can do better or not: 1- Give the possibility to the user that when click on button near the link that extract data from the database to add this on a bookmark table. 2- When the user click on button add data to a the bookmark browser with a javascript as this (http://stackoverflow.com/questions/10033215/how-do-i-add-an-add-to-favorites-button-or-link-on-my-website). I think is the easiest solution but I'm not sure what can do the correct way to this. Any advice is welcome:)
  4. PHP Database Server

    Hello. I'm currently developing an app in the Intel XDK for my local high school. One of the features I would like to add is something where school administrators (such as the athletic director) can login and then submit data into an HTML5 form, which is then submitted to a server and stored in a database. Then, after it is stored, I would like the information to be able to be viewed by regular users of the app, in something such as an HTML page. THe purpose of this would be for the school admins to submit scores from the games such as football, etc. My question is, how do I setup the server (im assuming would run PHP) to be able to store the submitted data, and then would edit an HTML page to include the new text? Any help is appreciated! Thanks!
  5. Problem in Checkbox Checked

    Hi Sir, I creating a form with checkbox for example I checked the Add Employee and Upload Employee, after I click the Submit button the output is 2 and 3 which is correct but only the Upload Employee was checked. How can it be that the Add Employee and Upload Employee was checked. Also how can save checkbox check in the database. if(isset($_POST['submit'])){ if(!empty($_POST['access'])) { $access = $_POST['access']; echo "You chose the following color(s): <br>"; foreach ($access as $access_id){ echo $access_id."<br />"; }} // end brace for if(isset else { echo "You did not choose a color."; }}<input type="checkbox" name="access[]" id="access" value="1" <?php if($access_id==1) echo 'checked="checked"'; ?>>Search/View Employee Information<br><input type="checkbox" name="access[]" id="access" value="2" <?php if($access_id==2) echo 'checked="checked"'; ?>>Add Employee<br><input type="checkbox" name="access[]" id="access" value="3" <?php if($access_id==3) echo 'checked="checked"'; ?>>Upload Employee<br><input type="checkbox" name="access[]" id="access" value="4" <?php if($access_id==4) echo 'checked="checked"'; ?>>Permission<br><input type="checkbox" name="access[]" id="access" value="5" <?php if($access_id==5) echo 'checked="checked"'; ?>>Vacation<br><input type="checkbox" name="access[]" id="access" value="6" <?php if($access_id==6) echo 'checked="checked"'; ?>>Calendar Event<br> <input type="submit" name="submit" id="submit" value="Submit"> Thank youHi Sir,I creating a form with checkboxfor example I checked the Add Employee and Upload Employee, after I click the Submit button the output is 2 and 3 which is correct but only the Upload Employee was checked.How can it be that the Add Employee and Upload Employee was checked.Also how can save checkbox check in the database. if(isset($_POST['submit'])){ if(!empty($_POST['access'])) { $access = $_POST['access']; echo "You chose the following color(s): <br>"; foreach ($access as $access_id){ echo $access_id."<br />"; }} // end brace for if(isset else { echo "You did not choose a color."; }}<input type="checkbox" name="access[]" id="access" value="1" <?php if($access_id==1) echo 'checked="checked"'; ?>>Search/View Employee Information<br><input type="checkbox" name="access[]" id="access" value="2" <?php if($access_id==2) echo 'checked="checked"'; ?>>Add Employee<br><input type="checkbox" name="access[]" id="access" value="3" <?php if($access_id==3) echo 'checked="checked"'; ?>>Upload Employee<br><input type="checkbox" name="access[]" id="access" value="4" <?php if($access_id==4) echo 'checked="checked"'; ?>>Permission<br><input type="checkbox" name="access[]" id="access" value="5" <?php if($access_id==5) echo 'checked="checked"'; ?>>Vacation<br><input type="checkbox" name="access[]" id="access" value="6" <?php if($access_id==6) echo 'checked="checked"'; ?>>Calendar Event<br> <input type="submit" name="submit" id="submit" value="Submit"> Thank you
  6. Hello every one anyone can solve my prob my database not save my html data in mysql i want to save my hrml data in mysql but its work only for 755 characters after 755 755 no data save in database so plz tell me how i save my html 8000 characters data how to save in my db Thanks
  7. Learning code (php/sql/etc) part time

    Hi, Can anyone recommend anywhere that I can learn code part time in the United Kingdom? I have been teaching myself html, css, etc on a basic level & now venturing into php, mysql, js, etc & think that having a tutor or guidance would really help speed up my learning process. Any companies or colleges offering part time courses in these area's will hopefully fill in the holes in my knowledge & help me progress. I'm not really concerned about qualification certificates, the knowledge is more important to me. Thanks for any advice. Old Guy.
  8. How can i select articles based on images

    Hi, need some advice to do logic in my table casue i never face this before, hope you guys help me out this issue i need to show data from database and the image upload here cause cannot upload here to big system respond but let me tell here what i stuck it I need show the row with max id ( Done ) I need show data limit 1 where id != row with max id (Done) I need show all data without max id (point 1) and point 2 Thanks, and think that it can handle by css by hidden or by selector asecending but still figure out how. edit : i use codeiigniter
  9. Hi,Good day!I found a tutorial on creating a calendar that can add Event.Now, I want to enhance it to add Delete and Edit button but I have no idea on how to do that here is my code:calendar.php <?php$hostname = 'localhost';$username = 'root';$password = 'root';$dbname = 'calendar';$conn = new mysqli($hostname, $username, $password, $dbname);// Check connectionif ($conn->connect_error) { die("Connection failed: " . $conn->connect_error);}?><!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>Untitled Document</title><script> function goLastMonth(month,year) { if(month == 1) { --year; month = 13; } --month var monthstring = ""+month+""; var monthlength = monthstring.length; if(monthlength <= 1) { monthstring = "0"+monthstring; } document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+monthstring+"&year="+year; } function goNextMonth(month,year) { if(month == 12) { ++year; month = 0; } ++month var monthstring = ""+month+""; var monthlength = monthstring.length; if(monthlength <= 1) { monthstring = "0"+monthstring; } document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+monthstring+"&year="+year; }</script><style> .today { background-color: #d3c6bd; } .event { background-color: #8d735a; }</style></head><body><?phpif(isset($_GET['day'])){ $day = $_GET['day'];}else{ $day = date("j");}if(isset($_GET['month'])){ $month = $_GET['month'];}else{ $month = date("n");}if(isset($_GET['year'])){ $year = $_GET['year'];}else{ $year = date("Y");}$maxDay = cal_days_in_month(CAL_GREGORIAN, $month, $year);if( $day > $maxDay ) { $day = $maxDay;}$currentTimeStamp = strtotime("$year-$month-$day");$monthName = date("F", $currentTimeStamp);$numDays = date("t", $currentTimeStamp);$counter = 0;if(isset($_GET['add'])){ $title = $_POST['txttitle']; $detail = $_POST['txtdetail']; $eventdate = $month."/".$day."/".$year; $sqlinsert = "INSERT INTO tbl_calendar (Title, Detail, eventDate, dateAdded) VALUES ('".$title."','".$detail."','".$eventdate."', now())"; if ($conn->query($sqlinsert) === TRUE) { // echo "Event was successfully Added..."; } else { // echo "Event Failed to be Added..."; } }?><table border="1"> <tr> <td><input style='width:60px; height:40px;' type='button' value='<' name='previousbutton' onClick="goLastMonth(<?php echo $month.",".$year; ?>);"></td> <td colspan="5" style='text-align:center;font-weight:bold;background-color:#8d735a; color:#FFF;'><?php echo $monthName. ", ".$year; ?></td> <td><input style='width:60px; height:40px;' type='button' value='>' name='nextbutton' onClick="goNextMonth(<?php echo $month.",".$year; ?>);"></td> </tr> <tr style='background-color:#af9c8e; color:white;'> <td width='60px' height='40px' align='center'>Sun</td> <td width='60px' height='40px' align='center'>Mon</td> <td width='60px' height='40px' align='center'>Tue</td> <td width='60px' height='40px' align='center'>Wed</td> <td width='60px' height='40px' align='center'>Thu</td> <td width='60px' height='40px' align='center'>Fri</td> <td width='60px' height='40px' align='center'>Sat</td> </tr> <?php echo "<tr>"; for($i = 1; $i < $numDays+1; $i++, $counter++){ $timeStamp = strtotime("$year-$month-$i"); if($i == 1) { $firstDay = date("w", $timeStamp); for($j = 0; $j < $firstDay; $j++, $counter++) { echo "<td> </td>"; } } if($counter % 7 == 0) { echo "</tr><tr>"; } $monthstring = $month; $monthlength = strlen($monthstring); $daystring = $i; $daylength = strlen($daystring); if($monthlength <=1) { $monthstring = "0".$monthstring; } if($daylength <=1) { $daystring = "0".$daystring; } $todaysDate = date("m/d/Y"); $dateToCompare = $monthstring.'/'.$daystring.'/'.$year; echo "<td align='center' width='60px' height='40px'"; if($todaysDate == $dateToCompare) { echo "class='today'"; } else { $sqlCount = "SELECT * from tbl_calendar where eventDate='".$dateToCompare."'"; $resCount = $conn->query($sqlCount); $noOfEvent = $resCount->num_rows; if($noOfEvent >= 1){ echo "class='event'"; } } echo "><a href='".$_SERVER['PHP_SELF']."?month=".$monthstring."&day=".$daystring."&year=".$year."&v=true' style='text-decoration:none; color:#000;'>".$i."</a></td>"; } echo "</tr>"; ?></table><br/> <?php if(isset($_GET['v'])) { echo "<a href='".$_SERVER['PHP_SELF']."?month=".$month."&day=".$day."&year=".$year."&v=true&f=true' style='float:left; margin:-390px auto auto 500px; background-color:#83694d; padding:5px; border-color:#fece99; border-radius:4px; color:white; cursor:pointer; width:58px; text-decoration:none; font-weight:bold;'>Add Event</a>"; if(isset($_GET['f'])) { include("eventform.php"); } $sqlEvent = "SELECT * FROM tbl_calendar WHERE eventDate = '".$month."/".$day."/".$year."'"; $resEvent = $conn->query($sqlEvent); $cntEvent = $resEvent->num_rows; echo "<br/>"; if(isset($_GET['f'])) { echo "<div style='float:left; margin:-150px auto auto 500px;'>"; } else { echo "<div style='float:left; margin:-370px auto auto 500px;'>"; } while($row= $resEvent->fetch_array()) { echo "<b>Title: </b>". $row['Title']."<br/>"; echo "<b>Detail: </b>". $row['Detail']."<br/>"; } echo "</div>"; } ?></body></html>eventform.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>Untitled Document</title></head><body><form name='eventform' method='POST' action="<?php $_SERVER['PHP_SELF']; ?>?month=<?php echo $month;?>&day=<?php echo $day; ?>&year=<?php echo $year; ?>&v=true&add=true"> <div style="float:left; margin:-360px auto auto 500px;"> <table width='400px'> <tr> <td width='50px' style='font-weight:bold;'>Title: </td> <td width='250px'><input type='text' name='txttitle' size='40'></td> </tr> <tr> <td width='50px' style='font-weight:bold;'>Detail: </td> <td width='250px'><textarea name='txtdetail' style='width: 300px; height: 150px;'> </textarea></td> </tr> <tr> <td colspan='2' align='center'><input type='submit' name='btnadd' value='Submit' style='width:80px; height:25px; background-image:url(images/Search-Button.jpg); border-radius:5px; border: 1px solid #616f7c; color:#fff; margin: auto;cursor:pointer;'></td> </tr> </table> </div></form></body></html>Thank you
  10. mute user from chat

    Hi, i am playing a game and there is a user in chat that bothers me and other players a lot but he does not break any game rule... i was wondering if there is a way i could block or mute his text with a JavaScript if so, does anyone have a tutorial on how to code something like this? the chat have no ID but every chat message is put out like this. <table border="0" padding="0" cellspacing="0" width="100%"> <tbody> <tr> <td width="90" class="chat"> <div id="202525"></div> 2015-08-24 06:06:00 </td> <td style=""> <a href="javascript:newmsg('The Martyr','')" style="">The Martyr:</a> " so I starting to give up" </td> </tr> </tbody></table> and it looks like this in chat: 2015-08-24 06:06:00 The Martyr: so I starting to give up i was thinking i could use the user name 'The Martyr' in some way to block that user i would love to code something that would just remove the lines from the chat box. and any other line the user typed and will type. i just have no idea where to start. any kind of help would be appreciated thanks
  11. meaning mysql error

    I get an error code You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near I found this is error 1149 ? is that right? I'm looking for the meaning of this error. What is the reason I'm having this? Does it mean the mysq code in my php script is wrong? Is a solution changing the MYSQL line or can the error also be made in the php part of the script?
  12. Bootstrap sounds a bit like a finished optional program to use? also It seemed like when I first started seeing this page I have been learning from, that it is trying to "sell me" on the HTML5 as a good new and easier way to think of html code I wonder if this stuff has any merit? is it true? Is there any particular Web and computer code language *(scripting etc,) that are universal, or more functional for a different similar type? like for example I have read that someone wrote "there personal favorite scripting is" and similar quoted. Is there any that are not liked or favored by many, but are more sort of fundamentally necessary to and work very well, and will be around to stay? It seems like to me HTML, is the way things are done, also interactions with internet and computers happens with javascript. As I have researched more about how it all works, It seems there are database languages that are used as well, and of course web page layout - CSS, it seems like some of these must be more of a basic foundation? I would like to focus on the types of web coding that have stood the test of time? types of code that aren't going anywhere due to the nature of how they function is not likely to be outdated soon? some of the questions and comments are referring to, jSON, mySql, appML, PHP, jquery, CSS, bootsrap, html5, (html5 vs. HTML or XHTML), xml, are any of the things listed Proprietarily limited more-so than others? or do any of them duplicate function of another? all generally speaking, I am sure there are reasons for everything. but to cut down the cluster of things to learn? which is important, and if multitudes of things are important enough to learn. which order is best?
  13. I'm receiving this error 'Call to a member function prepare() on null' if I were to put this search code into the page. It works fine if i were to put at other pages(for inserting to database).Here's my search code that I've put before the html tags: <?php//echo '<pre>';//echo $_POST;//echo '</pre>';//declare the form name//$searchForm = htmlentities($_SERVER['PHP_SELF']);try { //inserts database connections require('Connections/database.php'); if (($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['search'])) { // array to hold errors $errorsSearch = array(); //create a bad word array $badwords = array('######','damn','mother######er','###### you'); //Declare variables $search = $_POST['search']; //Validations for the $_POST //check if it's blank if (trim($search) == "" || !isset($search)) { $errorsSearch[] = ("Search is blank!"); } //Check if the text to search is too long if (isset($search) && strlen(trim($search)) > 50) { $errorsSearch[] = ("The text to search is too long!"); } //Check for any vulgarities if (isset($search) && in_array($search,$badwords)) { $errorsSearch[] = ("No vulgarities!"); } if (empty($errorsSearch)) { //Declare the sql query $query = "SELECT * FROM portfolio WHERE nameOfPortfolio LIKE '%$search%'"; //var_dump($query); $stmt = $database->query($query); $number_of_rows = $stmt->fetchColumn(); if ($number_of_rows == 0) { $errorsSearch[]= ("No results! Sorry, please try again!"); } if ($number_of_rows > 0) { //$errors[] = "There is an existing record. You cannot insert another profile! Either update the old one, or delete to insert again."; header("Location:searchResults.php"); exit; }} if (isset($errorsSearch) == true) //foreach($errors as $error){ echo "<div id=search_errors>" .implode("<br>", $errorsSearch) . "</div>"; //printf("%s",$error);}} //end of form processing} //end of try methodcatch(PDOException $e){ // end of database dependent code, handle any errors $status = empty($query) ? 'Connection failed':" Query failed: $query"; // application message trigger_error("$status, Error: {$e->getMessage()}, File: {$e->getFile()}, Line: {$e->getLine()}"); // user message $errorsSearch[] = 'Sorry, this page is not working at this time.';}// done with the database, destroy any pdostatment resource and close connection$stmt = null;$database = null; //the html document that uses any data from the above code starts here -?> This is my code for getting the data: <table width="379" border="0" cellspacing="0" cellpadding="0" style=" border-style: solid" > <?php try { //connect to database require_once('Connections/database.php'); //Selecting a single row! $sql = "SELECT * FROM userProfile WHERE user_id in ( select id from users where id = ".($_SESSION['user_id']).")"; //Prepare our SELECT statement. $statement = $database->prepare($sql); //Execute our SELECT statement. $statement->execute(); if (!$row = $statement->fetch(PDO::FETCH_ASSOC)) { print_r ("No Data to show. Please add in your profile. Navigate your way through the left side of the page where the navigations are."); } if (isset($errors) == true) { echo "<div id=add_port_errors>" .implode("<br>", $errors) . "</div>"; }// get method/display code (if any) - get/produce data that's needed to display the page// to edit existing data, if the $data array is empty at this point, retrieve any existing data from the database table?> <tr> <th width="auto" scope="row"><div align="left">Profile Picture:</div></th> <td width="auto"><img src="<?php print htmlspecialchars($row['picPath']); ?>" width="82" height="72"> </td> <td width="auto"><form name="editProfile" method="post" action="editProfile.php"> <input type="submit" name="edit" id="edit" value="Edit"> </form></td> </tr> <tr> <th scope="row"><div align="left">Username:</div></th> <td><label><?php print htmlspecialchars($row['username']); ?></label></td> <td><form name="editProfile" method="post" action="editProfile.php"> <input type="submit" name="edit" id="edit" value="Edit"> </form></td> </tr> <tr> <th scope="row"><div align="left">Name:</div></th> <td><label><?php print htmlspecialchars($row['Name']); ?></label></td> <td><form name="editProfile" method="post" action="editProfile.php"> <input type="submit" name="edit" id="edit" value="Edit"> </form></td> </tr> <tr> <th scope="row"><div align="left">Email:</div></th> <td><label><?php print htmlspecialchars($row['Email']); ?></label></td> <td><form name="editProfile" method="post" action="editProfile.php"> <input type="submit" name="edit" id="edit" value="Edit"> </form></td> </tr> <tr> <th scope="row"><div align="left">ContactNo:</div></th> <td><label><?php print htmlspecialchars($row['ContactNo']); ?></label></td> <td><form name="editProfile" method="post" action="editProfile.php"> <input type="submit" name="edit" id="edit" value="Edit"> </form></td> </tr> <tr> <th scope="row"><div align="left">Skillset:</div></th> <td><label><?php print htmlspecialchars($row['skillset']); ?></label></td> <td><form name="editProfile" method="post" action="editProfile.php"> <input type="submit" name="edit" id="edit" value="Edit"> </form></td> </tr> <tr> <th scope="row"><div align="left">Specialization:</div></th> <td><label><?php print htmlspecialchars($row['Specialization']); ?></label></td> <td><form name="editProfile" method="post" action="editProfile.php"> <input type="submit" name="edit" id="edit" value="Edit"> </form></td> </tr> <tr> <th scope="row"><div align="left">Introduction:</div></th> <td><label><?php print htmlspecialchars($row['introduction']); ?></label></td> <td><form name="editProfile" method="post" action="editProfile.php"> <input type="submit" name="edit" id="edit" value="Edit"> </form></td><?php } //catch(PDOException $e){ // end of database dependent code, handle any errors$status = empty($query) ? 'Connection failed':" Query failed: $query";// application messagetrigger_error("$status, Error: {$e->getMessage()}, File: {$e->getFile()}, Line: {$e->getLine()}");// user message$errors[] = 'Sorry, this page is not working at this time.';}// done with the database, destroy any pdostatment resource and close connection$stmt = null;$database = null; ?> </tr> </table> My database is correct though, I'm using $database for all the connections, i didn't change the variable name. I'm not sure why it wouldn't initialized. Is my select query wrong? ;-;
  14. Jquery Autocomplete

    Hi,Good day!I created a search box and my problem is when I type Employee ID the auto list displayed is Employee Name, I need to display on the list is based on what I type. I don't know if it is possible that in one search box I can search Employee name then the list of names will display, when I type Employee ID, employee id list will display. same with Passport no and res id.Now, when I type Employee Id or Passport No or res id and employee name. the displayed list is employee name.this is my code: <script type="text/javascript" src="js/jquery.js"></script> <script type='text/javascript' src='js/jquery.autocomplete.js'></script> <link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" /><script type="text/javascript">//----auto complete emp no--//$().ready(function() { $("#search_data").autocomplete("get_emp_info.php", { width: 237, minLength: 3,//search after three characters matchContains: true, mustMatch: true, selectFirst: false }); });</script> <table> <tr> <td style="border: none;color:#80600a;font-weight:bold;">Search:</td> <td><input type="text" name="search_data" id="search_data" value="" size="35" autofocus></td> </tr> </table> <?phpob_start();include('includes/connection.php');$q = strtolower($_GET["q"]);if ($q == '') { header("HTTP/1.0 404 Not Found", true, 404);}//else (!$q) return;else{$sql = "SELECT pe.employee_no, pe.employee_name, pe.passport_no, gov.res_id FROM tbl_personal_info AS pe JOIN tbl_public_info AS pu ON (pe.employee_no = pu.employee_no) JOIN tbl_e_government_info AS gov ON (pu.employee_no = gov.employee_no) WHERE pe.employee_no LIKE '%".$q."%' OR pe.employee_name LIKE '%".$q."%' OR pe.passport_no LIKE '%".$q."%' OR gov.res_id LIKE '%".$q."%'";$result = $conn->query($sql);if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $pid = $row["employee_no"]; $employee_name = $row["employee_name"]; $passport_no = $row["passport_no"]; $res_id = $row["res_id"]; echo "$employee_name|$pid|$passport_no|$res_idn"; }} else { echo "0 results";}$conn->close(); }?>
  15. PHP restriction error [Closed]

    I'm trying to restrict users from accessing a page if their rank isn't manager or admin. I made a variable called $rank which is the rank that is fetched from the user's table in my database. When I echo the rank on the page, the rank does equal to manager or admin but it redirects me to the index page because it somehow doesn't equal manager or admin. When I try using this code: if(!isset($_SESSION['userID'])) { header("Location: index.php");} else if ($rank == "manager" OR $rank == "admin") { } else { header("Location: index.php");} it does work but I feel like that's the wrong way of doing it. This is the code that I'm using now and isn't working: $tUsers_Select = "SELECT users.rank, ranks.rank_name FROM users LEFT JOIN ranks ON users.rank = ranks.rank_name WHERE user_id = ".$_SESSION['userID'];$tUsers_Select_Query = mysqli_query($dbConnect, $tUsers_Select);$fetch = mysqli_fetch_array($tUsers_Select_Query);$rank = $fetch['rank'];if(!isset($_SESSION['userID'])) {header("Location: index.php");} else if ($rank !== "manager" OR $rank !== "admin") {header("Location: index.php");} Hopefully you understood. Please comment if you have any questions.
  16. I have a hard time trying to make my radio buttons work. I know that radio buttons are a special case whereby if the user did not click on them, the value will not be taken in. Thus, i have made all my radio buttons to be set per group. However, i can't seem to get the validating right. This is my current validating code as of now: if ((isset($data['specialization']) && $data['specialization'] = "specialization_1")) { $data['specialization'] = "IS"; $skillset =($data['ISgrp1'].",".$data['ISgrp2'].",".$data['ISgrp3'].",".$data['ISgrp4'].",".$data['ISgrp5']); } if ((isset($data['specialization']) && $data['specialization'] = "specialization_2")) { $data['specialization'] = "IM"; $skillset = ($data['IMgrp1'].",".$data['IMgrp2'].",".$data['IMgrp3'].",".$data['IMgrp4'].",".$data['IMgrp5']); } if ((isset($data['specialization']) && $data['specialization'] = "specialization_3")) { $data['specialization']= "CNET"; $skillset = ($data['CNETgrp1'].",".$data['CNETgrp2'].",".$data['CNETgrp3'].",".$data['CNETgrp4'].",".$data['CNETgrp5']); } if ((isset($data['specialization']) && $data['specialization'] = "specialization_4")) { $data['specialization'] = "ITSM"; $skillset = ($data['ITSMgrp1'].",".$data['ITSMgrp2'].",".$data['ITSMgrp3'].",".$data['ITSMgrp4'].",".$data['ITSMgrp5']); } I have set my specialization radio group to correspond together with my $skillset. However, my $specialization is somehow always set to "ITSM" although I click on IS" and $skillset is showing only ",,,," in the database. (it used to be nothing as i have to declare $skillset = "" for they can't read my $skillset inside the {} , I'm not sure what i have done to the piece of code o.o). I've heard about imploding (since it's in an array), and this is what I came up with: //assign skillsets based on the specialization if (!$data['specialization'] = "" && isset($data['specialization'])) { if ($data['specialization']= "specialization_1") { $data['specialization'] = "IS"; $skillset = (implode(",",($data['ISgrp1']).",".($data['ISgrp2']).",".($data['ISgrp3']).",".($data['ISgrp4']).",".($data['ISgrp5']))); } if ($data['specialization']= "specialization_2") { $data['specialization'] = "IM"; $skillset = (implode(",",($data['IMgrp1']).",".($data['IMgrp2']).",".($data['IMgrp3']).",".($data['IMgrp4']).",".($data['IMgrp5']))); } if ($data['specialization']= "specialization_3") { $data['specialization']= "CNET"; $skillset = (implode(",",($data['CNETgrp1']).",".($data['CNETgrp2']).",".($data['CNETgrp3']).",".($data['CNETgrp4']).",".($data['CNETgrp5']))); } if ($data['specialization']= "specialization_4") { $data['specialization'] = "ITSM"; $skillset = (implode(",",($data['ITSMgrp1']).",".($data['ITSMgrp2']).",".($data['ITSMgrp3']).",".($data['ITSMgrp4']).",".($data['ITSMgrp5']))); } } However, they are showing undefined $skillset and the $data[''] inside the $skillset. Please tell me where i've gone wrong, I have been searching for some examples but the examples are only those with male/female gender type of option (simple type). Why is it that they can't get the $skillset defined in that validation? Also, can someone give me a link to a good image uploading tutorial? I can't seem to get it right as it always goes to a blank page when i hit the submit>< This is my page(my html form and my php codes ): addProfile.php
  17. PHP sign in user after registration

    I'm creating a simple login and registration form. What I'm trying to do is when a user registers, it should log them in. In order to get logged in, the user's ID that gets registered needs to be sent to the home page so the username can be displayed. I'm not sure what is wrong with my code. Register: <!DOCTYPE html><?php session_start(); if(isset($_SESSION['userID']) AND !empty($_SESSION['userID'])) { header("Location: home.php"); } if(isset($_POST['register'])) { $firstName = mysqli_real_escape_string($dbConnect, $_POST['firstName']); $lastName = mysqli_real_escape_string($dbConnect, $_POST['lastName']); $username = mysqli_real_escape_string($dbConnect, $_POST['username']); $email = mysqli_real_escape_string($dbConnect, $_POST['email']); $password = mysqli_real_escape_string($dbConnect, $_POST['password']);{ // Check if data exists already in the database $exists = mysqli_query($dbConnect, "SELECT user_id, username, email FROM users WHERE username = '$username' AND email = '$email'"); $row = mysqli_fetch_array($exists); $dbusername = $row['username']; $dbemail = $row['email']; if ($username == $dbusername) { die("Username already taken."); } else if ($email == $dbemail) { die("Email already registered."); }} $registerUser = "INSERT INTO users (first_name, last_name, username, email, password) VALUES('$firstName', '$lastName', '$username', '$email', '$password')";{ // Select ID from registered user $selectID = "SELECT user_id FROM users WHERE username = '$username'"; $selectID_Query = mysqli_query($dbConnect, $selectID); $fetch = mysqli_fetch_array($selectID_Query); $userID = $fetch['user_id']; $_SESSION['userID'] = $userID;} if(mysqli_query($dbConnect, $registerUser)) { header("Location: home.php"); } else { echo "<script>alert('error while registering you...');</script>"; } } include "includes/head.php"; include "includes/nav.php";?> <div id="main-content"> <div class="welcome-msg"> <h1 class="huge">Registration form</h1> <h3 class="medium">Please fill in all the inputs</h3> <form id="login-form" method="post"> <label for="firstName">First Name</label> <input type="text" name="firstName" id="firstName" required> <label for="lastName">Last Name</label> <input type="text" name="lastName" id="lastName" required> <label for="username">Username</label> <input type="text" name="username" id="username" required> <label for="email">Email</label> <input type="email" name="email" id="email" required> <label for="password">Password</label> <input type="password" name="password" id="password" required> <button type="submit" name="register">Register</button> </form> </div> </div></body> Home: <!DOCTYPE html><html><?phpsession_start();if(!isset($_SESSION['userID'])) { header("Location: index.php");}$tUsers_Select_Query = mysqli_query($dbConnect, "SELECT * FROM users WHERE user_id=".$_SESSION['userID']);$row = mysqli_fetch_array($tUsers_Select_Query);include "includes/head.php";include "includes/nav.php";?> <div id="main-content"> <h1 class="huge">Welcome back, <?php echo $row['username'] ?>!</h1> <a href="/lr/logout.php?logout">Logout</a> </div></body> If you need any more details, please comment.
  18. I am trying to make a result page so I can get some information from the database by using php coding. I need it to be able to find a patient name and date of service. Which will be if I type in (Search:) Joe Doe and add (from:) 02/02/2015 (to:) 02/14/2015. It will find the patient name and all date of service. Here is my code ... I know mysql is not good but it will work for now. <?phpmysql_connect('localhost', 'root', 'no_password');mysql_select_db('timeclock');$results = array();if(isset($_GET['search'])) { $search = $_GET['search_box']; $from = $_GET['from']; // or $from = $_get['from']; $to = $_GET['to']; // or $to = $_get['to']; $sql = mysql_query("SELECT * FROM info WHERE patient_name = '".$search."' AND (date_of_service BETWEEN '".$from."' AND '".$to."')"); while($row = mysql_fetch_assoc($sql)) { $results[] = $row; }}?><!-- form --><form name="search_form" method="GET" action="">Search: <input type="text" name="search_box" value="" />Dates From : <input type="text" name="from" value=""/> To : <input type="text" name="to" value=""/><input type="submit" name="search" value="Look up Patient ..."></form><!-- end --><table width="70%" cellpadding="5" cellspace="5"><tr> <td><strong>Care Provider</strong></td> <td><strong>Patient Name</strong></td> <td><strong>Date of Time</strong></td> <td><strong>Time In</strong></td> <td><strong>Time Out</strong></td> <td><strong>Remarks</strong></td></tr><?php if(!empty($results)): ?><?php foreach($results as $row){ ?><tr> <td><?php echo $row['care_provider']; ?></td> <td><?php echo $row['patient_name']; ?></td> <td><?php echo $row['date_of_service']; ?></td> <td><?php echo $row['time_in']; ?></td> <td><?php echo $row['time_out']; ?></td> <td><?php echo $row['remarks']; ?></td></tr><?php } ?><?php endif; ?></table>
  19. Doubt in w3schools

    Hi, I have doubt in AJAX Database, In that getuser.php what should i write in the place of ajax_demo. Please anybody help me. And the link is http://www.w3schools.com/php/php_ajax_database.asp
  20. I'm writing an application using PHP and MySQL that is a TV Guide/TV Listings to pull the results of the following fields: id – int(11) name – varchar(255) chan_position – int(3) src_image – varchar(255) time – varchar(255) title – varchar(255) date – varchar(25) This is the code I've tried so far that basically displays all results as a table: <?php require('db.php'); ?> <div class="container"> <? //Start table echo "<table id='guide'>"; echo "<th>Channel</th>"; echo "<th>Title</th>"; echo "<th>Time</th>"; echo "<th>Date</th>"; echo "</tr>"; // Loop through database for ($i = 1; $i < $rowcount; $i++) { $row = mysqli_fetch_assoc($result); $chan_name = $row['name']; $chan_num = $row['chan_position']; $chan_logo = $row['src_image']; $time = date("g:i a", strtotime($row['time'])); $title = $row['title']; $date = $row['date']; // Show entries echo "<tr> <td style='text-align: center;'>"."<img src='".$chan_logo."'><br>".$chan_name."</td> <td>".$title."</td> <td>".$time."</td> <td>".$date."</td> </tr>"; } echo "</table>" ?> The ultimate goal is to have it display closely (but not exactly) to how its done here: http://www.zap2it.com/tvlistings 1. Getting the pagination to be horizontal and the loop through the results based on the time that is stored in the `time` column from 00:00 to 23:00 (use of AJAX necessary?) **Additional details** This is what is currently being output and the link above is what is needed to be output in terms of scrolling and pagination functionality. The output of the table at the moment is how the data is currently stored in the table as well.
  21. i found this script online: http://stackoverflow.com/questions/8022353/how-to-populate-html-dropdown-list-with-values-from-database <?php $conn = new mysqli('localhost', 'username', 'password', 'database') or die ('Cannot connect to db'); $result = $conn->query("select id, name from table"); echo "<html>"; echo "<body>"; echo "<select name='id'>"; while ($row = $result->fetch_assoc()) { unset($id, $name); $id = $row['id']; $name = $row['name']; echo '<option value="'.$id.'">'.$name.'</option>'; } echo "</select>"; echo "</body>"; echo "</html>"; ?> But what I want is to get the table names from the database. Does anyone know how?
  22. updating multiple queries in php

    I want to update more than one column in php using mysql. fr example: $sql="update table_name set where username='$user'; $sql="update table_name set where password='$pass'; how to concatenate this querie? could you tell anyone how to solve this? Thanks in advance
  23. Hello everyone Anyone can help me i want show mysql records on .html page so plz tell me how i done and 2nd i m creat a sms submit form for user using text area but when i creat view.php page for show sms then show sms in one line of all text from sms so how i can do plz help me
  24. hello everyone m New In Php anyone Can Help I Want Upload Mutltifile with form name 2nd name file 1 file 2 file 3 file 4 than i want save in mysql like this id name 2ndname file3 file 4
  25. Hi guys, I'm new in PHP. I cannot find tutorial about how to get all categories article is listed in together with article title, author printed on the article list. I have 4 tables in DB: articles = DB for articles detailse: id, title, user_id, post_date articles_categories = id, category_id categories = category_id, category_name users = user_id, user_name, user_mail I want to do this: Which script logic do you suggest? Any kind of help is welcomed.
×