Jump to content

abrahamgarcia27

Members
  • Posts

    131
  • Joined

  • Last visited

Everything posted by abrahamgarcia27

  1. I have a query that outputs certain values in a table, but i want to put a conditional if statement. What i have right now is if the status is 1 echo Close and if the status is 0 Open what i want it to do now is not to show the values that have 1 along with all the other database table entries how would i do that //if statement for status if($rows['status'] == 1) { $status = "Close"; } else $status = "Open"; ?>
  2. I have the following code which is a jquery timer, but i cannot seem to make the jquery function work in a while loop. Does any one have an idea of what i can do? <?php //begin the while loop while ($rows = mysql_fetch_assoc($sql)){ //if statement for status if($rows[$status] == 1) { $status = "Close"; } else { $status = "Open"; } ?> <td><?php echo $rows[$fname]?></td> <td><?php echo $rows[$people]?></td> <td><?php echo $rows[$tnumber]?></td> <td><?php echo $rows[$waiter]?></td> <td id="demo1" class="demo"></td> <td><?php echo $status ?></td> </tr> <?php } ?> </tbody> </table> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <script src="js/jquery.stopwatch.js"></script> <script> $(document).ready(function() { $('#demo1').stopwatch().stopwatch('start'); }); </script> </body> </html> Here is the code for the Stop Watch /* */ (function( $ ){ function incrementer(ct, increment) { return function() { ct+=increment; return ct; }; } function pad2(number) { return (number < 10 ? '0' : '') + number; } function formatMilliseconds(millis) { var x, seconds, minutes, hours; x = millis / 1000; seconds = Math.floor(x % 60); x /= 60; minutes = Math.floor(x % 60); x /= 60; hours = Math.floor(x % 24); // x /= 24; // days = Math.floor(x); return [pad2(hours), pad2(minutes), pad2(seconds)].join(':'); } var methods = { init: function(options) { var settings = { updateInterval: 1000, startTime: 0, formatter: formatMilliseconds }; if (options) { $.extend(settings, options); } return this.each(function() { var $this = $(this), data = $this.data('stopwatch'); // If the plugin hasn't been initialized yet if (!data) { // Setup the stopwatch data data = settings; data.target = $this; data.elapsed = settings.startTime; // create counter data.incrementer = incrementer(data.startTime, data.updateInterval); data.tick_function = function() { var millis = data.incrementer(); data.elapsed = millis; data.target.trigger('tick.stopwatch', [millis]); data.target.stopwatch('render', millis); }; $this.data('stopwatch', data); } }); }, start: function() { return this.each(function() { var $this = $(this), data = $this.data('stopwatch'); // Mark as active data.active = true; data.timerID = setInterval(data.tick_function, data.updateInterval) $this.data('stopwatch', data); }); }, stop: function() { return this.each(function() { var $this = $(this), data = $this.data('stopwatch'); clearInterval(data.timerID); data.active = false; $this.data('stopwatch', data); }); }, destroy: function() { return this.each(function(){ var $this = $(this), data = $this.data('stopwatch'); $this.stopwatch('stop').unbind('.stopwatch').removeData('stopwatch'); }) }, render: function(ct) { var $this = $(this), data = $this.data('stopwatch'); $this.html(data.formatter(ct)); }, toggle: function() { return this.each(function() { var $this = $(this); var data = $this.data('stopwatch'); if (data.active) { $this.stopwatch('stop'); } else { $this.stopwatch('start'); } }); }, reset: function() { return this.each(function() { var $this = $(this); data = $this.data('stopwatch'); data.incrementer = incrementer(data.startTime, data.updateInterval); data.elapsed = data.startTime; $this.data('stopwatch', data); }); } }; // Define the function $.fn.stopwatch = function( method ) { if (methods[method]) { return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); } else if (typeof method === 'object' || !method) { return methods.init.apply(this, arguments); } else { $.error( 'Method ' + method + ' does not exist on jQuery.stopwatch' ); } }; })( jQuery );
  3. This is the code that worked for me no i just have another question on how to close the modal dialog box when i select a button <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Local Store Reservation Form</title> <link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" /> <script src="lib/jquery.js" type="text/javascript"></script> <script src="src/facebox.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function($) { $('a[rel*=facebox]').facebox({ loadingImage : 'src/loading.gif', closeImage : 'src/closelabel.png' }) }) </script> <!-- jQuery & jQuery UI + theme (required) --> <link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.15.custom.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <!-- keyboard widget css & script (required) --> <link rel="stylesheet" href="css/keyboard.css"> <script src="js/jquery.keyboard.js"></script> <!-- keyboard extensions (optional) --> <script src="js/jquery.mousewheel.js"></script> <!-- <script src="js/jquery.keyboard.extension-typing.js"></script> <script src="js/jquery.keyboard.extension-autocomplete.js"></script> --> <!-- initialize keyboard (required) --> <script> $(function(){ $('#keyboard').keyboard(); }); </script> <script> $(function(){ $('#keyboard2').keyboard(); }); </script> <script> $(function(){ $('#keyboard3').keyboard(); }); </script> <script> $(function(){ $('#keyboard4').keyboard(); }); </script> </head> <body> <form name="registerreservation" method="post" action="localregister.php"> <table width="600px" align="center"> <tr> <td valign="middle"> <label for ="fname">Full Name: </label> </td> <td valign="middle"> <input id="keyboard" type="text" name="fname" maxlength="50" height="30"size="30" /> </td> </tr> <tr> <td valign="middle"> <label for="n_people">People Attending:</label> </td> <td valign="middle"> <input id="keyboard2" type="text" name="n_people" maxlength="50" height="30" size="30" /> </td> </tr> <tr> <td valign="middle"> <label for="t_number">Table Number: </label> </td> <td valign="middle"> <a href="#info" rel="facebox"><input type="text" name="t_number" value="Select a Table..." height="30" maxlength="50" size="30" /></a> </tr> <tr> <td valign="middle"> <label for="waiter"> Waiter: </label> </td> <td valign="middle"> <?php $con=mysql_connect("localhost","root","") or die("couldn't connect to mysql"); $db=mysql_select_db("ac_res",$con) or die("database not found"); $result=mysql_query("SELECT fname FROM waiter") or die("query error"); echo "<select name=waiter>"; while($r=mysql_fetch_array($result)) { //echo $r['name']; echo "<option value='".$r['fname']."'>".$r['fname']."</option>"; } echo "</select>"; ?> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" name="reserve" value="Reserve"/> </td> </tr> </table> </form> <div id="info" style="display:none;"> <code> <button>1</button> <button>2</button> <button>3</button> <button>4</button> <button>5</button> <button>6</button> </code> <script> $("button").click(function () { var text = $(this).text(); $('input[name*="t_number"]').val(text); }); </script> </div> </body> </html>
  4. I am totally new to coding and i came across a problem that i havent figured out how to do it. I have a basic registration form with the following fields (Full Name, People Attending, Table Number, Waiter) The 'Table Number' Field calls a variable from another form so when i click on table Number a pop out window with jquery pops out with a Restaurant Table like Diagram. Each button which symbolizes a table has a numerical value. What i want to do is post the value selected from the table form into the Table field in my main form. I have gotten this far, but the problem is that when select a table it refreshes my original page. I was wondering if anyone had an idea how i could attack this problem.
  5. I am totally new to coding and i came across a problem that i havent figured out how to do it. I have a basic registration form with the following fields (Full Name, People Attending, Table Number, Waiter) The 'Table Number' Field calls a variable from another form so when i click on table Number a pop out window with jquery pops out with a Restaurant Table like Diagram. Each button which symbolizes a table has a numerical value. What i want to do is post the value selected from the table form into the Table field in my main form. I have gotten this far, but the problem is that when select a table it refreshes my original page. I was wondering if anyone had an idea how i could attack this problem.
  6. Hello I am working on a table reservation application for a restaurant i am really new to coding i have the in restaurant reservation form <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Local Store Reservation Form</title> <link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" /> <script src="lib/jquery.js" type="text/javascript"></script> <script src="src/facebox.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function($) { $('a[rel*=facebox]').facebox({ loadingImage : 'src/loading.gif', closeImage : 'src/closelabel.png' }) }) </script> <!-- jQuery & jQuery UI + theme (required) --> <link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.15.custom.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <!-- keyboard widget css & script (required) --> <link rel="stylesheet" href="css/keyboard.css"> <script src="js/jquery.keyboard.js"></script> <!-- keyboard extensions (optional) --> <script src="js/jquery.mousewheel.js"></script> <!-- <script src="js/jquery.keyboard.extension-typing.js"></script> <script src="js/jquery.keyboard.extension-autocomplete.js"></script> --> <!-- initialize keyboard (required) --> <script> $(function(){ $('#keyboard').keyboard(); }); </script> <script> $(function(){ $('#keyboard2').keyboard(); }); </script> <script> $(function(){ $('#keyboard3').keyboard(); }); </script> <script> $(function(){ $('#keyboard4').keyboard(); }); </script> </head> <body> <form name="registerreservation" method="post" action="localregister.php"> <table width="600px" align="center"> <tr> <td valign="middle"> <label for ="fname">Full Name: </label> </td> <td valign="middle"> <input id="keyboard" type="text" name="fname" maxlength="50" height="30"size="30" /> </td> </tr> <tr> <td valign="middle"> <label for="n_people">People Attending:</label> </td> <td valign="middle"> <input id="keyboard2" type="text" name="n_people" maxlength="50" height="30" size="30" /> </td> </tr> <tr> <td valign="middle"> <label for="t_number">Table Number: </label> </td> <td valign="middle"> <a href="tables.html" rel="facebox"><input type="text" name="t_number" id= "tables" value="" height="30" maxlength="50" size="30" /></a> </tr> <tr> <td valign="middle"> <label for="waiter"> Waiter: </label> </td> <td valign="middle"> <input id="keyboard4" type="text" name="waiter" height="30" maxlength="50" size="30" /> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" name="reserve" value="Reserve"/> </td> </tr> </table> </form> </body> </html> on the table field i have pop out box with jquery that pulls another html form. I have a button that has a value of 5 which is symbolic to the table number. I want that value to transfer to my main form. here is the html form for the tables <!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>Tables</title> </head> <body> <input type="submit" value="5" /> </body> </html> what would be the easiest way to do this?
  7. i was reading but it seem that it doesnt do spanish to english does it?
  8. Hello i am trying to translate a table field, but i am having trouble with the syntax Translating Script <?php require("GTranslate.php"); error_reporting(E_ALL); ini_set('display_error',1); /** * Example using RequestHTTP */ $translate_string = "¿Cómo está usted"; try{ $gt = new Gtranslate; echo "".$gt->spanish_to_english($translate_string)."\n"; } catch (GTranslateException $ge) { echo $ge->getMessage(); } ?> and here is a table field example i want to translate <td><?php echo nl2br(str_replace(array('\n', '\r'), "\n", $item->tablefield));?></td> i am totally new to php
  9. i am sorry i am new to programming and i would want to know what would be the safest way to protect for security issues?
  10. I dont want to obfusucate the password my database is composed of the following member_id (auto increment) this is the one i want to obfusucate firstname lastname login password (md5) Is there a way to do this? and how would i do it?
  11. edituser.php?id=10 I have this user page edit function, but i have a question for my password i have the md5 key could i do the same for my member_id primary key? so instead of edituser.php?id=10 [/code/ it gives me something like this [code] edituser.php?id=asdf54as54f14asdf874asdfasd
  12. I am working on a button that will delete a User from a database. Is there a way i can pop out a warning message "your user will be deleted are you sure YES or NO" before running the delete query
  13. try moving the session_start(); to the beginning of the php script
  14. mjdamato I am just trying to learn to code and i thought this would be a cool way to start. Could you tell me where there is alot wrong with the code that can cause failures and malicious attacks so i can train myself in writing better code? I got it to work by the way, but i still have to add the hash to the password and other stuff to the form Pikachu2000 I found the php.ini file, but i cant find the part with error reporting you gave me i found this ; Eval the expression with current error_reporting(). Set to true if you want ; error_reporting(0) around the eval(). ;assert.quiet_eval = 0 ;error_reporting = E_ALL & ~E_NOTICE ; ; - Show all errors, except for notices ; ;error_reporting = E_ALL & ~E_NOTICE | E_STRICT ; ; - Show only errors ; ;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR ; ; - Show all errors except for notices and coding standards warnings ; error_reporting = E_ALL & ~E_NOTICE ; Print out errors (as a part of the output). For production web sites, ; you're strongly encouraged to turn this feature off, and use error logging ; instead (see below). Keeping display_errors enabled on a production web site ; may reveal security information to end users, such as file paths on your Web ; server, your database schema or other information. display_errors = On ; Even when display_errors is on, errors that occur during PHP's startup ; sequence are not displayed. It's strongly recommended to keep ; display_startup_errors off, except for when debugging. display_startup_errors = Off
  15. I got this Query: UPDATE newUsers2 SET firstname='may', lastname='may', login='may', passwd='may', userType='' WHERE id='12' Error: Unknown column 'id' in 'where clause'
  16. I am having trouble updating a table. I cant's seem to make it work. Does anyone see anything wrong with the code? This is the form where the data from the database is populated <?php require_once('auth.php'); ?> <?php //Start session session_start(); ?> <!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>Edit User</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>Edit User</h1> <a href="member-profile.php">Orders</a> | <a href="users.php">Users</a> | <a href="logout.php">Logout</a> <?php //Include database connection details require_once('config.php'); //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $id = $_GET['id']; $sql = 'SELECT * FROM `newUsers2` WHERE `member_id` = "'.$id.'"'; $query = mysql_query($sql) or die("Couldn't execute query. ". mysql_error()); $results = mysql_fetch_array($query); ?> <form id="edituser" name="edituser" method="post" action="edituser-exec.php"> <table width="300" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <th> </th> <td><input name="old_member_id" type="hidden" class="textfield" value= <?php echo $results[member_id]?> /> </td> </tr> <tr> <th>First Name </th> <td><input name="old_fname" type="text" class="textfield" value= <?php echo $results[firstname]?> /> </td> </tr> <tr> <th>Last Name </th> <td><input name="old_lname" type="text" class="textfield" value= <?php echo $results[lastname]?> /> </td> </tr> <tr> <th width="124">Login</th> <td width="168"><input name="old_login" type="text" class="textfield" value= <?php echo $results[login]?> /> </td> </tr> <tr> <th>Password</th> <td><input name="old_password" type="password" class="textfield" value= <?php echo $results[passwd]?> /> </td> </tr> <tr> <th>Confirm Password </th> <td><input name="old_cpassword" type="password" class="textfield" value= <?php echo $results[passwd]?> /> </td> </tr> <tr> <th>Admin Rights </th> <td><input name="old_userType" type="checkbox" value=<?php echo $results[userType]?> /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Update" value="Update" /></td> </tr> </table> </form> </body> </html> this is the update page <?php require_once('auth.php'); ?> <?php //Start session session_start(); ?> <!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>Edit User</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>Edit User</h1> <a href="member-profile.php">Orders</a> | <a href="users.php">Users</a> | <a href="logout.php">Logout</a> <?php //Include database connection details require_once('config.php'); //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $old_id=$_POST['old_member_id']; $old_fname=$_POST['old_fname']; $old_lname=$_POST['old_lname']; $old_login=$_POST['old_login']; $old_password=$_POST['old_password']; $old_userType=$_POST['old_userType']; $query="UPDATE newUsers2 SET firstname='$old_fname', lastname='$old_lname', login='$old_login', passwd='$old_password', userType='$old_userType' WHERE id='$old_id'"; mysql_query($query); echo "Record Updated"; mysql_close(); ?> </body> </html>
  17. how would you structure a update query i know for inserting i used this, but how would i structure a Update Query? //Create INSERT query $qry = "INSERT INTO newUsers2(firstname, lastname, login, passwd, userType) VALUES('$fname','$lname','$login','".md5($_POST['password'])."', '$userType')"; $result = @mysql_query($qry);
  18. I am new to programming and i wanted to see how i can update data that is already in my database through an edit button, but i want it to edit only that member_id (primary key) my database is composed of the following member_id (auto increment) firstname lastname login password usertype $sql = mysql_query("SELECT * FROM newUsers2 ORDER BY member_id ASC"); $id = 'member_id'; $fname = 'firstname'; $lname = 'lastname'; $login = 'login'; echo '<ul class="list">' ; echo '<li class="heading">'; echo '<span class="id">ID </span>' ; echo '<span class="firstname">FIRST NAME </span>' ; echo '<span class="lastname">LAST NAME </span>' ; echo '<span class="login">LOGIN </span>' ; echo '<span class="userType">ADMIN RIGHTS</span>'; echo '<span class="edit">EDIT</span>'; echo '</li>' ; while ($rows = mysql_fetch_assoc($sql)){ if($rows['userType'] == 1) { $userTypeValue = "YES"; } else { $userTypeValue = "NO"; } echo '<li class="entries">' ; echo '<span class="id">' .$rows[$id]. '</span>' ; echo '<span class="firstname">' .$rows[$fname]. '</span>' ; echo '<span class="lastname">' .$rows[$lname]. '</span>' ; echo '<span class= "login">' .$rows[$login]. '</span>'; echo '<span class="userType">' .$userTypeValue. '</span>' ; echo '<span class="edit"> <a href="edituser.php">EDIT</a> </span>'; echo '</li>' ; } echo '</ul>' ; ?> [attachment deleted by admin]
  19. the field in the table of my database is userType if echo just userType this is what i get [attachment deleted by admin]
  20. I tried it and I been moving that code around can't make it seem to work any other suggestions?
  21. Hello i am new to programming and i am trying to create an if statement for a tinyint i have in my database, but don't know where to place it. Basically i want to say when $userType equals 0 "NO" and when $userType equals 1 "YES" this is to present in a table <?php require_once('auth.php'); ?> <?php //Start session session_start(); ?> <!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>View Users</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { font: 11px Verdana, Arial, Helvetica, sans-serif; color: #666666; margin: 0px; padding: 20px 10px 0px; } /* general style */ .list{ margin:0; padding:0; width:840px; } .list li{ list-style: none; margin:2px 0; overflow:hidden; border-bottom:1px solid #eee; } .entries span, .heading span{ display:block; width:155px; /* (~width of list) / 5 keep in mind the boxmodel*/ float:left; padding-left:12px; border-right:1px solid #eee; line-height: 30px; height:30px; } .heading span{ background: #CAE8EA; } /* entries */ </style> </head> <body> <h1>View Users</h1> <a href="member-profile.php">Orders</a> | <a href="users.php">Users</a> | <a href="logout.php">Logout</a> <?php //Include database connection details require_once('config.php'); //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); $sql = mysql_query("SELECT * FROM newUsers2 ORDER BY member_id ASC"); $id = 'member_id'; $fname = 'firstname'; $lname = 'lastname'; $login = 'login'; $userType = 'userType'; echo '<ul class="list">' ; echo '<li class="heading">'; echo '<span class="id">ID </span>' ; echo '<span class="firstname">FIRST NAME </span>' ; echo '<span class="lastname">LAST NAME </span>' ; echo '<span class="login">LOGIN </span>' ; echo '<span class="userType">ADMIN RIGHTS</span>'; echo '</li>' ; while ($rows = mysql_fetch_assoc($sql)){ echo '<li class="entries">' ; echo '<span class="id">' .$rows[$id]. '</span>' ; echo '<span class="firstname">' .$rows[$fname]. '</span>' ; echo '<span class="lastname">' .$rows[$lname]. '</span>' ; echo '<span class= "login">' .$rows[$login]. '</span>'; echo '<span class="userType">' .$rows[$userType]. if ($userType == 0) { echo "NO"; } elseif ($userType == 1) { echo "YES"};'</span>' ; echo '</li>' ; } echo '</ul>' ; ?> </body> </html>
×
×
  • 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.