
swatisonee
Members-
Posts
253 -
Joined
-
Last visited
Everything posted by swatisonee
-
Oh thanks ! Where I get stuck is at the product_quote stage. But I am going to study your solution now.
-
Hi. I have a product database w/ tables each for product series, model, sub-model and optionals. One item in each of these makes up one product. So Series K, Model 7, sub-model 2, optional 3 will be a product called K 7/2-3 .The permutations and combinations of these are all possible products. In the same db, I have a quotations table. Each quotation has a unique id / record. A quotation can include any number of products : it can have K 7/2-3, KA 561/1-2 , FPN 311/2-1 or it can only have KA 561/1-2 etc. Now I am stuck. Don't know how to a. structure the quotations table b. create a MySQL select so that one statement can make multiple selections . I thought of using a checkbox but that doesn't work either since the series/model/sub model/optionals must chosen sequentially. Any ideas I can follow thru ? Many thanks Swati
-
Scrambled. I know I am missing something but cant see it ! Pointers please ! Thanks :-)
-
I have a simple login script and db DB fields : un,pw, date, sessionid and ip. The login script is also a pretty simple one . I want to be able to add a line of code that forces pw change every 90 days. Any suggestions please? What could I add and where ? The operative part of the code here. Thanks. //Process this if statement only if form was submitted if($_POST['submit']){ session_start(); //session_register("session"); $username=$_POST['username']; $password=$_POST['password']; $ip=$_SERVER['REMOTE_ADDR']; // To protect MySQL injection $myusername = stripslashes($username); $mypassword = stripslashes($password); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $encrypted_mypassword=md5($mypassword); include ("../NEWDBS.php"); //db info for DB2 //Test for login success $sql = "SELECT * FROM Users WHERE Username='$myusername' AND Password = '$encrypted_mypassword'"; $result = mysql_query($sql); if ($myrow = mysql_fetch_array($result)){ $login_success = 'Yes'; $sql2= "insert into Log(blah blah ...) "; if($_POST['submit'] && ($login_success == 'Yes') ){ $successMessage = '<p class="data"><center><font face="Antique Olive" size=2>Thank you for logging in '.$username.' !<br /><br />'; }
-
So here is what I did. Turned on compatibility view for IE10. The original code started working in IE and FF but not Chrome. Seems to be a javascript issue as the error in Chrome is "cannot read property value or null" . What can I check to resolve this please? Thanks.
-
While on the subject, I know there are several datepickers around. Can someone recommend a real simple one please? I need to pick atleast 3-4 dates in one form and then have it pass in yyyy-mm-dd format to a MySQL database. Thanks.
-
Ok, here's something I found out. The datepicker pops up, a date can be selected but the variable doesn't pass thru the form on submit when <input type=text id="todate" size=12> However, when <input type=text name="todate" size=12> the datepicker doesn't pop up nor does the date get selected. However, if one types the date in the input box, the variable passes thru the form and gets submitted. Why does the selection of id or name make a difference and how do I resolve this please? also, could this be an issue with javascript? thanks
-
Earlier when one clicked on the cal.gif icon ,the current month would appear and one could choose a date. Now clicking on the icon doesnt have the month's calender pop up.
-
Hi, My web hosting co. upgraded to php 3.4.11.1 . I was using My Datepicker from rainforest.net http://www.rainforestnet.com/datetimepicker/datetimepicker.htm and all of sudden it just doesn't work. It has worked so beautifully all these years - I have never even customised it and all of sudden I cannot figure out why Newcsscal isn't getting called. Here is the part that I use . Any pointers on what could be going wrong and what I need to do ? Thank You ! <head> <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> <title>Contacts</title> <link type="text/css" rel="stylesheet" href="NEWDBS/cssfiles/leave.css"> //<script src="./datepicker/datetimepicker_css.js"></script> // per the script creator it should be in the head but since we're calling the form, I would have it called in the body below </head> <body bgcolor=white lang=EN-IN link=blue vlink=purple> <div class=Section1> <div align=center> <form action="<?php print $PHP_SELF ?>" method="post"> <input type="hidden" name="userid" value="<? echo $userid ?>"> <input type="hidden" name="usertype" value="<? echo $usertype ?>"> <?php } else { ?> <FORM METHOD=post ACTION="<? echo $PHP_SELF ?>"> <script src="./datepicker/datetimepicker_css.js"></script> blah blah.... <input type=text name="todate" size=12> <a href="javascript:NewCssCal('todate', 'yyyymmdd')"> <img src="./datepicker/images/cal.gif" width="16" height="16" alt="Pick a date"></a></span></p>
-
Well this is what finally worked. SELECT * FROM Customers c RIGHT OUTER JOIN Reports r USING (CID) GROUP BY c.`Company` asc Thanks . S
-
Folks...anything you can spot on what might be going wrong with this code ? Much obliged. Thanks.
-
Hi: I have the foll. code. The table "Reports" has multiple records for a given value of CID in the Field CID. I'd like to be able to select only 1 of them so that a list of customers appearing in the Reports table is available for selection in the dropdown alphabetically. The foll. code does it but it doesnt list the Customers alphabetically. And when I use Join, the query doesnt run. I get a blank list . The Field CID is common to both tables- Reports and Customers. Could someone help me with the Join ? Thanks. Swat <?php $sqlco = "SELECT DISTINCT CID FROM `Reports` "; $resultco = mysql_query($sqlco) or die (mysql_error() ) ; if ($myrowco = mysql_fetch_array($resultco) ) { do { $cid = $myrowco["CID"]; $sqlrep = "SELECT * FROM `Customers` WHERE `CID` = '$cid' " ; $resultrep = mysql_query($sqlrep) or die (mysql_error() ) ; $myrowrep = mysql_fetch_array($resultrep); $company = $myrowrep["Company"]; printf("<option value=%d> %s , %s", $myrowco["CID"], $myrowrep["Company"], $myrowco["Mdate"]); } while ($myrowco = mysql_fetch_array($resultco)); } else { echo "No records found." ; } ?></select></a> What i tried was this : <?php $sqlco = "SELECT DISTINCT CID FROM `Reports` r JOIN `Customers` c WHERE r.CID = c.CID ORDER BY c.Company asc "; $resultco = mysql_query($sqlco) or die (mysql_error() ); if ($myrowco = mysql_fetch_array($resultco) ) { do { printf("<option value=%d> %s ", $myrowco["CID"], $myrowco["Company"]); } while ($myrowco = mysql_fetch_array($resultco)); } else { echo "No records found." ; } ?>
-
Sorry Pikachu missed seeing this post. I kept looking at the code and just could not figure out what was wrong - hence posted the whole thing. Then decided to bypass MAX. FWIW, can you look at the code i posted in reply to PFMaBiSmAd . Thanks !
-
I gave up on MAX. I converted the query as under : $sqlb = "SELECT (`QD`) FROM `Qts` WHERE `OCID` = '$ocid' ORDER BY `QD` DESC LIMIT 1 " ;" ; Worked.
-
Pikachu, Doesnt the code need to run thru the entire table to check for all records where OCID = $ocid and then selecting the most recent date?
-
Heres the complete code <? error_reporting(E_ALL); ini_set('display_errors','On'); include ("../include/header.php"); //db info include ("logindl.php"); //logging data // common to every scrip $userid = $_SESSION['userid']; $ocid = $_POST["ocid"]; // comes from the previous page $sqlb = "SELECT (`QD`) FROM `Quotes` WHERE `OCID` = '$ocid' " ; echo $sqlb; $resultb = mysql_query($sqlb) or die (mysql_error()); $num_rows = mysql_num_rows($resultb); for($i = 0; $i < $num_rows; $i++) { $rowb = mysql_fetch_array($resultb); $qd = $rowb["QD"]; echo $qd; // this gets echoed correctly - lists all the dates meeting the criteria. Dates are 2011-07-19 , 2011-08-26 etc $qd1 = $rowb["MAX(QD)"]; // this doesnt seem to get recognised.Ideally, it ought to output 2011-08-26 echo $qd1; } //The foll part can run only when the MAX date gets selected. $sqlo = "UPDATE Ord SET `OCD` = '$qd1' WHERE `OCID` = '$ocid' " ; $resulto = mysql_query($sqlo) or die (mysql_error()); ?>
-
Ok ...let me see if i understood that correctly. This is what i did <? error_reporting(E_ALL); ini_set('display_errors','On'); >? $sqlb = "SELECT (`QD`) FROM `Qts` WHERE `OCID` = '$ocid' " ; echo $sqlb; // echoes correctly $resultb = mysql_query($sqlb) or die (mysql_error()); $num_rows = mysql_num_rows($resultb); for($i = 0; $i < $num_rows; $i++) { $rowb = mysql_fetch_array($resultb); $qd = $rowb["QD"]; echo $qd; // lists all the dates matching the query. $qd1 = $rowb["MAX(QD)"]; // Is this correct ? echo $qd1; // No output. No error display either .
-
$resultb = mysql_query($sqlb) or die (mysql_error()); yields nothing. The query echoes correctly. No error but Max QD doesnt get output.
-
Simplest of codes and simplest of errors. Darned if i can find it tho. I simply need to select the Max of Dates in a table. This is my code. But I cannot get it to work. $sqlb = "SELECT MAX(QD) FROM `Qts` WHERE `OCID` = '$ocid' " ; //QD is the date column in YYYY-MM-DD format; $resultb = mysql_query($sqlb); $num_rows = mysql_num_rows($resultb); for($i = 0; $i < $num_rows; $i++) { $rowb = mysql_fetch_array($resultb); $qd = $rowb["QD"]; echo $qd; // should echo out the most recent date if say there were 2 entries of 2011-07-19 and 2011-08-26, then the latter should be output. } This doesnt happen. In fact the query doesnt run at all? What am I missing ? Thanks in advance for guidance ! Swati
-
It works perfectly !! Thank you so much. I ought to have thought about using JOIN.
-
Exactly and therein lies my problem. Because the 1st table has only the IDs it can sort numerically which is nullified when the city names are output thru the 2nd selection . So i wish to know how i can get the city selection sorted alphabetically.
-
I have this code below but the output on screen doesnt get sorted alphabetically. Any pointers please ? Many thanks ! $resultxx = mysql_query(" SELECT DISTINCT CITYID FROM Address ORDER BY `CITYID` asc "); //ORDER here is immaterial if ($myrowxx = mysql_fetch_array($resultxx)) { do { $cityid = $myrowxx["CITYID"]; $sqlcity1 =" SELECT * FROM Cities WHERE CITYID = $cityid ORDER BY `City` asc "; //ORDER here is irrelevant $resultcity1 = mysql_query( $sqlcity1 ) or die (mysql_error()); $myrowcity1 = mysql_fetch_array($resultcity1); printf("<option value=%d> %s", $myrowcity1["CITYID"], $myrowcity1["City"]); } while ($myrowxx = mysql_fetch_array($resultxx)); echo "</select>\n"; } else { echo "Sorry, no records were found!"; echo "</select>\n"; }
-
silly mistake ! this worked . $s1 = "select * from $dbname2.`Travelexpense` WHERE Userid='$user' && MONTH(`Enddate`)=$month && YEAR(`Enddate`)=$year AND `CID` = '$coid' AND `RID` = '$roid'"; blah blah
-
Here's what i've been attempting to do . a. I have a table "travelexpense" in 2 DBs. All columns are identical. b. Based on a set of parameters, a user can have a record in this table in one or both of the databases. c. When i want to output all the entries pertaining to that user in both these tables, I use Select Union. So far so good. d. However, the query references customers pertaining to those expenses . The customer table is present in both databases but is populated with different records. e. Now when the SELECT UNION runs, it picks up only the customer in the first database and not the second, even if there is an entry pertaining only to the second database. f. Odlly though the other data - that is the expenses themselves are selected correctly. Its only the customers entries that are wrong Code snippet below $sqlZ= " SELECT * FROM $dbname2.`Travelexpense` WHERE Userid='$user' && MONTH(`Enddate`)=$month && YEAR(`Enddate`)=$year UNION select * from $dbname3.`Travelexpense` WHERE Userid='$user' && MONTH(`Enddate`)=$month && YEAR(`Enddate`)=$year "; $resultZ = mysql_query($sqlZ) or die (mysql_error()); $numofrows = mysql_num_rows($resultZ); for($i = 0; $i < $numofrows; $i++) { $myrowZ = mysql_fetch_array($resultZ); $coid = $myrowZ["CID"]; $s1 = "SELECT * FROM $dbname2.`Customers` WHERE `CID` = $coid UNION select * from $dbname3.`Customers` WHERE `CID` = $coid"; $result1 = mysql_query($s1); $myrow2 = mysql_fetch_array($result1); $Name=$myrow2["Company"]; //here's the problem . If say $coid = 150 , then it will look only at record 150 in Table Customers in dbname2 and NOT in Table Customers in dbname3 even if only dbname3 has a relevant entry. blah blah } Am i using UNION incorrectly esp in the query $s1? Appreciate any help . Thanks ! Swati
-
Ok let me see if i can explain this better. Net net i'm missing the point and dont know how to set it right . a. User logs in with un, pw as per a script login.php. b. This scrip also contains the foll. code where he is directed to a page (sales.php or hr.php) based on usertype. - as per code snippet below c. If say, usertype is 8, he get directed to sales.php which should as per modified code check that the user is indeed of type 8. d. Now what was happening earlier was that by simply changing sales.php to hr.php in the browser address bar , he could access the latter page. e. The problem that i find with the modification made above is for scripts that are a common feature to both sales.php and hr.php. Say for example checking of individial leave records where the script is common to users of both sales and hr have . Trying something like this code doesnt work if ( (isset($_SESSION['userid']) && (($_SESSION['usertype']) !=8 ) ) OR (isset($_SESSION['userid']) && (($_SESSION['usertype']) !=3 )) ) { echo "You are not authorised to access this page exit;} //it rejects both usertypes 8 and 3 Code for login.php if($_POST['submit']) { session_start(); blah blah ... $sql = "SELECT * FROM Users WHERE ........."; $result = mysql_query($sql); if ($myrow = mysql_fetch_array($result)) { $login_success = 'Yes'; $userid = $myrow["Userid"]; $usertype = $myrow["UTID"]; $status = "On"; $_SESSION['id']=session_id(); $sql2= "insert into Log (Sessionid,Userid,IP,Date,File, Status) values('$_SESSION[id]','$userid','$ip','$tm', '$url', '$status')"; $result2 = mysql_query($sql2) or die ('no access to database: ' . mysql_error()); if ($usertype =='5' ) { $userFile = 'hr.php'; } if ($usertype =='8' ) { $userFile = 'sales.php'; } if ($usertype =='9' ) { $userFile = 'head.php'; } } } $_SESSION['userid']=$userid; $_SESSION['usertype']=$usertype; some html stuff and then $successMessage .= 'Click <a href="'.$userFile.'?Userid='.$userid.'"> here </a>to proceed to your options';