PHP - Seperate Results By Change In First Order By Term
Here's the query:
Code: [Select] $sql = mysql_query("SELECT * FROM resources WHERE gameCat = '' ORDER BY systemCat,order_id"); I want something to happen when the systemCat changes in the results. Like this: Code: [Select] if($row['systemCat'] CHANGES){ echo '<div id="seperator"></div>'; } Any ideas? Thank you! Similar Tutorialsi want to sort the available words by the "searched word"...is there any way ? Code: [Select] <?php $query = "SELECT * FROM ce_cour_chap WHERE nom LIKE'%$find%' ORDER BY nom"; $result = mysql_query($query); while($search = mysql_fetch_array( $result )) { echo $search['nom']." - ".$search["chid"]."<br/>"; } ?> I've got a search page that spits out results that match the term that was input. Within the results, I want to add a span with a yellow background behind just the search term. I'll show my code, then say my problem Code: [Select] <?php $search = (term in $_GET variable that was searched for); // while loop that goes through all results, $result is the text that the searched term was found in $new_result = str_ireplace($search, "<span style='background:yellow'>$search</span>", $result); echo $new_result; // end while loop ?> my problem is that if somebody searches for the word "bob", then if the term "Bob" was found, when it outputs the $new_result, it shows as "bob" with the yellow background. Searching for "Bob" would give the correct results("Bob" with a yellow background), but basically when the output is given, the case of each letter is displayed as it was typed in the search field. Hi Guys I have a product page in mysql as below: id itemnumber order_id 1 348939012 2 2 535432454 1 3 543253424 4 4 987698769 3 I need to order this in my PHP mysql_fetch_assoc by order id. What I mean is I need to list them by order_id: 1,2,3,4 I have used ORDER BY order_id but still it wont work, any ideas? I'm trying to make a function which will display the top X results of the row Y which I set, for this instance I'm using the row browser and the top 5 results from my table statistics, the where is just to eliminate Search Bot results from showing up. I also want it to return the count of the amount of rows as well. So say there was 10 results for the browser 'Safari', then it would return the count of 10 for that result as well as the result itself. Code: [Select] $display->show_list('statistics', 'browser', '5', 'WHERE browser!=\'Search Bot\''); Here is my function. I'm cleaned it up a bit to remove certain checks and outputs if the query were to fail, etc. Code: [Select] function show_list($table, $row, $limit = 5, $where = NULL) { $item = mysql_query("SELECT DISTINCT $row FROM $table $where LIMIT $limit"); $result = array(); while ($fetch = mysql_fetch_array($item)) { $result[] = $fetch; } return $result; } Basically, how would I go about making it count the amount of rows for the row I've set, and then to output that along side the result? Hi guys, I have this SQL query which I use in my PHP search script Code: [Select] $query_for_result=mysql_query("SELECT * FROM customer WHERE c_name like '%".$query."%' OR c_telephone like '%".$query."%' OR c_address like '%".$query."%'"); It works fine, the only problem is now my database is bigger I would like to be able do SORT or ORDER BY id so that my search results are in order from asc to desc. Is this possible? if so can you help me. Thanks Hi guys, Having problems sorting mysql results. I can easily order/sort table columns but would like to order the results by a variable.(Distance in Miles). Havent much experience in PHP and really struggling with this. Basically a query echoing out car make and models and how far they are located from a postcode. Can get it to work no porblem, but not to order/sort by least distance. Heres what i'm working with: Code: [Select] $res=mysql_query("SELECT * FROM cars"); while ($row = mysql_fetch_assoc($res)){ echo $row['Make']; echo $row['Model']; //variable will be determimed by user input form $postcode="W12 3SR"; $start=$postcode; $ends = array(); //finds value from database field { $ends[]=$row['Location']; } // Postcode entered by user via input form $result=mysql_query("SELECT * FROM postcodes WHERE Pcode='$start'"); while($row=mysql_fetch_array($result)){ $gridn[0]=$row['Grid_N']; $gride[0]=$row['Grid_E']; } foreach($ends as $fin){ // Postcodes within mysql table $result=mysql_query("SELECT * FROM postcodes WHERE Pcode='$fin'"); while($row=mysql_fetch_array($result)){ $gridn[1]=$row['Grid_N']; $gride[1]=$row['Grid_E']; } // TAKE GRID REFS FROM EACH OTHER TO WORK OUT DISTANCE. $distance_n=$gridn[0]-$gridn[1]; $distance_e=$gride[0]-$gride[1]; // CALCULATE THE DISTANCE BETWEEN THE TWO POSTCODES AND DIVIDE BY 1.6 TO CONVERT KM TO MILES $hypot=sqrt(($distance_n*$distance_n)+($distance_e*$distance_e))/1.609; //VARIABLE FOR DISTANCE AND ROUNDED OF TO NEAREST WHOLE NUMBER. $distance=''.round($hypot/1000,0).''; echo " $distance miles"; echo "<br>"; } } ?> I wish i could just do something like this but isnt possible, is it ? Code: [Select] "Select * FROM cars ORDER BY $distance"; Thanks! How do I present these documentaries like this:
0-9
10 Things You Need to Know About Sleep
20 Animals That Will Kill You
A
Ant Kingdom
Atkins Diet
B
Battle of the Brains
Body Talk
I don't even know where to start!
I'm not asking anyone to do this for me; I just need a push in the right direction.
Any help will be appreciated.
How can I make this output in descending order from greatest to least? Right now, it appears like: 1940 1941 1942 1943 1944 etc... i'd like it to be like 2012 2011 2010 2009 etc.. until it gets to 1940 any ideas? here is my code: <? $i = 1939; while ($i < 2012) { $i++; echo '<option value="'.$i.'">'.$i.'</option>'; } ?> I wish to order my results by its occurrence inside the $status array. Basically all of the results with the status 'New' are to be listed first, then the results with the status Today, Tomorrow, Soon and so on. Is this possible, or is there alternatively a different approach to ordering my results how I desire? Code: [Select] $status = array('New', 'Today', 'Tomorrow', 'Soon', 'Future', 'Complete'); $display->get_results("SELECT * FROM todo ORDER by status DESC"); Hello dear Community, i have a large document - and i want it to parse it and spit out only this part: schule.php?schulnr=80287&lschb= Question: How to i parse the stuff!? Well i try it with FireBug and FirePath (the Xpath-tool) i do it like the following: * Load the document into my browser, if possible * start Firebug extension/add-on * run the FirePath extension * and run the xpath //a[contains(@href, "schule")]/@href * then i click "Eval" button. i find 2030 results - that are marked - how do i get them out of the firebug - to work with them?! If i have to be more precise - please let me know!! Perhaps i have to write more - and to add more information See the screenshot - here http://img259.imageshack.us/img259/7360/sceenshoteval5.jpg how can i copy and paste the results - in order to do further processing from thereon. look forward to hear from you regards What im trying to achieve is a user contact system, when the user types input in the textarea its saved in a database along with his userid on the site and the date, I have an admin side coded up where it retrieves the data, but there is no order. I want to have it display the most recent results on top. I have looked into this in the mysql manual, but you know how that is its so hard to make sense of anything in that damn manual. Im using a while loop to display the data. How can I achieve this? I have quite a long .php page but I've attached the end of it. I was wondering if I can change the order it is displayed. Basically $j is a year. And currently it goes from 1894 until 2019. I don't think anything is currently telling it to sort either way, it just by default shows that way. But I want it to show 2019 first and go down to 1894. I had this written for me by someone who I can no longer get hold of. $total_record=count($session_player); $i=0; $palyerslink=""; foreach($session_player as $var=>$val) { $i++; if($i==$total_record) $palyerslink.="<a href='/history/?pid=$var' title='view this in more detail'>$val</a>"; else $palyerslink.="<a href='/history/?pid=$var' title='view this in more detail'>$val</a>, "; } if(!empty($session_player)) { $tr++; $records.="<tr class=row> <td class=border-right><a href='/history/browse?season=$j'>$j-$value</a></td> <td class=border-right>$max_goal_season</td> <td>$palyerslink</td> </tr>"; } } $records.="</table></div>"; echo $records; ?>
This is the end of the page where the records are then displayed using the echo. I'm not sure if more code is needed though, I could post it in full if needed Edited May 29, 2020 by alxneHey guys, I am having trouble figuring this out. I currently have a database that automatically sorts itself by the id of the data. But, I am wanting the user to be able to change the sort order via a select box. I already have the select box programmed with the options, but I am not sure how to go about coding the options to change the sort order of the displayed data. What would the best way to go about programming this be? Thank you very much ahead of time!! I would like to know how to do search terms. For example, someone key in the terms in the text field, and click search, thn it will show the data. I'm sure this is possible, but I'm not having any luck. Code: [Select] $array = array("11:23", "12:46", "13:34", "14:34", "14:85"); if (in_array('12', $array)) { echo "yes"; } else { echo "no"; }} Is 'password' a protected/resevred term in either PHP or HTML? Is this code valid... Quote <li> <label for="password"> <em><img src="images/required.png" alt="required" /></em> Password: </label> <input id="password" name="password" class="text" type="password" /> </li> TomTees Is PHP used to create this type is feature? I already have a MYSQL table set up, how difficult is it to create this sort of feature? On this image, where it says 'filter your results' if a user clicks 'Detached Houses' then only detached houses will be displayed. if a user clicks 'Semi-detached' then only semi detached houses will be shown. Whats the technical term for this type of feature, and can you point me towards any tutorials etc, would really appreciate it. thank you! I want to let user to choose the checked box, so they will type in the words in the box, and select the radio button to limit their search. How should I approach it? $search_words = mysql_real_escape_string($_POST['search_words']); $query = "SELECT name,login_id,password,email FROM User WHERE name LIKE '".$search_words."%' ORDER BY name ASC"; // my query to display the necessary fields $result = mysql_query($query, $conn);//get results $result2 = mysql_query($query, $conn);//get results $resultCheck = mysql_result($result2,0,0); ?> <p align="center" class="passwordsummary_header"> User's Password Summary <table width="302" border="1" align="center"> <tr> <td width="229"> <form method="post" action="search.php" id="searchform"> <div align="center" class="label"> <p>Search: <input name="search_words" type="text" id="search_words" size="30" maxlength="20" /> <input type="submit" name="GO" id="GO" value="Go" /> </p> <p> <input type = "radio" name = "namesearch" id = "namesearch" value = "AM" <?php if($name == 'namesearch') {echo "checked";}?> > name search</input> <input name = "loginidsearch" type = "radio" id = "loginidsearch" value = "loginidsearch" <?php if($login_id == 'loginidsearch') {echo 'checked';}?>>loginid search<br /> <input type = "radio" id = "emailsearch" name = "emailsearch" value = "emailsearch" <?php if($email == 'emailsearch') {echo 'checked';}?>> email search </input> </div> </form> </td> </tr> </table> </p> <?php if ($search_words != "" && $resultCheck != "") { echo "<table width='650' border='1' align='center' cellspacing='1'> <tr><tr> <td class='passwordsummary_label'>No</td> <td class='passwordsummary_label'>Name</td> <td class='passwordsummary_label'>Login ID</td> <td class='passwordsummary_label'>Password</td> <td class='passwordsummary_label'>Email</td> </tr>"; $i = 1; while ($row = mysql_fetch_row($result)) //use loop to get the results { $name = $row['0']; $login_id = $row['1']; $password = $row['2']; $email = $row['3']; ?> <td class="passwordsummary_info"><?php echo $i;?></td> <td class="passwordsummary_info"><?php echo $name;?></td> <td class="passwordsummary_info"><?php echo $login_id;?></td> <td class="passwordsummary_info"><?php echo $password;?></td> <td class="passwordsummary_info"><?php echo $email;?></td> </tr> <?php $i++; } echo "</table>"; } else { echo '<p class="results">No search results</p>'; } Hey all, I am in a situation where database management system needs to be up and running very quickly, which would store records of addresses possibly from all the properties in a particular US state. But it would only be 1 US state, not all. These records need to be updated and retrieved for particular campaigns. The programming solution (e.g. PHP) would need to be able to import csv files generated from excel and match the records in the database in order to know which fields to update. It seems like a lot of work to do this from scratch using PHP in the short-term, given time limitations. Hence, I was considering using Microsoft Access as a front end in the interim and then when time is available writing a web-based PHP/MySql application using HTML, CSS, and JavaScript front end to allow users to easily perform data entry. Does anyone think this is a smart course of action? Ideally a web PHP app would be more robust, but considering it needs to be done from scratch, it would be time consuming. There's no right or wrong answer for this. I'm just looking for opinions. Thanks for any response.
Hi everyone. I'm very new into self learning programming. Presently I'm trying to develop a simple basic Robot that would only Place a Market Order every seconds and it will cancel the Order every followed seconds. Using the following library: It would place Trade Order at a ( Price = ex.com api * Binance api Aggregate Trades Price) I have already wrote the api to call for xe.com exchange rate with php <?php $auth = base64_encode("username:password"); $context = stream_context_create([ "http" => [ "header" => "Authorization: Basic $auth" ] ]); $homepage = file_get_contents("https://xecdapi.xe.com/v1/convert_from?to=NGN&amount=1.195", false, $context ); $json = json_decode($homepage, TRUE); foreach ($json as $k=>$to){ echo $k; // etc }; ?> And also for the Binance Aggregate Price in JavaScript
<script> var burl = "https://api3.binance.com"; var query = '/api/v3/aggTrades'; query += '?symbol=BTCUSDT'; var url = burl + query; var ourRequest = new XMLHttpRequest(); ourRequest.open('GET',url,true); ourRequest.onload = function(){ console.log(ourRequest.responseText); } ourRequest.send(); </script>
My problem is how to handle these two api responds and also the functions to use them to place a trade and cancel it. |