PHP - Drop Down Menu Order
I am trying to get the drop downs to work in this order on the second <li> 903,896,898,1513 but they won't. I think it's picking up ascending order maybe? Is there another php/include I should use? It's a WordPress site.
Code: [Select] <div id="navigation"> <div id="navbar_menu"> <ul id="nav_menu"> <li><?php wp_list_pages('include=3&title_li=&depth=2');?></li> <li><?php wp_list_pages('include=2,903,896,898,1513&title_li=&depth=2');?></li> <li><?php wp_list_pages('include=23,911,913&title_li=&depth=1');?></li> <li><?php wp_list_pages('include=25,921,925,927&title_li=&depth=1');?></li> <li><?php wp_list_pages('include=27&title_li=&depth=2');?></li> <li><?php wp_list_categories('include=3&title_li=&depth=2');?></li> <li><?php wp_list_pages('include=407&title_li=&depth=2');?></li> </ul> </div> </div> Thanks in advance! [attachment deleted by admin] Similar TutorialsI am very new new php (wrote my first PHP script 5 Days ago) and am trying to give myself a crash course but I have hit a pit-stop which is killing me a little! I hope that title makes sense.... Basically I created PHP script to take data from a database and display in, I then wrote some code to use a drop down menu to order that data. That all worked ok until I tried to utilise some pagination. I can make the pagination work, and I can make the ordering work, but not at the same time! At the moment the code that I have will allow me to order the list and almost paginate it. There are 40 results and I want to display 10 at a time. When not using the ordering code I can paginate it perfectly but when I try to intergrate the two bits of code it will only display the first 10 results and not give me an option to go to the next page to see the rest! The code: if (!isset($_GET['start'])) { $_GET['start'] = 0; } $per_page = 10; $start = $_GET['start']; if (!$start) $start = 0; $sort = @$_POST['order']; if (!empty($sort)) { $get = mysql_query("SELECT bookname, bookauthor, bookpub, bookisbn FROM booktable ORDER BY ".mysql_real_escape_string($_POST['order'])." ASC LIMIT $start, $per_page"); } else { $get = mysql_query("SELECT bookname, bookauthor, bookpub, bookisbn FROM booktable ORDER BY bookname ASC LIMIT $start, $per_page"); } $record_count = mysql_num_rows($get); ?> <?php if (isset($_GET['showerror'])) $errorcode = $_GET['showerror']; else $errorcode = 0; ?> wont include all the html rubbish and the ordering menu! <div id="mid"> <?php echo "<table>"; echo "<tr>"; echo "<th>"; echo "</th>"; echo "<th>"; echo "Book Title"; echo "</th>"; echo "<th>"; echo "Book Author"; echo "</th>"; echo "<th>"; echo "Book Publisher"; echo "</th>"; echo "<th>"; echo "Book ISBN"; echo "</th>"; echo "<th>"; echo "</th>"; echo "</tr>"; while ($row = mysql_fetch_assoc($get)) { // get data $bookname = $row['bookname']; $bookauthor = $row['bookauthor']; $bookpub = $row['bookpub']; $bookisbn = $row['bookisbn']; echo "<tr>"; echo "<td>"; echo "<a href='addtolist.php?bookname=".$bookname."&bookauthor=".$bookauthor."&bookpub=".$bookpub."&bookisbn=".$bookisbn."'>Add to basket</a>"; echo "</td>"; echo "<td>"; echo $bookname; echo "</td>"; echo "<td>"; echo $bookauthor; echo "</td>"; echo "<td>"; echo $bookpub; echo "</td>"; echo "<td>"; echo $bookisbn; echo "</td>"; echo "</tr>"; } echo "</table>"; $prev = $start - $per_page; $next = $start + $per_page; if (!($start<=0)) echo "<a href='products.php?start=$prev'>Prev</a> "; //set variable for first page number $i=1; //show page numbers for ($x = 0; $x < $record_count; $x = $x + $per_page) { if ($start != $x) echo "<a class='pagin' href='products.php?start=$x'> $i </a>"; else echo "<a class='pagin' href='products.php?start=$x'><b> $i </b></a>"; $i++; } //show next button if (!($start >= $record_count - $per_page)) echo "<a class='pagin' href='products.php?start=$next'> Next </a>"; ?> Thank you so much for reading!
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. im fairly new to php so tend to do trial and error..... more error than trial tbh. im wondering if it is possible to get a drop down menu to fill from a mysql database and to arrange it alphabetically. i have created the menu just dont know how to arrange it better. also how can i use the items id in drop menu to load other info from that row on the database. hope you can help me. Code: [Select] <FORM> <?php $result = mysql_query( "SELECT * FROM movie_info" ) ; echo "<select name= film onChange='submit()' >film name</option>"; while ($nt=mysql_fetch_array($result)){ ?> <?php echo "<option value='$nt[id]'>$nt[title] </option>"; } ?> </select> </FORM> Okay, so, here's the scenario. I have a form that is editing an item that is already in the database. The text fields fill in just fine with that info. However, the drop down menus don't retrieve that info, rather resorting to the defaults, which can be a problem if you don't remember what you originally had. Is there anyway to make the dropdown menus pull the info from the table and use that rather than resorting back to the default? I tried using this: Code: [Select] <tr><td width="20%">Bonus:</td><td><select name="bonus" value="{{bonus}}"> <option value="Attack" {{bonus1select}}>Add to the attack power of weapon</option> <option value="Defense" {{bonus2select}}>Add to the defensive power of armor</option> <option value="None" {{bonus3select}}>No effect</option> </select><br /></td></tr> So, it's obvious the "value" portion not working. Any help would be great!! Hi i currenlty have adrop box filled with companies so the user can select which company they woudl like services from but the default is currently 0 and is to selecvt all firms but im unsure how to do this. Current code: Code: [Select] <td>Taxi Firm</td><td> <select name="taxifirm"> <option value="0" selected>All Taxi Firms</option> <?php $sql = mysql_query("SELECT * FROM taxi_Firms"); while($row = mysql_fetch_array($sql)){ $uid = $row["Firm_ID"]; $username = $row["Firm_Name"]; echo '<option value="'.$uid.'">'.$username.'</option>' ; } ?> amny help is welcomed thanx helo i a newbie in php. i need some help regarding my system. i want my data from database to display in drop down menu form.anyone have idea how to do that? i really need some help. i have search all over and couldn't find any solution. any suggestions would be helpful Hi, i know this is probably very basic but i have been banging my head and looking for tuts. i have built a mysql php dropdown menu. all displays fine. now, how do i get the menu to actualy take me to a new url? the new url should be www.mysite.com/"menu selection" Code: [Select] <? include_once 'includes/db.php'; $result = mysql_query("select * from crimerate WHERE DISTRICT = 'Limpopo'", $con); if (!$result) { die('Invalid query: ' . mysql_error()); } $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $crime=$row["CRIME"]; $options.="<OPTION VALUE=\"$id\">$crime</option>"; } ?> <SELECT NAME=crime> <OPTION VALUE=0>Choose <?=$options?> </SELECT> I'm trying to code a drop-down menu that has four options; one for pie,exp, root 3, and the golden ratio.(all math values) Beside the drop-down menu, there is an option for user-inputted data, they must input only positive numbers. I must take there selected drop-down menu option and times it by the user inputted number. I'm not sure how to check which option the user chose.
<form id="s" method="post"> </select> <input type="submit" name="Submit" value="Send"> Everything That ive tried has failed Hi, i wonder whether someone may be able to help me please. I am using a combination of PHP and AJAX to create two drop down menus on a HTML form. The data is being pulled from a mySQL database with the options available in the second drop down dependent on the value selected in the first. The initial drop down menu called 'detectors' and the behaviours for the second drop down menu, 'searchheads' are created with the following AJAX code: Code: [Select] Function AjaxFunction(detectorid) { var httpxml; try { // Firefox, Opera 8.0+, Safari httpxml=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { httpxml=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpxml=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } function stateck() { if(httpxml.readyState==4) { var myarray=eval(httpxml.responseText); // Before adding new we must remove previously loaded elements for(j=document.addfindstolocation.searchheads.options.length-1;j>=0;j--) { document.addfindstolocation.searchheads.remove(j); } for (i=0;i<myarray.length;i++) { var optn = document.createElement("OPTION"); optn.text = myarray[i]; optn.value = myarray[i]; document.addfindstolocation.searchheads.options.add(optn); } } } var url="searchheaddetails.php"; url=url+"?detectorid="+detectorid; url=url+"&sid="+Math.random(); httpxml.onreadystatechange=stateck; httpxml.open("GET",url,true); httpxml.send(null); } The following code is the file 'searchheaddetails.php' (as highlighted above) which populates the second drop down menu. Code: [Select] <? $detectorid=$_GET['detectorid']; require "config.php"; $q=mysql_query("SELECT * FROM searchheads WHERE detectorid='$detectorid' ORDER BY 'searchheadname' ASC"); echo mysql_error(); $myarray=array(); $str=""; while($nt=mysql_fetch_array($q)){ $str=$str . "\"$nt[searchheadname]\","; } $str=substr($str,0,(strLen($str)-1)); // Removing the last char , from the string echo "new Array($str)"; ?> And this is the section of my form that pulls together the two drop down menus. Code: [Select] <form name="addfindstolocation" method="post" id="addfindstolocation"> <div align="left"> <select name=detectors id="detectorid" onchange="AjaxFunction(this.value);"> <option value=''>Select One</option> <? require "phpfile.php";// connection to database $q=mysql_query("SELECT * from detectors WHERE userid='1'ORDER BY 'detectorname' ASC"); while($n=mysql_fetch_array($q)){ echo "<option value=$n[detectorid]>$n[detectorname]</option>"; } ?> </select> </div> </div> <p align="left"> <label></label> <label>Search Head Used</label></p> <div> <div align="left"> <select name=searchheads id="searchheadid"> </select> </div> The drop down menus work fine, but I'm having a little difficulty with the data that is being saved. For the 'detectors' drop down menu the data being saved upon a selection being made is the 'id' pertient to the relevant detector e.g. 'Detector1' is selected and the 'id' value of '1' is saved which is exactly what I want. However when it comes to the second drop down menu, the value saved is the text value that the user selects, rather than the 'id'. e.g. 'Deep Search Head ' rather than an 'id' of '1'. Could someone perhaps tell me please what I need to change so that the 'id' value is saved rather than the text value. If it helps, the coding is taken from the following http://www.plus2net.com/php_tutorial/ajax_drop_down_list.php. Many thanks and kind regards. Chris I did search this up but all of them were lists.
I want to make a menu drop down like so....
Non-clicked...
Clicked...
The grey boxes would be images (unless it is easier to code them).
I am a complete noob so please don't use technical terms
Thanks
Hi I have a temporary web page with a drop down menu. Problem is to get rid of the gap on the drop down menus. Any help please
www.des-otoole.co.uk/top_menu
Hello! This is my first post here. I'm usually do programming in Ruby (Rails) but for a special occasion I need PHP. So hi PHP people! I come in peace My question is quite simple. How do you make a drop down menu? Most preferably with database populated fields in it. In the Rails community, this really helped me make these menus in Rails: http://www.kahfei.com/?p=23 Could someone briefly write something like that too? (The place holders) Orrr you guys can just explain how to do it. The ones I found on the internet were quite confusing and not explained enough. Help anyone? Thank you I have lots of tables for my products could i use the table name for a drop down menu? or is it not safe Thanks for any help Hi, I'm no pro at PHP but I am trying to get a drop down menu to a authenticate before moving to the next part of the form. What I want is once a selection has been made, ONLY THEN can the user move on, OTHERWISE a message echo appears. This is the html menu box <select size="1" name="title"> <option>Please Select</option> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Dr">Dr</option> </select> Then this is what I have in the form PHP: $visitortitle = $_POST['visitortitle']; if ( HOW DO I GET THIS PART TO AUTHENTICATE AN OPTION HAS BEEN SELECTED? ) { echo "<p>Please enter a title correctly<br />before you try submitting the form again.</p>\n"; die ( '<a href="pef.html">click here go back and try again</a>' ); echo $id;} If anyone can help me sort out this part of the form I can move on as the rest is working fine? Thanks Gary Hey guys im looking to do a drop down menu which is pretty basic however, in this drop down menu it uses an array of 4 values eg Orange, Apples, Bananas, Strawberry's. For this menu if a user has previously chosen an Orange which is stored on the db then then when the drop down menu is loaded it should move Orange to the top of the list, the same applies for the other values. How could I do this? I know how to do the select statement and place the values in an array. from there I dont know quite how to approach it. () Thank you. I'm having a problem with populating a second drop down menu that needs to be identical to the first from a mysql database. I have about 20 items in the DB & I only want to show the first 9. My code is: Code: [Select] <select name="a_type" style="width: 175px;"> <option value="" selected="selected"> None selected</option> <?php $i=1; while (($_produce = mysql_fetch_array($result_produce)) && ($i <=9 )) { $produce_type=$_produce["type"]; $produce_id=$_produce["id"]; $i++; ?> <option value="<?php echo $produce_id; ?>"><?php echo $produce_id; ?> - <?php echo $produce_type; ?> </option> <?php } ?> </select> That works fine in my first drop down menu but the second drop down menu with the same exact code will show items starting at 11 & higher instead of 1 to 9. I haven't tried closing the DB & the reopening it which I assume would work but there are a lot of other variables & things I'd have to check to make sure they don't get effected so I'd rather not. Is there a simple way to solve this? I've followed a few tutorials, as I've never touched drop down before (more of a conventional navbar guy ). But none are dropping the nested list :-\. I even took the code from one, no changes made, and it still didn't drop the menu
This is as far as I got on this tutorial (http://line25.com/tu...s-dropdown-menu) before coming here
#topbar-navigation { width: 101%; margin: 0 auto; ; margin-top: -8px; height: 56px; background: #ffffff; display: inline-block; text-align: center; min-width: 1100px; -webkit-box-shadow: 0 1px 8px 0px #b5b5b5; -moz-box-shadow: 0 1px 8px 0px #b5b5b5; box-shadow: 0 1px 8px 0px #b5b5b5; } #topbar-navigation ul { display: inline-table; list-style: none; position: absolute; margin-left: auto; margin-right: auto; margin-top: 20px; top: 0; left: 765px; right: 0; } #topbar-navigation ul:after { content: ""; clear: both; display: block; } #topbar-navigation ul ul { display: none; } #topbar-navigation ul li:hover > ul { display: block; } #topbar-navigation ul li a { display: block; padding: 25px 40px; color: #99a0a8; text-decoration: none; font-family: 'sinkin_sans400_regular'; font-size: 12px; } <div id="topbar-navigation"> <a href="index.php"><img src="images/moduniverselogo.png" class="site-logo" draggable="false" /></a> <ul> <li><a href="#">Welcome, <b style="color:#ff924e" ><?php echo $user->data['username'] ?></b></a></li> <ul> <li><a href="#">My Profile</a></li> <li><a href="#">Edit Account</a></li> <li><a href="#">Log Out</a></li> </ul> </ul> </div>I want it nested to the right like on the site currently: http://i.imgur.com/llZPUbZ.png Edited by Azercii, 20 June 2014 - 10:01 PM. I'm not sure how this would be done with php or something else, what I want is to have a button and when the button is pressed it creates a drop down menu and if it's pressed again then it creates a second drop down menu. I've been googling but haven't found anything yet if someone has an idea or a tutorial that they could direct me to that would be very helpful!!!! Any help is greatly appreciated, thanks in advance!!! Hi all I am trying to create a menu that shows the initially selected value depending on which page the user is on: <?php $fetchcategories=mysql_query("SELECT * FROM `product_categories` ORDER BY id ASC"); while($returnedcategories=mysql_fetch_array($fetchcategories)) { echo "<option value=\"".$returnedcategories['name']."\" selected=\"selected\" >".$returnedcategories['name']."</option>"; } ?> There are three product categories; Stone, Wood and Accessories. in the SQL. When on the stone.php page I need the option value 'stone' to stay selected. Many thanks for your help Pete I am brand new to php and I don't know where I am going wrong with this. I would like to have drop down menu which is populated from mySQL and which would allow user to select one option. The selection would be used on the following page once the form is submitted. Right now I have the following script and it populates the dropdown menu but it does not return value when selection is made. <form action="databaseinputcheck2.php" method="post"> <?php mysql_connect("localhost", "xxxxxxxxxxxx", "xxxxxxxxxxxxxx") or die(mysql_error()); echo "Connected to MySQL<br />"; ?> <p>Lotteries: <?php mysql_select_db("wpawlowski") or die(mysql_error()); // Get all the data from the "LotteryNames" table $lotterynameresult = mysql_query("SELECT id, Name FROM LotteryNames") or die(mysql_error()); ?> <select name="LotteryName" size="1"> <option selected value="">Select One</option> <option value="">----------</option> <?php // keeps getting the next row until there are no more to get while($currentlottery = mysql_fetch_array( $lotterynameresult )) { $lid=$currentlottery['id']; $lname=$currentlottery['Name']; // Print out the contents of each row into drop down menu echo "<option value='$lid'>$lname</option>\n"; //$options.="<OPTION VALUE=\"$lid\">".$lname; //Selection input line } ?> <input type="submit" value="GO" /> </form> I looked on the internet and it is my understanding that if I comment out the line starting withc "echo" and uncomment the one below the drop down menu should still be populated and the selection would be stored in the $options variable which in turn could be transfered to databaseinputcheck2.php with $_POST to be used there, but when I do uncomment that line and comment the echo line out my drop down menu is not populated, what am I doing wrong? |