Jump to content

portabletelly

Members
  • Posts

    44
  • Joined

  • Last visited

Everything posted by portabletelly

  1. Ok ill try and explain this as best i can. I have client.php which includes a file called 'Functions/Common_Functions.php'; on this clients.php page it has a form, the form is a mixture of html and script. include 'Functions/Common_Functions.php'; func_header(); header_client_search(); func_endheader(); func_TopMenu(); menu_items(); ?> <br><br> <form method="post" action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>> <?php if (isset($_GET['error'])) { ?> <p class="error"><?php echo $_GET['error']; ?></p> <?php } client_search(); client_search_script(); // $clientSearch = ($_POST['clientSearch']); ?> <input type="submit" value="Search"> </form> <?php // Check if the form is submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Process form data if needed echo "formposted"; echo $clientSearch; $clientSearch = isset($_POST['clientSearch']) ? $_POST['clientSearch'] : ''; echo "Form posted with clientSearch value: " . htmlspecialchars($clientSearch); echo $clientSearch; } The two functions client_search(); and client_Search_script(); go out and query mysql clients table so as you start typing a clients name the options get smaller "suggestive text". This part is working well. However when I submit the form for the life of me I cannot get the clients name captured on submit. This is the script code located in common_functions.php function header_client_search(){ echo "<style>"; echo " #suggestions {"; echo " position: absolute;"; echo " max-height: 200px;"; echo " overflow-y: auto;"; echo " border: 1px solid #ccc;"; echo " background-color: #fff;"; echo "}"; echo ".suggestion {"; echo " padding: 8px;"; echo " cursor: pointer;"; echo " background-color: #cccccc;"; echo "}"; echo ".suggestion:hover {"; // echo " background-color: #f2f2f2;"; echo " background-color: #cccccc;"; echo " }"; echo "</style>"; } function client_search(){ echo "<h1 color=#00000>Client Search</h1>"; echo "<label for='clientSearch'>Search Clients:</label>"; echo "<input type='text' id='clientSearch' oninput='getSuggestions(this.value)'>"; echo "<div id='suggestions'></div>"; } function client_search_script(){ echo "<script>"; echo "function getSuggestions(query) {"; echo "if (query.length === 0) {"; echo "document.getElementById('suggestions').innerHTML = '';"; echo "return;"; echo " }"; //echo "// Make an asynchronous request to fetch suggestions"; echo "var xhttp = new XMLHttpRequest();"; echo "xhttp.onreadystatechange = function() {"; echo "if (this.readyState == 4 && this.status == 200) {"; echo "document.getElementById('suggestions').innerHTML = this.responseText;"; echo "}"; echo "};"; echo "xhttp.open('GET', 'get_suggestions.php?q=' + query, true);"; echo "xhttp.send();"; echo "}"; echo "function selectSuggestion(value) {"; echo "document.getElementById('clientSearch').value = value;"; echo "document.getElementById('suggestions').innerHTML = '';"; echo " }"; echo "</script>"; } and incase you need it this is the get_suggestions.php file <?php // Include your database connection logic here include('Functions/db_con.php'); // Get the search query from the URL parameter $q = $_GET['q']; // Prepare and execute the query to fetch client names based on the search query $query = "SELECT DISTINCT CompanyName FROM Customer WHERE CompanyName LIKE :query"; $stmt = $pdo->prepare($query); $stmt->bindValue(':query', '%' . $q . '%', PDO::PARAM_STR); $stmt->execute(); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); // Output the suggestions as a list foreach ($results as $row) { echo '<div class="suggestion" onclick="selectSuggestion(\'' . $row['CompanyName'] . '\')">' . $row['CompanyName'] . '</div>'; } ?> What I have tried to do is muck around with $clientSearch = isset($_POST['clientSearch']) ? $_POST['clientSearch'] : ''; echo "Form posted with clientSearch value: " . htmlspecialchars($clientSearch); and these $clientSearch = document.getElementById('clientSearch'); echo $clientSearch; but I can never get the customer name back after submitting form I just get client search value: blank like in the picture below. Where am I going wrong?
  2. Please ignore above post about additional pages I jumped the gun I had to change the collum syncroID to be unique in mysql in order for this to work. Seems to work well.
  3. Hmm, am I doing something wrong here. It appears that the following code just add new duplicate entries into the database. Clearing out the customer table, 9 pages of records are created on first run then an additional 9 pages total 18 pages on second run. <?php function Get_Customer() { set_time_limit(300); $customers = []; $totalPages = getTotalPages(); $page = 1; while ($page <= $totalPages) { $returnedCustomers = Customers($page); $customers = array_merge($customers, $returnedCustomers); $page++; } include('db_con.php'); //**************https://forums.phpfreaks.com/topic/317537-curl-rate-limits-and-time-outs-limit-rate-under-a-certain-amount-for-get-requests/ ************************* //updated syncroid //updated SQL query with duplicate key update $query = "INSERT INTO Customer (SyncroID, CompanyName, Address, City, State, Postcode) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE SyncroID = VALUES(SyncroID), CompanyName = VALUES(CompanyName), Address = VALUES(Address), City = VALUES(City), State = VALUES(State), Postcode = VALUES(Postcode)"; echo $query; try { $pdo->beginTransaction(); $stmt = $pdo->prepare($query); foreach ($customers as $customer) { if (!empty($customer['business_name'])) { //udpated Customer ID for where clause $stmt->execute([$customer['id'], $customer['business_name'], $customer['address'], $customer['city'], $customer['state'], $customer['zip']]); } } $pdo->commit(); } catch (\Throwable $e){ $pdo->rollback(); throw $e; } //******************************end of gizmola code *************************** return $customers; } function Customers($page = 1) { $url = "https://xxxxxxxxxxxxxxxxxxxxxmsp.com/api/v1/customers?sort=business_name&page=" . $page; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Accept: application/json", "Authorization: xxxxxxxxxxxxxxxxxxxxxxxx" ]); $result = curl_exec($cURL); $data = json_decode($result, true); $customers = $data["customers"]; curl_close($cURL); return $customers; } function getTotalPages() { $url = "https://xxxxxxxxxxxxxxxxmsp.com/api/v1/customers"; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Accept: application/json", "Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ]); $result = curl_exec($cURL); $data = json_decode($result, true); $totalPages = $data["meta"]["total_pages"]; curl_close($cURL); return $totalPages; } // Get_Customer(); // test /* echo "<br>"; echo $custname; echo " "; echo $customer["address"]; echo " "; echo $customer["city"]; echo ","; echo $customer["state"]; echo " "; echo $customer["zip"]; echo "<b>Customer ID:</b> "; echo " "; echo $customer["id"]; echo "<br>"; echo $query; echo "<br>"; */ //INSERT INTO `Customer` (`SyncroID`, `PrimaryContactID`, `CompanyName`, `Address`, `City`, `State`, `Postcode`, `Country`, `AccountStatus`, `UserName`, `Password_Hash`, `Password_Salt`, `Notes`, `BillingContactID`) //VALUES ('12321', NULL, 'test', NULL, NULL, 'QLD', NULL, 'Australia', 4, NULL, NULL, NULL, NULL, NULL); The $query variable returns INSERT INTO Customer (SyncroID, CompanyName, Address, City, State, Postcode) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE SyncroID = VALUES(SyncroID), CompanyName = VALUES(CompanyName), Address = VALUES(Address), City = VALUES(City), State = VALUES(State), Postcode = VALUES(Postcode) my primary key on the customer table is Customer_ID but I don't want duplicate entries based on Syncro_ID either.
  4. So im trying to run a SQL query to insert data into a customer table. But I only want to insert date if the ID does not already exist. This code here works //************************************start of gizmola coe ************************* $query = "INSERT INTO Customer (SyncroID, CompanyName) VALUES (?, ?)"; try { $pdo->beginTransaction(); $stmt = $pdo->prepare($query); foreach ($customers as $customer) { if (!empty($customer['business_name'])) { $stmt->execute([$customer['id'], $customer['business_name']]); } } $pdo->commit(); } catch (\Throwable $e){ $pdo->rollback(); throw $e; } //******************************end of gizmola code *************************** However when I try to add the where clause in it just bails out on the below code, im pretty sure my where statement has bad syntax and then im not sure the execute is done right? //**************https://forums.phpfreaks.com/topic/317537-curl-rate-limits-and-time-outs-limit-rate-under-a-certain-amount-for-get-requests/ ************************* //updated syncroid $query = "INSERT INTO Customer (SyncroID, CompanyName, Address, City, State, Postcode) VALUES (?, ?, ?, ?, ?, ?) WHERE (SyncroID) != VALUES (?)"; try { $pdo->beginTransaction(); $stmt = $pdo->prepare($query); foreach ($customers as $customer) { if (!empty($customer['business_name'])) { //udpated Customer ID for where clause $stmt->execute([$customer['id'], $customer['business_name'], $customer['address'], $customer['city'], $customer['state'], $customer['zip'], [$customer['id']]); } } $pdo->commit(); } catch (\Throwable $e){ $pdo->rollback(); throw $e; } //******************************end of gizmola code ***************************
  5. Just circling back to this. Finally got it working with gizmola's code thank you. This was the end result. Now i have to rewrite this code to add all the other fields in. Then after that is successful if the ID already exists in mysql then only update row if there's something different. I don't fully understand why this is faster and works though. Is it because it prepares the query outside of the for loop rather than inside the for loop and that's why it doesn't time out? <?php function Get_Customer() { set_time_limit(300); $customers = []; $totalPages = getTotalPages(); $page = 1; while ($page <= $totalPages) { $returnedCustomers = Customers($page); $customers = array_merge($customers, $returnedCustomers); $page++; } include('db_con.php'); //************************************start of gizmola coe ************************* $query = "INSERT INTO Customer (SyncroID, CompanyName) VALUES (?, ?)"; try { $pdo->beginTransaction(); $stmt = $pdo->prepare($query); foreach ($customers as $customer) { if (!empty($customer['business_name'])) { $stmt->execute([$customer['id'], $customer['business_name']]); } } $pdo->commit(); } catch (\Throwable $e){ $pdo->rollback(); throw $e; } //******************************end of gizmola code *************************** return $customers; } function Customers($page = 1) { $url = "https://xxxxxxxxxxxxxxxxxxxxxxxxxxmsp.com/api/v1/customers?sort=business_name&page=" . $page; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Accept: application/json", "Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ]); $result = curl_exec($cURL); $data = json_decode($result, true); $customers = $data["customers"]; curl_close($cURL); return $customers; } function getTotalPages() { $url = "https://xxxxxxxxxxxxxxxmsp.com/api/v1/customers"; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Accept: application/json", "Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ]); $result = curl_exec($cURL); $data = json_decode($result, true); $totalPages = $data["meta"]["total_pages"]; curl_close($cURL); return $totalPages; }
  6. Thanks ill give that go . In Reply to gizmol the data below is additional data that I'll need to insert later after i can successfully insert just the ID and business name. I know that I'm currently not using but i hope to add it in later ill just comment it out for now. $customer["id"]; $customer["firstname"]; $customer["lastname"]; $customer["fullname"]; $customer["business_name"]; $customer["email"]; $customer["phone"]; $customer["mobile"]; $customer["address"]; $customer["city"]; $customer["state"]; $customer["zip"]; $customer["business_and_full_name"]; $customer["business_then_name"];
  7. Continuing on with this thread the solutions was this, it returns a complete set of customer from all 6 pages. However <?php function Get_Customer() { set_time_limit(300); $customers = []; $totalPages = getTotalPages(); $page = 1; while ($page <= $totalPages) { $returnedCustomers = Customers($page); $customers = array_merge($customers, $returnedCustomers); $page++; } include('db_con.php'); //tedst // echo "Total Pages: " . $page . "<br>"; // echo "Total Customers: " . count($customers) . "<br>"; // loop through array of customer foreach ($customers as $customer) { $customer["id"]; $customer["firstname"]; $customer["lastname"]; $customer["fullname"]; $customer["business_name"]; $customer["email"]; $customer["phone"]; $customer["mobile"]; $customer["address"]; $customer["city"]; $customer["state"]; $customer["zip"]; $customer["business_and_full_name"]; $customer["business_then_name"]; if ($customer["business_name"] != "") { $custname = $customer["business_name"]; //Insert customer data into the customer table with syncroID and Company Name $query = "INSERT INTO Customer (SyncroID, CompanyName) VALUES ('" . $customer["id"] . "', '" . $customer["business_name"] ."');"; echo "<br>"; echo $query; echo "<br>"; //$stmt = $pdo->query($query); usleep(5000); } } return $customers; } function Customers($page = 1) { $url = "https://xxxxxxxxxxxxxxxxxxxxxxxxcom/api/v1/customers?sort=business_name&page=" . $page; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Accept: application/json", "Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ]); $result = curl_exec($cURL); $data = json_decode($result, true); $customers = $data["customers"]; curl_close($cURL); return $customers; } function getTotalPages() { $url = "https://xxxxxxxxxxxxxxxxxsp.com/api/v1/customers"; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Accept: application/json", "Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ]); $result = curl_exec($cURL); $data = json_decode($result, true); $totalPages = $data["meta"]["total_pages"]; curl_close($cURL); return $totalPages; } // Get_Customer(); // test /* echo "<br>"; echo $custname; echo " "; echo $customer["address"]; echo " "; echo $customer["city"]; echo ","; echo $customer["state"]; echo " "; echo $customer["zip"]; echo "<b>Customer ID:</b> "; echo " "; echo $customer["id"]; echo "<br>"; echo $query; echo "<br>"; */ //INSERT INTO `Customer` (`SyncroID`, `PrimaryContactID`, `CompanyName`, `Address`, `City`, `State`, `Postcode`, `Country`, `AccountStatus`, `UserName`, `Password_Hash`, `Password_Salt`, `Notes`, `BillingContactID`) //VALUES ('12321', NULL, 'test', NULL, NULL, 'QLD', NULL, 'Australia', 4, NULL, NULL, NULL, NULL, NULL); When I change this line of code to insert into my database //$stmt = $pdo->query($query); to $stmt = $pdo->query($query); I only get the first 80 rows before I get a gateway time out. I tried usleep in for and set_time_limit but they made no difference. Anyone got any ideas. I know the api is getting the full data set so I assume its some memory or time out limit.
  8. So the situation is this I have a cloud based webapp that stores allot of our customer data. We are building in house CRM to manage a few things the app doesn't do. However I need to get and replace all the customer info from my subscription webapp via an api call to our inhouse crm mysql clients table. The first step was to do a curl get request. This code below seems to be 1/2 working it gets down to clients with the letter C. and then returns the page, I'm missing all clients from D to Z. How would I change this code to get all remaining pages from the curl get request? Also I need to keep my requests under 180 per second. <?php function Get_Customer() { $url = 'https://xxxxxxxxxxxxxxxxxx.xxxxxxmsp.com/api/v1/customers?sort=business_name'; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json', 'Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ]); $result = curl_exec($cURL); $data = json_decode($result, true); $customers = $data['customers']; // loop through array of customer foreach ($customers as $customer) { $customer['id']; $customer['firstname']; $customer['lastname']; $customer['fullname']; $customer['business_name']; $customer['email']; $customer['phone']; $customer['mobile']; $customer['business_and_full_name']; $customer['business_then_name']; echo $customer['business_name']; echo "<br>"; } curl_close($cURL); } ?>
  9. Hi all I dont kno if I can explain what I am after correctly but anyway here I go. I have a backend php page that lets me update information in a mysql table. The web page has several forms on the same page one after the other the only difference between the forms is the part of the sql query where it says id = 1. What I am trying to accomplish is a for loop where if I have a mysql table with 5 rows, with data that starts at id 1 through to id 5. I would like the for loop to print out the form data as below until it reaches the last id. I also need the ids in the sql query to change so this would need to be a variable of some sorts. Can someone point me in the right direction as how this can be accomplished if googled it but cant really find what I am after. <form method="post" action="processhp.php"> <br>Article Name:<br><input type="Text" name="heading" value ="<?php $db =mysql_connect("localhost", "*******", "*******"); mysql_select_db("aandstec_aandstech",$db); $result = mysql_query("SELECT * FROM ******* WHERE id = '1'",$db); while($myrow = mysql_fetch_array($result)) { echo $myrow["article"]; } ?> "> <br> ID:<br><input type="Text" name="id" value="1" readonly > <br> Data:<br><TextArea type="Text" name="data" rows="3" cols="50"><?php $db =mysql_connect("localhost", "*******", "*******"); mysql_select_db("*******",$db); $result = mysql_query("SELECT * FROM personnel WHERE id = '1'",$db); while($myrow = mysql_fetch_array($result)) { echo $myrow["data"]; } ?></textarea> <input type="Submit" name="submit" value="Update"> </form>
  10. Managed to fix it. while($myrow = mysql_fetch_array($result)) { //echo "<pre width='80'>"; echo "<font face='Lucida Sans Unicode' size=2>"; echo nl2br($myrow["data"]); echo "</font>"; //echo "</pre>"; }
  11. ingnore that last post commenting out pre fixed the issue while($myrow = mysql_fetch_array($result)) { //echo "<pre width='80'>"; echo "<font face='Lucida Sans Unicode' size=2>"; echo nl2br($myrow["data"]); echo "</font>"; //echo "</pre>"; }
  12. I just added the following while($myrow = mysql_fetch_array($result)) { echo "<pre width='80'>"; echo "<font face='Lucida Sans Unicode' size=2>"; echo nl2br($myrow["data"]); echo "</font>"; echo "</pre>"; } It appears that the carriage returns just got more space it didn't effect the width in anyway. Strange thing is this page looks fine in firefox but no IE. Would this be the correct syntax echo nl2br($myrow["data"]);
  13. Ok so Im not to sure if this is the right thread to post in but here is my catch 22 issue. I have a test web page www.aandstech.com.au/test.php Test.php pulls its content from a my sql table. This works fine. When I pull down the info without <pre>code to retrieve data from mysql database</pre> tags I loose all my formating ie carraige returns. However the justify works fine. When I use my <pre> tages to retrieve data from mysql database the carrige returns are fine however the text goes right accross the entire page and not within its div. I have made some headway into resolving this issue by using <pre width="80"></pre> However this fix looks fine in firefox 3 but has absoultley no effect in ie6 through to 8.0. Anyway heres a snippet of my code any help would be greatley appreciated. [color=red]<div class="body"> <p> <?php $db =mysql_connect("localhost", "******", "*******"); mysql_select_db("*****_*****",$db); $result = mysql_query("SELECT * FROM ***** WHERE id = 1",$db); while($myrow = mysql_fetch_array($result)) { echo "<pre width='80'>"; echo "<font face='Lucida Sans Unicode' size=2>"; echo $myrow["data"]; echo "</font>"; echo "</pre>"; } ?> </p> </div>[/color] Another thing is that Im using css and any text pulled from a table doesn't use the css thats why I had to put the fonts in.
  14. Ok so Im not to sure if this is the right thread to post in but here is my catch 22 issue. I have a test web page www.aandstech.com.au/test.php Test.php pulls its content from a my sql table. This works fine. When I pull down the info without <pre>code to retrieve data from mysql database</pre> tags I loose all my formating ie carraige returns. However the justify works fine. When I use my <pre> tages to retrieve data from mysql database the carrige returns are fine however the text goes right accross the entire page and not within its div. I have made some headway into resolving this issue by using <pre width="80"></pre> However this fix looks fine in firefox 3 but has absoultley no effect in ie6 through to 8.0. Anyway heres a snippet of my code any help would be greatley appreciated. [color=red]<div class="body"> <p> <?php $db =mysql_connect("localhost", "******", "*******"); mysql_select_db("*****_*****",$db); $result = mysql_query("SELECT * FROM ***** WHERE id = 1",$db); while($myrow = mysql_fetch_array($result)) { echo "<pre width='80'>"; echo "<font face='Lucida Sans Unicode' size=2>"; echo $myrow["data"]; echo "</font>"; echo "</pre>"; } ?> </p> </div>[/color] Another thing is that Im using css and any text pulled from a table doesn't use the css thats why I had to put the fonts in.
  15. Hi, I have a table called call_event. The call_events table has colum called Time_taken. Data in this colum is stored as a decimal vaulue. EG. 4hrs and 15 minutest would be stored as 4.25. I would like to be able to do a mysql query which give a total of all the returned values from a query but Im not quite sure what syntax I need. The query I would like to do is to find out the the total time for a call. I would imagen the query would be somthing like this Query = SELECT Time_Taken FROM call_event WHERE call_id ="$call_ID"; When running this query it will return all the times_taken which have the call_id field = to $call_ID. eg 4.5, 3.25 0.00 5.0 However what do I need to do get the total for all these values eg 4.5 + 3.25 + 0.00 + 5.00 = 12.75 I want to be do a query that will return the value of all the time_Taken added up for example in this case I wanted the query to return 12.75 Is this possible with just a query or do I need to do somthing funky with php to add up all the returned values?
  16. Hi, I have a table called call_event. The call_events table has colum called Time_taken. Data in this colum is stored as a decimal vaulue. EG. 4hrs and 15 minutest would be stored as 4.25. I would like to be able to do a mysql query which give a total of all the returned values from a query but Im not quite sure what syntax I need. The query I would like to do is to find out the the total time for a call. I would imagen the query would be somthing like this Query = SELECT Time_Taken FROM call_event WHERE call_id ="$call_ID"; When running this query it will return all the times_taken which have the call_id field = to $call_ID. eg 4.5, 3.25 0.00 5.0 However what do I need to do get the total for all these values eg 4.5 + 3.25 + 0.00 + 5.00 = 12.75 I want to be do a query that will return the value of all the time_Taken added up for example in this case I wanted the query to return 12.75 Is this possible with just a query or do I need to do somthing funky with php to add up all the returned values?
  17. Hi im trying to get a list of priorities in reverse order. Is there a command which is directly opposite to ORDER BY Currently I have several calls (rows) in the data table with priorities ranging from 1, 2, 3, 4 Calls with a priority of 1's are diplayed at the top of my page and 4 at the bottom. My problem is I need them in the opersite order can this be done in the select statement. I thought there might have been some kind of ORDER BY REVERSE statement or somthing. This is my query. $query_get_calls ="SELECT * FROM data WHERE TechID ='$techid' ORDER BY priority";[code] [/code]
  18. Im not sure if im using the right logic her but Im trying to output multiple rows of data which = techid in the data table. The mysql data table consits of the following columns CALL_ID ID FirstName EMail LastName cat_id descrip status priority phoneNumber phoneExt mobile ticketVisi pageView TechID cost Time_Logged I have a function which is displaying ques function display_Ques() { //conect to mysql and select db include("connect.php"); include("selectdb.php"); //define variables posted from ques.php $tech = htmlspecialchars($_POST['ChooseTech']); $customer = htmlspecialchars($_POST['ChooseCustomer']); //define sql get tech id query $query_get_tech_id = "SELECT id FROM accounts WHERE FirstName ='$tech'"; $result = mysql_query($query_get_tech_id, $link); if(mysql_num_rows($result)) { while($row = mysql_fetch_row($result)) { $techid = $row[0]; } } //Query all call for tech $query_get_calls ="SELECT * FROM data WHERE TechID ='$techid'"; echo "This is $tech Que"; echo '<br>'; echo "This is the Tech ID $techid"; echo '<table>'; $result_calls = mysql_query($query_get_calls, $link); if(mysql_num_rows($result_calls)) { while($row = mysql_fetch_row($result_calls)) { //echo the entire array here echo $row[0]; } } echo '</table>'; } ?> However I dont know what to do here to echo the text out in a nice format. while($row = mysql_fetch_row($result_calls)) { //echo the entire array here echo $row[0]; } Currently if I type in a different number between the [] the output will change to what ever is in the next colum where TechID ='$techid'. for example $row[0] shows the calls_ID 1234 where as $row[1] shows 4774 which is the values for ID (customers id). Can someone please point me in the right directions for what query I need to run to select all the calls WHERE FirstName ='$tech'"; and how I can output multiple colums into a table. Currently my select statment works however it the echo output which im having troubles with.
  19. Not sure if this is going to work because the onchange is client side. What I now want to do is if a user chooses a tech <select name="ChooseTech" onChange="document.ct.submit()"> then a mysql query is run which echo's the outputs pn the same page for all the calls for that tech. Any idea how I would do that or if its possible? <html> <head> <title>Manage Queues</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Designed by Aaron Portelli" content="Portal HelpDesk"> <link rel="stylesheet" type="text/css" href="../style.css" /> <?php include("connect.php"); include("selectdb.php"); include("functions.php"); ?> </head> <body> <table width="100" border="0" cellspacing="0" cellpadding="1"> <tr> <td width="25%"><b>Tech_Queue</b> </td> <td width="25%"><b>Customer_Queue</b></td></td> <td></td> </tr> <tr> <td width="25%"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="ct" method="post"> <select name="ChooseTech" onChange="document.ct.submit()"> <?PHP echo ChooseTech(); ?> </select></form></td> <td width="25%"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="cc" method="post"> <select name="ChooseCustomer" onChange="document.cc.submit()"> <?PHP echo createList(); ?> </select></form></td> <td width="50%"></td> </table> <br> <input type="submit" name="command" value="GO!" class="button" /> <h1> </h1> <?php $tech = htmlspecialchars($_POST['ChooseTech']); $customer = htmlspecialchars($_POST['ChooseCustomer']); echo $tech; echo $customer; ?> </body> </html>
  20. Thanx craygo seems to work. taith what do you mean by changing content without reloading=javascript/ajax
  21. I have a form with a go button which echo's two variables for customer and tech when I submit the form. However my intention is to choose a tech in the select option "><select type="submit" name="ChooseTech" size="1" onChange="do somthing here"> then echo the content to the page without having to hit the go button. I belive I need to use Onchange but not matter what I type in for onchange= nothing seems to happen. Ideally I would like to choose a tech from the dynamic list then call a function which outputs the contents under echo $tech; echo $customer; Does anyone have any ideas how I could do that? <html> <head> <title>Manage Queues</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Designed by Aaron Portelli" content="Portal HelpDesk"> <link rel="stylesheet" type="text/css" href="../style.css" /> <?php include("connect.php"); include("selectdb.php"); include("functions.php"); ?> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table width="100" border="0" cellspacing="0" cellpadding="1"> <tr> <td width="25%"><b>Tech_Queue</b> </td> <td width="25%"><b>Customer_Queue</b></td></td> <td></td> </tr> <tr> <td width="25%"><select type="submit" name="ChooseTech" size="1" onChange="do somthing here"> <?PHP echo ChooseTech(); ?> </select></td> <td width="25%"><select name="ChooseCustomer" size="1" onChange="do somthing here"> <?PHP echo createList(); ?> </select></td> <td width="50%"></td> </table> <br> <input type="submit" name="command" value="GO!" class="button" /> </form> <h1> </h1> <?php $tech = htmlspecialchars($_POST['ChooseTech']); $customer = htmlspecialchars($_POST['ChooseCustomer']); echo $tech; echo $customer; ?> </body> </html>
  22. I have started building a php mysql internal application which I may like on sell some day. I was wondering if it was possilbe to compile certain .php pages so they cannot be modified, kinda like what you can do with other languages such as java and c when you compile the code.
×
×
  • 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.