gardan06
-
Posts
75 -
Joined
-
Last visited
Never
Posts posted by gardan06
-
-
someone out there has got to have a solution to this...
-
anyone?
-
i have this table:
i merged PRs A to F in Merged1.
my problem is that i want to know which rows from A to F belong to sub_dept_code 1-5, then the other from 6-9, so that will make 2 count(*) queries right?
my current query right now (which works by the way) is:
select * from (select count(*) as total1 from PR where PRNo in ('A','B','C','D','E','F') and sub_dept_code in ('1','2','3','4','5')) as z, (select count(*) as total2 from PR where PRNo in ('A','B','C','D','E','F') and sub_dept_code in ('6','7','8','9')) as y
..but i feel there's a better way to code it. is there a better and more optimal way to translate my query, or is this it?
-
i currently have this code:
select c.sku,c.sku_desc,a.po_no,b.actual_vendor_code as vendor_code,unit_cost,b.receivedate as issuedbydate from sku c left outer join purchase_detail a on (c.sku=a.sku) inner join purchase_hdr b on (a.po_no=b.po_no) where b.po_status='RR_PO' and c.dept_code='2' order by c.sku,b.receivedate descbut i want to group them per sku, so i tried:
select c.sku,c.sku_desc,a.po_no,b.actual_vendor_code as vendor_code,unit_cost,b.receivedate as issuedbydate from sku c left outer join purchase_detail a on (c.sku=a.sku) inner join purchase_hdr b on (a.po_no=b.po_no) where b.po_status='RR_PO' and c.dept_code='2' group by c.sku order by c.sku,b.receivedate descthe problem was it didn't recognize the receivedate ordering so while it did show only one SKU item, it also showed the earliest item, not the latest.
i also tried:
select distinct(c.sku),c.sku_desc,a.po_no,b.actual_vendor_code as vendor_code,unit_cost,b.receivedate as issuedbydate from sku c left outer join purchase_detail a on (c.sku=a.sku) inner join purchase_hdr b on (a.po_no=b.po_no) where b.po_status='RR_PO' and c.dept_code='2' order by c.sku,b.receivedate descbut the results were the same as the 1st one.
would anyone be kind enough to show me how to code the query in a way that only one SKU item is shown and it should be the latest one.
your help is greatly appreciated. thank you.
-
oh i got it. instead of using style.visibility set to hidden or visible, i used a span tag and set style.display to inline or none.
thanks for the help guys.
-
well basically, i'm trying to have either an edit button or add button appear depending on an inputted item. if the item already exists on the database, the edit button appears. if it doesnt, the add button appears.
the button positions are like this(they're hidden by default):
Clear Add Editi want the edit button to appear in the same position as the add button because for sure, they wont be appearing at the same time, but unfortunately, i had difficulty doing that.
can anyone help me? i'd really appreciate your immediate response.
thank you.
Gardan
-
never mind, i got it.
to those who doesn't know yet, the command is $_SERVER['HTTP_HOST']
thanks for your time guys.
-
long story short, is there a command that outputs your site's URL? (ex. http://www.phpfreaks.net/ will be outputted)
thanks in advance.
-
function updatePOHead(url) { if (url==undefined) url=''; var arr = new Array(); var optVendorKey = document.getElementById("optVendorKey").value; var optShipToKey = document.getElementById("optShipToKey").value; var txtPONumber = document.getElementById("txtPONumber").value; var optPOStatus = document.getElementById("optPOStatus").value; var optTermsKey = document.getElementById("optTermsKey").value; //var txtDiscount = document.getElementById("txtDiscount").value; var txtOrderDate = document.getElementById("txtOrderDate").value; var txtDeliveryDate = document.getElementById("txtDeliveryDate").value; var optPOType = document.getElementById("optPOType").value; var txtCancelDate = document.getElementById("txtCancelDate").value; //var radTermsKey; var txtDiscount = 0; var radTermsKey = ''; var controls = document.frmPO.length; var cnt = 0; var element; for (i = 0; i < controls; i++) { element = document.frmPO[i]; if (element.type == "radio") { if (element.checked == true) { radTermsKey = element.value; cnt++; } } } arr.push(optVendorKey); arr.push(optShipToKey); arr.push(optPOStatus); arr.push(optTermsKey); arr.push(txtDiscount); arr.push(radTermsKey); arr.push(txtOrderDate); arr.push(txtDeliveryDate); arr.push(optPOType); arr.push(txtCancelDate); //alert(arr.toString()); if(confirm("Save all changes?")) { alert(url); agent.call("", "updatepodraft", "callback_updatePOHead", txtPONumber, url, arr.toString()); } else { window.location=url; } } function callback_updatePOHead(response) { var message = document.getElementById("message"); alert(response[0]); alert(response[1]); return false; if (response[1]=='') { if(response[0]==1) response[0] = 'RECORD SAVED'; else response[0] = 'RECORD NOT SAVED, ERROR RUNNING COMMAND'; message.innerHTML = response[0]; } else { alert('Record Saved'); window.location=response[1]; } }
function updatepodraft($po, $url, $arr) { global $db; $h = array(); $h = split(',',$arr); $sql = sprintf("update purchase_hdr set actual_vendor_code = '%s', ship_location_code = %s, po_status = '%s', terms_code = '%s', discount = %01.03f, discount_type = '%s', po_date = '%s', recdate = '%s', item_type_code = '%s', canceledbydate = '%s' where po_no = '%s'", $h[0], $h[1], $h[2], $h[3], $h[4], $h[5], $h[6], $h[7], $h[8], $h[9], $po); /*$rs = $db->db_query($sql); if(!$rs) $bjarr[0] = false; else $bjarr[0] = true;*/ $bjarr[0] = $sql; $bjarr[1] = $url; //$db->db_free_result($rs); return $bjarr; }
What im trying to do is save the url as it was called from the javascript function to the PHP function and then back to the callback javascript function for the wind.location command.
But the weird part is that somewhere between the javascript to php agent function, the url gets cut short (i.e. index.php?mode=po_entry&sub=header&po=xxxx becomes index.php?mode=po_entry). I have tried to error check if there's another way the url got cut short, but as i error checked every javascript code leading to the php code, i concluded that the problem would have occured on the translation to the php code.
in addition, the url always get cut short to index.php?mode=po_entry, which made me think that the ampersand (&) probably have something to do with it, but it didnt.
So pphp gurus, i ask for your help. Please tell me what went wrong in my code?
Thanks.
-
never mind, i got it myself..
seems like concat can be exploited to create your own like comparison
-
i have 2 tables joined wherein a.seq_no (w/c value is either 1, 2 or 3) should exist in b.number_choice(w/c value is either 1*, 1*2* or 1*2*3*).
is using the like function to a variable possible?
-
Ok, i have no problem using window.open() it works fine to me.
However, the problem is that the page's table is too long, it doesnt fit to an A4 in printing, even in landscape mode. The worse part is that it does not create a second page for the part that was cut, but what was weird is that it only doesnt accept 2nd pages horizontally, vertically long pages are 2nd page-able.
My question is: how can i be able to print that 2nd page?
-
amazing!SELECT a.name, a.qty, a.qty*100/x.tot as pc
FROM tablename a
JOIN (select SUM(qty) as tot from tablename) as x
thanks a lot!
-
I want my table to view percentages. Here's how:
Name Qty Pct QtyJohn 10 10%
...
Kerry 2 2%
__________________________________
100 100%
I want "Pct Qty" to automatically compute the percent of the "Qty" by the formula (qty/total qty)*100.
is it possible ?
thanks.
-
simple, you got $rs['1'] + $userp['total'] = $new; all backwards.
try
$new = $rs['1'] + $userp['total'];
-
if you want to return a text value from your webpage, then simply use either $_GET['variable_name'] or $_POST['variable_name'] depending on what your form method is.
if you want to return a text value from someone else's webpage, then that would be borderline hacking.
-
have you tried checking your query for errors? if not, try echoing your query. your problem could be your query variable not generating the right query.
-
I have:
<div id="name"></div>
Given the names "Michael", "Lue" and "Rachel" for example, how can i loop these 3 inside the div given? Is it even possible?
In case you guys are wondering, i need it to put names in a table wherein the column has a limited width and height. Needless to say, it should only occupy 1 line, thus this solution.
Thanks.
-
given this:
<div>Put text here.</div>is there a way in javascript to change the string inside the div from "Put text here." to something else? if yes, how?
Thanks.
Jay
-
i still have this problem so if anyone can give me a hand on this, i'd really appreciate it.
sorry for the bump. thanks.
-
anyone?
-
I did that and now I get this error
Parse error: syntax error, unexpected T_VARIABLE in /home/mesquit1/public_html/local/browse.php on line 24
I added parenthesis as suggested
$query = "SELECT * FROM table LIMIT "$limitvalue", "$limit"";
<-- no parenthesis
Of did you mean like this.
$query = "SELECT * FROM table LIMIT ($limitvalue", "$limit)";
<-- wrong quotations
That gives me the previous error.
do it like this:
$query = "SELECT * FROM table LIMIT (".$limitvalue.", ".$limit.")";
or
$query = "SELECT * FROM table LIMIT ({$limitvalue}, {$limit})";
-
I have tried the tutorial and I get this error.
Error: 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 'table LIMIT 0, 25' at line 1
Not sure where to go from here. Here is the code I am working with.
<?php include ('db_connect.php'); function show_data(){ $id = array(); $imgurl = array(); $address = array(); $city = array(); $state = array(); $postal = array(); $country = array(); $id = mysql_real_escape_string($_GET['id']); $i=0; if(isset($id)) { $limit = 25; $query_count = "SELECT count(*) FROM table"; if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM table LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } { $i = 0; while ($row = mysql_fetch_array ($result)) { $color = ($i%2== 0 || $i == 0)?'#DDDDDD':'#EEEEEE'; $id[$i] = $row["id"]; $imgurl[$i] = $row["imgurl"]; $address[$i] = $row["address"]; $city[$i] = $row["city"]; $state[$i] = $row["state"]; $postal[$i] = $row["postal"]; $country[$i] = $row["country"]; print"<tr bgcolor='".$color."'> <td class='bg3' width=110> <a href='/local/display.php?id= $id[$i]'> <img src='$imgurl[$i]' class='border' height'75' width='100'> </a> </td> <td class='bg3'>$address[$i]<br>$city[$i] $state[$i] $postal[$i]<br>$country[$i]</td> <td class='bg3' style='vertical-align: middle'>> <a href='display.php?id=$id[$i]'><b>Learn more about Display</b></a><br><br>> <a href='http://www.mapquest.com/maps/map.adp?searchtype=address&formtype=search&countryid=US&addtohistory=&country=US&address=$address[$i]&city=$city[$i]&zipcode=$postal[$i]&historyid=&submit=Get+Map' target='BLANK'> <b>Get Directions</b> </a> </td> </tr>"; ++$i; if($page != 1){ $pageprev = $page--; echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> "); }else{ echo("PREV".$limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); } mysql_free_result($result); } } } } ?>
-Thanks
you didnt put a parenthesis between the limit inputs.
select * from table limit(x,y);
-
well, fortunately, im also filipino.in my script, does it mean that for every page, i still have to find out what the very first row is? i guess it will be if there is no other way, but that's why i'm here, to find out if there IS another way.
sorry i still dont get it.. i wonder if it was my bad english that makes me hard to understand you?
maybe we can talk through private messaging using tagalog instead?
Saving Japanese Characters to MySQL tables
in MySQL Help
Posted
So we have a website that runs on ASP, PHP and mySQL and so far, the japanese text are working fine with meta charset set to "shift_jis". However, i need to call values from the database that are also japanese characters, and this is where my problems begin.
Firstly, i set collation to utf8, encoded the japanese text to utf8 then stored it in the database. i tried to decode it in the page that calls for that value, but it returns a different japanese text than the one i actually set, probably because meta charset is set to shift_jis. then, i set the column's collation to sjis, and tried to store the japanese text to the database, but it returns "????" and that was the the output on the actual page.
So im in a deep hole right now. I need to output the correct japanese text from the database to the page that calls it, but how would i do that?
Any kind of help is greatly appreciated. Thank you very much.