lansing
Members-
Posts
15 -
Joined
-
Last visited
Never
Contact Methods
-
Website URL
http://
Profile Information
-
Gender
Not Telling
-
Location
Clinton, TN USA
lansing's Achievements
Newbie (1/5)
0
Reputation
-
I do not see a reply link any were on in the PHP Freelancing area of this forum. What is up with this? Regards, Jason
-
[quote author=obsidian link=topic=107240.msg429978#msg429978 date=1157646497] [code] <?php $sql = mysql_query("SELECT * FROM users LEFT JOIN membership_fees WHERE users.user_id = membership_fees.user_id LIMIT $skip, $show"); $total = 0; while ($x = mysql_fetch_array($sql)) { $fee = $x['membership_fee']; $total += $fee; } ?> [/code] [/quote]What is this part about: [i][b]LEFT JOIN membership_fees WHERE users.user_id = membership_fees.user_id[/b][/i]? I didn't say anything about user or user_id. I tried to change the line to match my variables, but couldn't get anything to work.
-
I am using a very simple pagination script. I am trying to get use Mathematics with the records displayed on the page. Like if I limit it to 5 records per page & need to be able to use Mathematics on those 5 records. [u][b]Scenario:[/b][/u] Limit 5 records per page. Each record has a membership fee Need to add the total membership fees for those 5 records. I am picturing having the table rows stop & then having 2 rows after the pagination rows. With the 5 table rows created on my page by the pagination script I am placing making the next row show totals for the selected records, but the last row will show totals for the entire database. I have that last row working, but can't seem to get the query code to total up just those 5 records that the pagination selected from the db. I hope I haven't lost you. Here is what I have now & it isn't working. The LIMIT $skip,$show is the same code that the pagination script uses in its processings.[code=php:0] $total_paid ="SELECT SUM(membership_fees) as membership_fees_paid FROM $membership_fees_table LIMIT $skip,$show"; [/code]
-
[quote author=btherl link=topic=107192.msg429690#msg429690 date=1157598105] Lansing, do you want entries which are in both Table A and Table B, or entries which are in Table A and NOT in Table B? If you want entries in Table A and Table B, then inner join will work. If you want entries in Table A but NOT in Table B, then you need to use this: [code]SELECT a.* FROM $order_table a LEFT OUTER JOIN $commisions_table b ON (a.user_id = b.user_id) WHERE b.user_id IS NULL[/code] This will give you all rows from Table A which does NOT match a row from Table B. This is because an outer join puts NULL in the b.user_id (and all columns from b) if no row from b was found. [/quote]Thanks...works great.
-
I have [b]TableA[/b] & [b]Table[/b]B. I am quering [b]TableA[/b] for records, but only want to pull record data if the [i][b]record_id[/b][/i] from [b]TableA[/b] is in [b]TableB[/b]. I have posted other places & came to the conclusion that I need to use [i]INNER JOIN[/i] to accomplish what I need. I have posted what I have below, but this code keeps pulling data from [b]TableB[/b] & not [b]TableA[/b]. To fully explain this the first time. I am taking the records from [b]TableA[/b] that are NOT in [b]TableB[/b] & displaying them in a drop down menu. I then use this data on my page. [code=php:0] mysql_select_db($db_name, $conn); $query_seminars = ("SELECT a.customers_id, a.order_id, a.order_date, a.referring_id, a.order_status FROM $order_table a INNER JOIN $commisions_table b ON (a.order_id=b.order_id) WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= a.order_date AND a.referring_id != '' AND a.order_status = 'Filled' ORDER BY a.order_id DESC"); $seminars = mysql_query($query_seminars, $conn) or die(mysql_error()); $row_seminars = mysql_fetch_assoc($seminars); $totalRows_seminars = mysql_num_rows($seminars); $colname_chosen_seminar = "-1"; if (isset($_POST['order_id'])) { $colname_chosen_seminar = (get_magic_quotes_gpc()) ? $_POST['order_id'] : addslashes($_POST['order_id']); } mysql_select_db($db_name, $conn); $query_chosen_seminar = sprintf(" SELECT * FROM $order_table WHERE order_id = %s", $colname_chosen_seminar); $chosen_seminar = mysql_query($query_chosen_seminar, $conn) or die(mysql_error()); $row_chosen_seminar = mysql_fetch_assoc($chosen_seminar); $totalRows_chosen_seminar = mysql_num_rows($chosen_seminar); ?> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" name="news_entry" id="news_entry"> <table width="40%" border="0" align="center" cellpadding="4" cellspacing="0" class="newsheader"> <tr> <td width="44%" align="left" valign="top"><div align="right"><strong>Order ID :</strong></div></td> <td width="56%" align="left" valign="top"><div align="left"> <select name="order_id" onChange="chkFrm(this)"> <option value="Choose" <?php if (!(strcmp("Choose", $_POST['customers_id']))) {echo "SELECTED";} ?>>Select Order ID</option> <?php do { ?> <option value="<?php echo $row_seminars['order_id']?>"<?php if (!(strcmp($row_seminars['order_id'], $_POST['order_id']))) {echo "SELECTED";} ?>><?php echo $row_seminars['order_id']?></option> <?php } while ($row_seminars = mysql_fetch_assoc($seminars)); $rows = mysql_num_rows($seminars); if($rows > 0) { mysql_data_seek($seminars, 0); $row_seminars = mysql_fetch_assoc($seminars); } ?> </select> [/code] I know that on the line that displays the order_id in the drop down menu it is pulling it from the first query with should make that line be like the the line below, but if I make it like that then it just shows blank drop down menu. [code=php:0]<option value="<?php echo $row_seminars['a.order_id']?>"<?php if (!(strcmp($row_seminars['a.order_id'], $_POST['order_id']))) {echo "SELECTED";} ?>><?php echo $row_seminars['a.order_id']?></option>[/code]
-
[!--quoteo(post=364908:date=Apr 14 2006, 05:24 PM:name=Arif)--][div class=\'quotetop\']QUOTE(Arif @ Apr 14 2006, 05:24 PM) [snapback]364908[/snapback][/div][div class=\'quotemain\'][!--quotec--] need more description... [/quote]I don't know the answer, but I can explain so that maybe you can help him. He has input boxes that is for a ordering system. He wants to add a Quantity box so the user can type in they want 2 of the $25.00 items. When the user's pushes the number key [i][b]" 2 "[/b][/i] he wants the Total Price to show $50.00. He wants real time multiplication of inputted values...I would assume this would need to be in JavaScript with using a [i]onBlur[/i] function or [i]onChange[/i] function. I am also asuming that by default the quantity is set to [b]1[/b]? Arif...you might want to post this in the JavaScript section of this forum & might get answered quicker: [a href=\"http://www.phpfreaks.com/forums/index.php?showforum=6\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showforum=6[/a]
-
I don't know if I just missed something, but what formate is the configuration file? If it is .php then just use wordpad & just save it.
-
I have read the Pagination tutorials here & chose to use the [b][i]Pagination: Easy as PREV 1 2 3 NEXT[/i][/b] tutorial. I have it displaying everything, but the text isn't links. I will post my code below. I don't see any code that pulls the page # from the URL in the tutorial code that I am trying to use. [code]<?php $limit = 5; $query_count = "SELECT count(*) FROM orders"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM orders LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table>"); while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">n<td>"); echo($row["order_id"]); echo("</td>n<td>"); echo($row["customers_id"]); echo("</td>n</tr>"); } echo("</table>"); if($page != 1){ $pageprev = $page--; echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$pageprev\">PREV</a> "); }else{ echo("PREV"); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$pagenext\">NEXT ".$limit."</a>"); }else{ echo("NEXT ".$limit); } mysql_free_result($result); ?>[/code]
-
Thanks....I had to make the action filled of each form to this to get it to work...[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--][i]<?php $_SERVER['PHP_SELF'] ?>[/i][!--colorc--][/span][!--/colorc--] . Thanks for the help!!!
-
[!--quoteo(post=364618:date=Apr 13 2006, 05:52 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 13 2006, 05:52 PM) [snapback]364618[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]$n = 12345.67; echo number_format ($n, 2);[/code] --> 12,345.67 [/quote]Thanks...
-
[!--quoteo(post=364548:date=Apr 13 2006, 03:17 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 13 2006, 03:17 PM) [snapback]364548[/snapback][/div][div class=\'quotemain\'][!--quotec--] You have a "client" and a "server". Your process is as follows Client sends "status" to server. If status == filled a form is sent to the client. This form then sends "filled", "batch" and "acct" fields back to the server On the server you only update if "status" == filled. No "status" is sent to the server from this form. [/quote]OK...how do I make the form once it is filled out be submited to the same page...[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$_SERVER['PHP_SELF'][!--colorc--][/span][!--/colorc--] ?
-
Can this be used on the [i][b]decimal(6,2)[/b][/i] data type?
-
[!--quoteo(post=360121:date=Mar 30 2006, 02:42 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 30 2006, 02:42 PM) [snapback]360121[/snapback][/div][div class=\'quotemain\'][!--quotec--] I'd use a switch() statement [code]if (isset($_POST['status'])) { switch (_POST['status']) { case 'filled': # do whatever if filled break; case 'received': # do whatever if received break; case 'pending': # do whatever if pending break; case 'canceled': # do whatever if canceled break; } }[/code] [/quote] I am using that code & can't get it to save to the db with the new information. You can see my code below & see the echo's the names for the different statuses. I can see status display the name that is in the echo, but when I tried adding this form it will display the form & just go blank when I click the [i][b]Fill[/b][/i] button. I am not sure what is causing this. This is my colde:[code]<?php if($_POST['save']) { if (isset($_POST['status'])) { switch ($_POST['status']) { case 'Filled': ?> <form name="filled" method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> Acct: <input name="acct" type="text" id="acct"> <br> Batch: <input name="batch" type="text" id="batch"> <input name="filled" type="submit" class="submit" id="filled" value="Save" /> </form> <? if($_POST['filled']) { require("../cdb.php"); $acct = $_POST['acct']; $batch = $_POST['batch']; $now = date("Y-m-d H:i:s"); $id = $_REQUEST['id']; $status_update = ("UPDATE $orders SET order_status = 'Filled', tu_account = '$acct', tu_batch = '$batch', order_filldate = '$now' WHERE order_id = '$id'"); $savequery = mysql_query($status_update) or die(mysql_error()); if(!$savequery) { die('Error in updating the Order Status'); } else { echo 'Order Status successfully updated!'; } } break; case 'Received': echo 'Received'; break; case 'Pending': echo 'Pending'; break; case 'Canceled': echo 'Canceled'; break; } }/* require("../cdb.php"); $status = $_POST['status']; $now = date("Y-m-d H:i:s"); $id = $_REQUEST['id']; $status_update = ("UPDATE $orders SET order_status = '$status' WHERE order_id = '$id'"); $savequery = mysql_query($status_update) or die(mysql_error()); if(!$savequery) { die('Error in updating the Order Status'); } else { echo 'Order Status successfully updated!'; } } else { */} ?> [/code]
-
[!--quoteo(post=359252:date=Mar 28 2006, 08:03 AM:name=Eddyon)--][div class=\'quotetop\']QUOTE(Eddyon @ Mar 28 2006, 08:03 AM) [snapback]359252[/snapback][/div][div class=\'quotemain\'][!--quotec--] [a href=\"http://www.phpfreaks.com/tutorials/43/0.php\" target=\"_blank\"]Pagination: Easy as PREV 1 2 3 NEXT[/a] Nice tutorial there from TheReverend. And here is another, this time by phpfreak. [a href=\"http://www.phpfreaks.com/tutorials/73/1.php\" target=\"_blank\"]Page Numbering With PHP And MySQL Results[/a] [/quote]I have been trying different things to get this code to work for days now. I used that [b]Pagination: Easy as PREV 1 2 3 NEXT[/b]. My code isn't showing the [b][i]PREV[/i][/b] & [b][i]NEXT [/i][/b]as links. I don't have any links to navigate to different pages. I think it has something to do with checking to see if the [i][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]?page=1[!--colorc--][/span][!--/colorc--][/i] or the [i][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]?page=2[!--colorc--][/span][!--/colorc--][/i] in the url is there or not. I don't see any code for that. Like in the [b]Page Numbering With PHP And MySQL Results[/b] tutorial it has coding like this which the other tutorial doesn't. I can get lnks in the 2nd tutorial, but I like the first one better.[code]if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; }[/code] This is the code for my page![code]<?php //@mysql_connect($localhost, $user, $password) or die("ERROR--CAN'T CONNECT TO SERVER"); //@mysql_select_db($database) or die("ERROR--CAN'T CONNECT TO DB"); $limit = 5; $query_count = "SELECT count(*) FROM orders"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM orders LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table>"); while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">n<td>"); echo($row["order_id"]); echo("</td>n<td>"); echo($row["customers_id"]); echo("</td>n</tr>"); } echo("</table>"); if($page != 1){ $pageprev = $page--; echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$pageprev\">PREV</a> "); }else{ echo("PREV"); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$pagenext\">NEXT ".$limit."</a>"); }else{ echo("NEXT ".$limit); } mysql_free_result($result); ?>[/code]
-
I have a drop down menu that updates the status of a record in a MySQL db. I have 4 statuses...[i]Received[/i], [i]Pending[/i], [i]Filled[/i], & [i]Canceled[/i]. I am posting the form to [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]<?php $_SERVER['PHP_SELF'] ?>[!--colorc--][/span][!--/colorc--]. I will post the source code below. I need a couple of things to happen when I click the save button. If the option that I chose is the status of [i]Filled[/i] then I need to be able to enter a tracking number in a text field & after I enter that number then it perform the MySQL record update with the tracking number. Secondly if I choose the status of [i]Filled[/i] I need to update the order filled column in the db which is DATE/TIME format. If the option that I chose is the status of [i]Cacnelled[/i] then I need to be able to enter the reason for canceling the order in a text field & after I enter that number then it perform the MySQL record update with the cancellation reason. [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <?php require("../vars.php"); ?> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title><?php echo "$popup_status" ?></title> </head> <body> <form method="post" name="status_update" action="<?php $_SERVER['PHP_SELF'] ?>"> <fieldset> <legend> Update Order Status </legend> <p align="center"> <label for="status">Status:<select name="status" id="status"> <option selected value="">Choose status... <option value="Received">Received</option> <option value="Pending">Pending</option> <option value="Filled">Filled</option> <option value="Canceled">Canceled</option> </select></label><br /><br> <input type="submit" value="Save" name="save" class="submit" /> </fieldset> </form> <?php if($_POST['save']) { require("../cdb.php"); $status = $_POST['status']; $now = date("Y-m-d H:i:s"); $id = $_REQUEST['id']; $status_update = ("UPDATE $orders SET order_status = '$status', order_modified = '$now' WHERE order_id = '$id'"); $savequery = mysql_query($status_update) or die(mysql_error()); if(!$savequery) { die('Error in updating the Order Status'); } else { echo 'Order Status successfully updated!'; } } else { } ?> <p align="left"><?=$popup_close_text;?></p> </body> </html>[/code]