Jump to content

Search the Community

Showing results for tags 'select'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

  1. Hello Everyone, I found the following tutorial which is what I was looking for. https://www.w3schools.com/howto/howto_custom_select.asp However it does not work with keyboard inputs. I am trying to update the javascript of this tutorial so it works like a native select. What I'm trying to do is: If custom select is focused, pressing spacebar or enter drops down the options list Pressing the up or down arrow keys, navigates/highlights previous or next option Pressing enter on highlighted option, updates and closes native and custom select Pressing escape, closes native and custom select I've managed to get point number 4 (Pressing Esc closes all select boxes) by updating the last part of the javascript as follows. /*if the user clicks anywhere outside the select box, then close all select boxes:*/ document.addEventListener("click", closeAllSelect); document.onkeydown = function(e) { e = e || window.event; if ((e.keyCode == 27) || (e.which == 27)) { closeAllSelect(); } }; However I cannot get points 1, 2 and 3 to work. Any help figuring it out or better yet suggest a script update, would be greatly appreciated. Thanks in advance.
  2. https://www.w3schools.com/w3css/w3css_input.asp Hi, I'm using w3css and have a problem with a select field. Ive got a form (obviously) with a big TABLE - rows/columns. in one of the TD fields Ive got a bit of text, and then a SELECT field. The options within the select field are January, Feb, mar etc.. December Now - The select field is appearing BELOW the text i want - even thougfh the width of the TD field can obviously contain both the text & select fields in one line. i'm trying [CODE]<select class="w3-select" style='display: inline-block; float: left;' name="MYNAME" onchange="this.form.submit()">[/CODE] However i cant get the select field to be the same line as the proceeding text . any advice ? EDIT: the SELECT field fills the whole width of the TD field. So i can see that the words & select could easily fit on 1 line
  3. Hi there, Could anyone please help me to combine the below SQL statements such that the result is a 4 column table as shown in my screenshot? /* entire table here */ SELECT AutoNumber, DDAte, Amount FROM LedgerTransactions LT WHERE DDATE >= DATEFROMPARTS(2019,01,01) AND LT.AccNumber IN (select distinct AccNumber FROM LedgerMaster) ORDER BY ddate DESC /* add CoName to above table as 4th column, same value for every row */ select CoName from LedgerParameters Thank you in advance, Michelle
  4. Bonjour, Je suis entrain de créé un projet pour un site personnel, et j'aimerai savoir comment, avec deux <select> utilisé une condition pour ne pas affiché les mêmes propositions dans le deuxième <select> suivant ce qui a été choisi dans le premier. Merci
  5. <table border=1 colspan=50% width = 101% bgcolor = "#00012a" size=20%> <tr><td><select name="dept" color ="#0011a1"><option value="u" selected>DEPARTMENTS <option value="ap"><a href='code1.php'><a href='code1.php'>APPLIED SCIENCE DEPATMENT</a></option> <option value="pur">PURE SCIENCE <option value="soc">SOCIAL SCIENCE <option value="hum">HUMANITY </select> </td> </table>
  6. Hi, I've followed this W3 TUTORIAL to build a Custom Select Menu for my web application, which is now in production. According to the local law, my application now has to be accessible (WCAG 2.0 Pattern). The problem is that custom select menu (link above) doesn't provide a tab selector (for keyboard users), and my webapp fails in accessibility. I've tried to use "tabindex" attribute in .custom-select DIV, but it was not enough. Does anyone know how to make this accessible for keyboard users? I'm afraid of having to change all the selects of my application because of this. Thank you!
  7. Hi all, I am populating the <options> of a <select> statement from a database using php. I'm setting the value of the options to the 'workerID' and setting the innerHTML to the worker name, reading both of these values from the database table 'workers'. The 'input' button runs the php and I have the workerID as a value, but then I have to access the table again matching the workerID in a where clause to get the first & last name of the worker. It seems kind of redundant to do it this way - the question is, is there any way to pass along the worker name (which you just looked up) along with the worker ID, to the php function, or is this a normal way to do this. I thought of making the 'value' attribute a combination of ID and name, and then separating it in the php function to use, but I was wondering if there was an easier way that I am missing. I am just trying to cut down on traffic to the server. It would seem like there would be a better way to do this. Here is my code - thanks for your help!! <div id="chooseWorker"> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $chosenWorker = ($_POST["mySelect"]); include "phpConnection.php"; $sql = "SELECT firstName, lastName FROM workers WHERE workerID = '".$chosenWorker; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $_SESSION["adminFirstName"] = $row["firstName"]; $_SESSION["adminLastName"] = $row["lastName"]; } } } else { return "Worker not Found"; } } ?> <h3>Please choose a Worker</h3> <form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <select name="mySelect" size="12"> <?php include "phpConnection.php"; $sql = "SELECT * FROM workers ORDER BY ranking"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $fullName=$row["firstName"] . " " . $row["lastName"]; ?> <option value="<?php echo $row['workerID'];?>"><?php echo $fullName;?></option> <?php } // end while } // end if ?> </select> <input type="submit" value="Submit"> </form> <div> <button>cancel</button> </div> </div>
  8. I have used combo boxes for years in Access and the 'select' element on an html form is similar. All of the tutorials on w3 show how to fill the 'options' with literal values, but I would like to have the options be filled from a table in a database so the user can select one. I know this is probably a cross-topic item and I have an idea of how to go about it using javascript, php and sql, but I thought I'd ask if anyone knew of a procedure which is already created for this. In Access you just enter the row source for the combo box and the options are there - is there any kind of construct to do that for a 'select' element in html? Thanks
  9. SET-UP: Please find below three items including; one, the relevant form elements of a much larger form; two, the Javascript that determine what data will be sent to a PHP processing page via a $_POST variable, and three, The actual implementation of the code. The question follows the presentation of the code. The HTML <div id='language_options' style='clear:both;'> <label for='nl_tongue'>Native Tongue:<span class="formlabel">*</span></label> <span class="rightfloat"> <select id="nl_tongue" name="language" style="width:150px;"> <option selected value="0">Select Language</option> <optgroup label='africa [east]'> <option value='mg'>Malagasy</option> <option value=sw>Swahili</option> </optgroup> <optgroup label='africa [central]'> <option value=ny>Chichewa</option> <option value=sn>Shona</option> </optgroup> <optgroup label='Not found?'> <option value='other_tongue'>Click and enter!</option> </optgroup> </select> </span> </div><!-- end div#language_options --> <div id='nl_other'> <span class="rightfloat"><input id='nl_other_input' type='text' name='other' value=''></span> </div><!-- end div#nl_other --> <label id="nl_tongue_error" class="error" for="nl_tongue">This field is required.</label> The JAVASCRIPT $.get('./newsletter_filler.html', function(data) { $('#main').html(data); $('#nl_other').hide(); var tongue = ''; $('#nl_tongue').change(function() { if ($('#nl_tongue').val() == 'other_tongue') { $('#nl_other').show(); } }); }).done(function(){ $('.error').hide(); $(".button").click(function() { --- Other Code --- /********************************* The language Variable *********************************/ var language = $("select#nl_tongue").val(); if (language == "0") { $("label#nl_tongue_error").html("<p style='line-height:1.3em'>Please select your first language! Or, click on the <span style='font-weight:bold;'>\"Not found?\"</span> option at the bottom of the list of languages.</p>").show().css('float','left'); $("select#nl_tongue").focus().focusout(function() { $("label#nl_level_error").hide(); }); return false; } if (language == 'other_tongue') { language = $("#nl_other input").val(); if($("#nl_other input").val() == '') { $("label#nl_tongue_error").html("<p style='line-height:1.3em'>Please enter your first language.</p>").show().css('float','left'); $("nl_other_input").focus().focusout(function() { $("label#nl_tongue_error").hide(); $("#nl_other_input).hide(); }); return false; } } }); --- More Code --- }); IMPLEMENTATION: Sequence of Events Go to the Grammar Captive mainpage and do the following: Click on the word Subscribe under the heading Info/Newsletter. Click on the final <option> Click and enter! under the Not Found? <optgroup> at the bottom of the Select Language list. Enter a language of some sort. Click where it says Not found? and select a different language. Submit the form. The Outcome: The selected language takes precedence over the entered language, and the former is sent to the data base. DILEMMA: In order to correct this problem I have experimented in a variety of ways, but to know avail. What would you recommend and why? Roddy
  10. PROBLEM: Turn a two-step SELECT procedure into a one-step procedure. The two-step procedure is 1) Discover with a query to a parent table what other rows in the parent table are related to the queried row. 2) Obtain selected data for the queried row and other related rows from the parent table and a child table that are connected by a FOREIGN KEY. BACKGROUND: I have two tables -- a parent (parent_table) and a child (child_table) table - connected by a valid FOREIGN KEY and an additional table (ref_table) that contains information about the relationship among the rows of both the parent and child tables. Please find below the results of three SHOW CREATE TABLE statements to help you in your understanding of the table structure. In addition, I have included the INSERT statements for the child_table and ref-table. I accidentally destroyed the INSERT statement for the parent_table. This said, the parent and child tables are very similar in structure. DISCLAIMER: Please understand that the problem that I have created is heuristic in nature and is being used to create a prototype for subsequent, more practical use. The PARENT Table parent_table CREATE TABLE `parent_table` ( `id` int(3) NOT NULL DEFAULT '0', `usertype` enum('1','2','3') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '2' COMMENT '1=good, 2=neutral, 3=bad', `username` char(150) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`,`usertype`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 The CHILD Table child_table CREATE TABLE `child_table` ( `id` int(3) NOT NULL DEFAULT '0', `usertype` enum('1','2','3') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '2' COMMENT '1=good, 2=neutral, 3=bad', `userbio` varchar(500) DEFAULT NULL, KEY `parent` (`id`,`usertype`), CONSTRAINT `child_table_ibfk_1` FOREIGN KEY (`id`, `usertype`) REFERENCES `parent_table` (`id`, `usertype`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 INSERT INTO `child_table` (`id`, `usertype`, `userbio`) VALUES ('1', '1', 'I am Roddy.'), ('2', '2', 'I am Beth.'), ('3', '3', 'I am Matt.'), ('4', '3', 'I am Tim.'), ('5', '2', 'I am Tylor.'), ('6', '1', 'I am Liz.'), ('7', '1', 'I am Aldo.'), ('8', '1', 'I am Adzit.'), ('9', '3', 'I am Jason.'), ('10', '3', 'I am David.') The REFERENCE Table ref_table CREATE TABLE `ref_table` ( `ref_id` int(3) NOT NULL DEFAULT '0', `id` int(3) DEFAULT NULL, `ref` int(3) DEFAULT NULL, `count_ref` int(1) DEFAULT NULL, KEY `par_ref` (`ref_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 INSERT INTO ref_table (ref_id,id,ref,count_ref) VALUES ('1','1','2','1'), ('2','1','6','2'), ('3','1','7','3'), ('4','2','6','1'), ('5','2','9','2'), ('6','4','1','1'), ('7','4','2','2'), ('8','4','6','3'), ('9','4','10','4'), ('10','5','6','1'), ('11','6','1','1'), ('12','6','2','2'), ('13','6','9','3'), ('14','7','5','1'), ('15','7','6','2'), ('16','8','1','1'), ('17','9','10','1'), ('18','10','4','1'), ('19','10','6','2'), ('20',10, NULL,'1'); EXPLANATION BY EXAMPLE: Say a user is interested in row 4 of the parent_table. When the database is queried a SELECT JOIN statement looks in the id field of the ref_table and finds four corresponding rows identified by ref_id 6, 7, 8, and 9. With each of these latter rows is associated a different row -- namely, 1, 2, 6, 10. Without further selection is returned all of the information contained in the parent_table and child_table associated with rows 1, 2, 4, 6, and 10. This is what is supposed to happen, but does not. The REJECTED SQL STATEMENT SELECT * FROM parent_table OUTER JOIN child_table ON parent_table.id = child_table.id OUTER JOIN ref_table ON parent_table.id = ref_table.id QUESTION ONE: Does the table structure make sense? Are the constraints properly set? QUESTION TWO: Why is my SQL statement rejected as poorly formatted? This is my first attempt to use the JOIN clause. So, please be as thorough with your answer as possible. I must believe that I have a long road ahead with MySQL and should prepare for it as i move forward. Roddy
  11. GOAL: Use one <select> element to determine the selected option of another <select> element without destroying the ability of the second <select> element to override the selection made by the first <select> element. BACKGROUND: My biggest difficulties in my attempt to achieve the above goal are: reading the value of the first <select> element's manually (not the automated) selected option. forcing the second <select> element to perform as if it were manually selected. Please consider the following two select statements and answer the following question with jQuery. <h4>The <em>from</em> Select Input Control</h4> <select id='item_podtype_exp' form='rss2_feed' name='item_podtype'> <option value='' selected='selected'>Select a type</option> --> <option value='1'>Concept</option> <option value='2'>Form and Use</option> <option value='3'>Clausal Analysis</option> <option value='4'>Linear Analysis</option> <option value='5'>Socratic Inversion</option> </select> <h4>The <em>to</em> Select Input Control</h4> <select id='itunes_podtype_exp' form='rss2_feed' name='itunes_podtype'> <option value='' selected='selected'>Select a type</option> <option value=1>Concept</option> <option value=2>Form and Use</option> <option value=3>Clausal Analysis</option> <option value=4>Linear Analysis</option> <option value=5>Socratic Inversion</option> </select> QUESTION: How does one go about achieving the above goal? Your response will hopefully answer many more questions than I have room for here. Roddy
  12. QUESTION ONE: What is it called when you traverse an entire table in equal multiples of records? (I ask this question, because I have been fraught with frustration in my google searches.) QUESTION TWO: Do you know a routine that I can copy and modify? (This would greatly simply my search.) BACKGROUND: Surely there must be a standard routine for performing the following procedure: 1) Use PHP to read and display the first ten records of a MySQL table. 2) Read and display the next ten records of the same data table. 3) Either return to the previously read ten records and display these or continue on to the following ten unread records and display them. 5) When you have reached the end of the table display only the remaining records. GOAL: Ultimately I would like to read and display 10 records in a list format. At the bottom of the list I would place two buttons. One that displays the previously 10 records and one that displays the next ten unread records. WHAT I HAVE ACHIEVED SO FAR: <?php $col_name = 'item_pubdate'; $result_obj = $mysqli_obj->query("SELECT * FROM rss2_podcast_item ORDER BY '$col_name' LIMIT 0, 10"); while($row=$result_obj->fetch_array()) { ?> <div class='table_row podcast_item'> <div class='flex_item num_div'><?php echo $row['podcast_no_item'] . '&nbsp'; ?></div> <div class='flex_item date_div'><?php echo $row['item_pubdate']; ?></div> <div class='flex_item title_div'><?php echo $row['item_title']; ?></div> </div><!-- end div.table_row --> <div class='table_row discover_div'> <div class='flex-item'>Discover more ...</div> </div><!-- end div.table_row --> <div class='table_row'> <div class='flex-item details_div'> <?php echo $row['item_description']; ?> </div><!-- end div.table_row --> </div><!-- end div.table_row --> <?php } ?> With a little additional CSS and Javascript I have been able to achieve the following display. Clicking on the phrase "Discover more ..." reveals the hidden detail obtained from $row['item_description]. No. Publication Date|Time Podcast Title 60 2017-06-19 17:26:41 Title Ten Discover more ... 59 2017-06-18 09:50:37 Title Nine Discover more ... . . . 51 2017-09-24 11:00:17 Title One Discover more ... DESIRE: If I can only achieve the above stated goal, I can likely figure out a way to get AJAX to allow users to select podcast items by the week, month, year, and later category. But, this is already much too far into the future. For the moment, I would simply like to achieve my above stated goal. Any ideas? Roddy
  13. Hello, I have a variable ($post) that contains posted content from database. Now I want to select the first paragraph and insert a code after it (Ads precisely ). Here is my code <?php include "../modules/gfuncs.php"; $topicId=(int)$_GET['id']; #check if topic exists $q=$conn->query("SELECT * FROM topics WHERE id='$topicId'") or die( $conn->error ); if(mysqli_num_rows($q)==0){ header("location: $thisDomain/notfound"); exit; } #check for post $c4p=$conn->query("SELECT * FROM posts WHERE topicid=$topicId") or die($conn->error); if(mysqli_num_rows($c4p)==0){ $delpost=$conn->query("DELETE FROM topics WHERE id=$topicId") or die($conn->error); header("location:$thisDomain/notfound"); exit; } #new comment $notify=""; $err=""; if(isset($_POST['post']) and isLoggedIn()){ $msg=$_POST['msg']; $fid=(int)$_POST['fid']; $thisdate=time(); $error=array(); #if user uploads attachment if($_FILES['attach']['size']>0){ $thumb=$_FILES['attach']; $thumbtmp=$thumb['tmp_name']; $thumbname=$thumb['name']; $thumbsize=$thumb['size']; $targetDir="thumbs/$thumbname"; $ext=pathinfo($targetDir, PATHINFO_EXTENSION); $allowed=array("jpg","gif","png"); if(!in_array($ext, $allowed)){ $error[]="Invalid thumbnail format"; } elseif($thumbsize > 2097152){ $error[]="Thumbnail size exceeded limit"; } } if(!$msg or empty($msg)){ $error[]="Please enter a comment"; } elseif( strlen($msg)<3){ $error[]="Comment too short"; } if(count($error)==0){ $newAttachName=""; if($_FILES['attach']['size']>0){ $newAttachName=encrypt(time()*rand(), 15).".jpg"; @move_uploaded_file($thumbtmp, "thumbs/$newAttachName"); } $save=$conn->query("INSERT INTO posts SET topicid=$topicId, forumid=$fid, poster='$curUser', postdate=$thisdate, post='$msg', attachment='$newAttachName'") or die($conn->error); $notify='<div class="successHolder">Comment Successfully Added!</div>'; } else { $err=implode(",<br>", $error); $notify='<div class="errorHolder">'.$err.'</div>'; } } $load=mysqli_fetch_object($q); $forumid=$load->forumid; $subject=_read($load->subject); $subjext=$load->subject; $poster=$load->poster; $views=$load->views; #update views $newviews=$views+1; $updviews=$conn->query("UPDATE topics SET views=$newviews WHERE id=$topicId") or die($conn->error); $postdate=$load->postdate; $postdate=date("d, M Y.", $postdate); $lastposter=$load->lastposter; $lastpostdate=$load->lastpostdate; $locked=$load->locked; $attachment=$load->attachment; #load forum info $fq=$conn->query("SELECT * FROM forums WHERE forumid=$forumid") or die($conn->error); $ft=mysqli_fetch_object($fq); $forumName=$ft->forumname; $forumUrl="$thisDomain/forum/$forumid/".urlize($forumName); #count posts $postCount=$conn->query("SELECT * FROM posts WHERE topicid=$topicId") or die( $conn->error); $totalPosts=mysqli_num_rows($postCount); #pagination $limit=13; $pagination= new paging; $pagination->totalResults($totalPosts); $pagination->rows_per_page($limit); $page=@$_GET['page']; $pagination->page($page); $pagination->thisPage("$thisDomain/forum/$forumid/topic/$topicId/".urlize($subjext)); $paging=$pagination->paging(); $paging.="<span class=\"tp\">Page ".$pagination->currentPage()." of ".$pagination->totalPages()."</span>"; $anotif=""; $adminMenu=""; if($isAdmin){ if(isset($_POST['adminAct'])){ $time=time(); $act=$_POST['admin_act']; if($act=="tag_topic"){ $qt=$conn->query("SELECT * FROM updates WHERE media='topic' AND media_id='$topicId'") or die($conn->error); if(mysqli_num_rows($qt)==0){ $qaa=$conn->query("INSERT INTO updates SET media='topic', media_id=$topicId, updatetime=$time") or die($conn->error); $anotif='<div class="successHolder">Topic successfully tagged to homepage</div>'; } else { $anotif='<div class="errorHolder">Topic is already in updates</div>'; } } elseif($act="untag_topic"){ $qaa=$conn->query("DELETE FROM updates WHERE media='topic' AND media_id=$topicId") or die($conn->error); $anotif='<div class="successHolder">Topic successfully removed from updates</div>'; } elseif($act=="del_topic"){ $qaa=$conn->query("DELETE FROM topics WHERE id=$topicId") or die($conn->error); $delPost=$conn->query("DELETE FROM posts WHERE topicid=$topicId") or die($conn->error); $delFromUpdates=$conn->query("DELETE FROM updates WHERE media='topic' AND media_id=$topicId") or die($conn->error); header("location:$thisDomain/forum"); exit; } elseif($act=="edit_topic"){ header("location:$thisDomain/forum/topiceditor"); exit; } } $adminMenu="<div class=\"ContentX\"><form method=\"post\" action=\"\">"; #TAGGING: check if topic is tagged or not $qt=$conn->query("SELECT * FROM updates WHERE media='topic' AND media_id='$topicId'") or die($conn->error); if(mysqli_num_rows($qt)==0){ $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"tag_topic\"> Tag Topic"; } else { $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"untag_topic\"> Untag Topic"; } $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"del_topic\"> Delete Topic"; $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"edit_topic\"> Edit Topic <button type=\"submit\" name=\"adminAct\" class=\"w3-btn\">Submit</button></form></div>"; } #resend query to initiate paging $postQ=$conn->query("SELECT * FROM posts WHERE topicid=$topicId ORDER BY id ASC LIMIT $pagination->offset,$pagination->rows_per_page") or die($conn->error); #load all posts $contents=""; $postMenu=""; while($loadp=mysqli_fetch_object($postQ)){ $postid=$loadp->id; $poster=$loadp->poster; $postdate=$loadp->postdate; $postAttach=$loadp->attachment; $post=""; if($postAttach){ $post='[img]'.$thisDomain.'/forum/thumbs/'.$postAttach.'[/img]'; } $post.=$loadp->post; $post=_bbcode(_read($post)); #get user info $usr=new userinfo; $usr->user($poster); $posterDP=$usr->get_info("dp"); $posterCity=$usr->get_info("city"); $posterState=$usr->get_info("state"); $postdate=date("g:ia, jS M Y.", $postdate); if($isAdmin){ $postMenu="\n<br>[<a href=\"$thisDomain/forum/editpost/$postid\">Edit Post</a>] / [<a href=\"$thisDomain/forum/delpost/$postid\">Delete Post</a>]"; } $contents.=<<<eof <div class="aPost"> <table class="info"> <tr> <td width="75"> <img src="$thisDomain/user/dps/$posterDP" height="70" width="70" id="infoDP"> </td> <td> <a href="$thisDomain/profile/$poster"><span class="fa fa-user"></span> $poster</a>. $posterCity, $posterState<br> <span class="fa fa-pencil"></span> $postdate </tr> </table> <div class="msgBody"> $post </div>$postMenu </div> eof; } $pageTitle=$subject; include "../header.php"; ?>
  14. Hi, I am trying to learn basics of the SQL and following the tutorials on w3schools. Yesterday I was reading SQL Aliases and "Trying it myself". The following code returns 10 rows, each of them being zero. Am I missing something? SELECT FirstName + ' ' + LastName AS Name FROM Employees; Thanks.
  15. Hi all, I have a question about join or inner join; not sure in what way it should be used. I now use 2 queries in 2 different databases (made in phpmyadmin). SELECT `title` FROM `writers` WHERE id ='qwert58efedd1979f'; SELECT `name`, `lastname`, `str`, `nr`,` place` FROM `client` WHERE id ='qwert58efedd1979f'; I would like to make one mysql query and use join to search in 2 tables in 2 different databases. Can anyone tell how mysql does this?
  16. Hi all, <?php require 'db/connect.php'; $result = $db->query("SELECT * FROM people"); ?> I obtained a blank page running the above script, which indicates that everything is fine (path and table name are correct). I then removed the * from the query to see if it would report an error, but it did not. I added print_r($result); and run it. Nothing has changed. I included the * and run, it reported the number of rows and columns in the table. Why there has a been a lack of error reporting in this instance, noting that the ini file is configured to report all sorts of errors, even the warnings and notices (and it is reporting all that in other scripts)?
  17. hi, sorry, i have a question to do...but i know how to write in sql query ....however the answer need to write on relational algebra in query is like : SELECT * FROM operation where r='broken' group by pc having count(pc) >1 ; π id,pc,result ( σ r = 'broken' (operation)) like group by and having clasue...i no idea ... i searched on internet still @@ .... isnt the answer like that, i using split/step by step method to do rel 1 = σ r = 'broken' (operation) rel 2 = σ count(pc)>1 γ pc,count(pc) (rel 1)) rel 3 = π id,pc,result (rel 2 ) thanks
  18. I have a piece of code where I use MYSQL to add records into a database. Here I use INSERT, but I want to work with UPDATE. The user selects records which have to be updated. The records have a unique number. I hope people can help me how to convert MYSQL code into PHP. The MYSQL code used in the console is this: UPDATE table_name SET input2='my input here ' WHERE rec_number = 2; The part of the script I use looks like this: <?php $name1 = $conn->real_escape_string($input1); $name2 = $conn->real_escape_string($input2); // $sql = "INSERT INTO $table (input1, input2 ) VALUES (' $name1 ', ' $name2 ')" ; // olde code // $sql = "UPDATE $table SET input2, input1 WHERE rec_number = $rec_number_selected VALUES (' $name1 ', ' $name2 ')" ; $sql = "UPDATE $table (input1, input2) VALUE S (' $name1 ', ' $name2 ') WHERE rec_number = $rec_number_selected " ; ?> Anyone any idea what the right code is in PHP?
  19. I am attempting to create a drop down menu and I liked the style of the top home menu seen here http://www.lego.com/en-us/products (right near the lego symbol) but I am not sure how to create a similar one would some one gI've me guidance on how I can do this I just started html coding so I am a noon with little knowledge of html right now.
  20. So my goal is now to have a table list read from the database. The content of the table is supposed to be put in an <SELECT> <OPTION VALUE> form for a dropdown menu having the user select only 1 value. $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SHOW TABLES"; if (!$result = $conn->query($sql)){ die('There was an error running the query[' .$conn->error. ']'); } foreach($row = $result->fetch_assoc()){ echo "<center>"; $reeks = implode(" " , $row); // echo $reeks; // echo "<br>"; echo "</center>"; ?> <center> <form name = "inpform" method="post" action="Add-succ7.php"> <SELECT > <option value = "<?php echo $reeks; ?>" > </option> </SELECT> </center> <?php } mysqli_close($conn); ?> Do I have to do this with foreach or while? (or something else?) In the checkbox version I use while but when doing that I get a list of 8 checkboxes without any value. I see the dropdown menu is placed in the loop of while so another condition (like foreach) seems to be the first thing to think about. But what kinda solutions would you have for the script above?
  21. Beeing in a HTML page how can I return a PHP array into a Form's datalist input ?
  22. Dear All; Need your help. I am programming students' roll call in ASP with SQL 2008 R2. There are about 100 students. By default option selected is 'Present' using drop down list. I tried to use radio buttons but only one button remains selected so I am using drop-down list ( How to select multiple radio buttons?). After selecting "Present", "Absent","Late" etc, how do I insert all 100( or whatever number) of rows in the SQL table simultaneously? How should I use "for", "loop" or any other method? Please guide. Regards DAMODAR
  23. i'm trying to select columns with multiple conditions. i want to select all 'tr_type' for all 'aid's but not 'SALES' & 'PURCHASE' for aid in '1' & '2'. i tried --- SELECT * FROM tran WHERE aid NOT IN ('1','2') AND tr_type IN ('SALES','PURCHASE') ORDER BY date it didn't work. please suggest....
  24. why these lines are not working? $sql3 = "SELECT *,sum(amt),sum(qty) FROM purchase WHERE sid=$sid AND pvn!=0 ORDER BY pvn DESC LIMIT 2";$result3 = mysqli_query($connect, $sql3) or die(mysqli_error($connect));$row3 = mysqli_fetch_array($result3);echo $row3['sum(qty)'] . "<br />";$sql4 = "SELECT *,sum(amt),sum(qty) FROM purchase WHERE sid=$sid AND pvn!=0 ORDER BY pvn DESC LIMIT 3";$result4 = mysqli_query($connect, $sql4) or die(mysqli_error($connect));$row4 = mysqli_fetch_array($result4);echo $row4['sum(qty)'] . "<br />"; they both SELECT result from the complete rows on 'purchase' table. please guide what is wrong in it!
  25. I need the widget to be in my website. Any easy way that i can walk around to embed a widget inside my web can help
×
×
  • Create New...