(mysql) Select And Indices
Trying to write a php script where the user will enter the row number
(index) of a record. Say, for example, user wants record 55:
[MySQL]: select * from MyTable where Index = "55"
where Index is an autoincrement value, and also an index.
Unfortunately, MySQL barfs on this type of instruction. Doesn't seem
to want to let me access Index values...
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
MySQL INDEXes (indices?)
a couple of INDEX related questions. (i tried posting on the MySQL.com forum but got no response, feel free to point me to a good MySQL forum if there is one). i've been looking at some of my old databases with a view to optimising them as i'm totally self-taught and never realised loads of stuff like indexing when i created the databases! i'm using MySQL 3.23.58, all tables using MyISAM. Code:
View Replies !
View Related
Indices
How do you indice a table to speed up a query? Can someone explain to me more about indicing? Didn't really understand it on mysql.com
View Replies !
View Related
Checkboxs And Array Indices
I have a number of blocks like this on my form: <input type="text" name="name[]" value="a name"> <input type="text" name="ddi[]" value="1234"> <input type="checkbox" name="delete[]"> If I then submit the form, the array $delete is the only one which isn't indexed by its order on the form. For example, $name[ 0 ] and $ddi[ 0 ] always return the value of the first name[] and ddi[] input on the form. If I check any one of the checkboxes, say the third one, then $delete[ 0 ] will be "on", and all of the other including $delete[ 2 ] will be off. If I checked the third and seventh checkbox, just as an example, $delete[ 0 ] and $delete[ 1 ] will be "on". So, there is no way I can tell which checkboxes are actually checked, just how many have been checked. This is extremely annoying and doesn't happen with any of the other form controls.
View Replies !
View Related
Arrays And Complex Indices
the following line doesn't give its intended effect $selected[ $out['month'] ] = 'SELECTED' but this line will: $selected[ $out['month'] + 0 ] = 'SELECTED' How do I make sure $out['month'] is evaluated correctly without added a 0 to guide php?
View Replies !
View Related
Pushing Elements On Array With Indices
I try to push elements on an array but without succes. I have a for loop and need to do something like this array_push ($doelpunten, "$myrow[0]" => "$myrowDoelpunten[0]"); where myrow[0] is de indice and $myrowDoelpunten[0] the value. $doelpunten is the array Someone can help me out?
View Replies !
View Related
Debug_backtrace And FILE/LINE Indices
I've been using debug_backtrace() for a while to provide stack traces for a custom logging function. Today was the first time I've got the following error: "Notice: Undefined index: file in E:webrootliberrors.php on line 341 Notice: Undefined index: line in E:webrootliberrors.php on line 341" related to the following code:
View Replies !
View Related
MySQL+PHP Select One Row
I'm sure it has been asked a thousand times before, but still: How can I access a particular row in my MySQL table via PHP? The background is just to update the values of one row in the table via a html form with the old values already filled in. What I tried so far ist sth like this: $row=mysql_query('SELECT * FROM names WHERE ID=$entry'); for ($i = 0; $i < mysql_num_fields($row); $i++) { echo("<td>$row[$i]</td> "); } The mistake should be that mysql_query does not return a vector, but still a table... Does anybody have a good idea how to solve that problem?
View Replies !
View Related
MYSQL SELECT?
In my code I am trying to SELECT username and UsrRights When I Echo out the SQL query I do not get anything back. Why am I not getting anything echoed back? Code:
View Replies !
View Related
Mysql Select Via Php
Everything works. I just want to make a table of results show up in alphabetical order. I have mysql select whole table. I want to take the mysql select and select the whole table with one field alphabetically. A to Z. How do I do this?
View Replies !
View Related
Mysql Select From Db
I'm writing a guestbook and I got stuck on the part of the script that selects the posts from the database (mysql) and prints it to the page. The code is below: $result = mysql_query("SELECT * FROM table_name WHERE active =Ƈ'"); $row = mysql_fetch_array($result); print "$row"; This is a very basic script, I'll add the bells and whistles later but first I need to get this part to work. When I go to this page with my browser, I get the meta title tag but nothing in the body of the browser.
View Replies !
View Related
Mysql Select
I'm creating ad's system. There are two mysql tables: `ads` and `views`. In `views` i put the ids of `ads` table's entries. How to select from `ads` only rows, which ids don't exist in `views` table?
View Replies !
View Related
Won't Select From MySQL DB
I am trying to make it so my script will show a drop down form of all accepted credit cards from a certain table called devbg_credit_cards. I've checked all the spellings / letter cases and it's all right....but for some reason it won't show those credit cards in my options... any ideas? Code:
View Replies !
View Related
Select From A Mysql Table
I want to pull one field from a mysql table. How do I do that? Do I use SELECT? The field name is $sip_visitornum. And I want the last value that was inputted in to the db. I already have the code to get the visitor number but I don't know how to display data from the database properly. Thanks.
View Replies !
View Related
MYSQL - Select XX Months
I have a database set up, with one of the fields is a month - "200611" = November 2006 "200610" = October 2006 "200609" = September 2006 I was wondering, I know how to sort descending etc.. - Is there a way, to (add to an existing search criteria).. select all records in the last XX months.. IE, If I only wanted the last 2 months, it will only select records in October & November 2006.... or September also - if I want 3 months... (I have records going back to April 2006) Im guessing the 'unique' function will be used, but im not sure how to select XX months.....
View Replies !
View Related
Negative SELECT In Mysql?
How does one retrieve the rows in a select statement that DONT match the select. select CarIndex FROM DealerCatalog, BigCatalog WHERE DealerCatalog.CarIndex=BigCatalog.CarIndex finds all the cars in the dealer catalog that are in the bigger distributor catalog. How do I do the opposite in a single sql statement i.e. all the dealer cars that AREN'T in the big distributor catalog?
View Replies !
View Related
Mysql Query - Select Any
I have the following sql statemant to search a mysql database that gets if values from a form with combo box's in. SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid = hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND hottubs.seatsto <= '%s' AND hottubs.shape = '%s' ORDER BY $thesearchtype_search. Everything works fine except I want to add a select "any" from the shape combo box. I really need a way of cutting out the last " AND hottubs.shape = '%s' " if the $_GET['shape'] = 'any' Will this work using a variable as shown below?? IF ($_GET['shape'] != 'any' ) { $shape = AND hottubs.shape = '%s' } SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid = hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND hottubs.seatsto <= '%s' $shape ORDER BY $thesearchtype_search I have only been doing php about a month so go gentle!
View Replies !
View Related
MySQL SELECT Returns.
How would one go about retrieving data from a MySQL table, and then breaking it up into groups of, for example, 5. What I am trying to do is pull search results from sed table, and then be able to have links at the bottom that would be like "<Previous 1, 2, 3, 4, 5, 6, Next>" where the numbers represent the dynamic amount of pages listing the search results.
View Replies !
View Related
Conditional Select From Mysql
I have a mysql database which stores race data that I want to open up to users for viewing. I want the user to be able to select various subsets of the data according to the parameters: race, gender, age, and type (and maybe sometime, by name as well). This is BOTH a mysql question and a php one, as I ask for a more efficient solution (see bottom this post). Here is a snippet of how I am implementing the mysql statements to select only the exact subset of data. PHP Code:
View Replies !
View Related
Run A Sql (select) Statement On A MySQL DB
I am trying to run a sql (select) statement on a MySQL DB, using the sum function... It keeps returning a value that I know is not correct (in fact it is 1.3356959598149e-315)... The statment is: Select sum(domain_cost), sum(domain_charge) from table_name; I know the answer should be about $12,000, but it is clearly not giving me this... Is there a formatting that needs to be included in the statement.
View Replies !
View Related
MySQL Select Case
I'm trying to get the venue in the 'List' column when in contains a value. But if the venue Is Null then place the event in the 'List' SELECT CASE WHEN event Is Null THEN venue Else event End as 'List' ,DATE_FORMAT(fld_date, '%M') as Monthly[color=blue] >From na_statistics[/color]
View Replies !
View Related
MYSQL Select Code.
Im trying to make this somewhat statement which says through mysql_query(); somthing like: ("SELECT username = $user FROM user_info WHERE rights = $rights"); // then put $rights which has been never been valued before $_SESSION['RIGHTS'] = $rights; So correct me if im wrong i want to do something like this. if anyone could help me form this up in a formal mysql_query manner, since ive done a lil search but didnt find much about it.
View Replies !
View Related
Mysql Select Problem
Currently im using this: $query = "select * from news, users where news.User_ID = users.User_ID order by news.News_ID DESC" only problem is both tables have User_ID, how can I make aliases of these?
View Replies !
View Related
Mysql Select Query With Php
I want to create a sql query but don't know if this is possible with mysql. The Query should do the following: Select all db entries from table in which entry a is smaller than the number (count) of all db entries with criteria x from another table.
View Replies !
View Related
Mysql Select Date From
if I have something like.. $result = mysql_query("SELECT * FROM booked WHERE Date=��-04-07'") which just list items for that one day, how would I list everything from a date to a date in the future. ie like 2007-04-07 to 2008-04-07 .
View Replies !
View Related
Mysql Select Displays Nothing
I'm having some trouble with this script. I have within a table the column "item1name". When I try and run this script everything echos out okay yet the final if statement always displays nothing when there is actually text in the column specified. Any ideas why this is happening? <? $userid="2"; $refslot= "item1"; $ex= "name"; $refiname= $refslot.$ex; echo $refiname; mysql_connect("localhost", "xxx", "xxx") or die(mysql_error()); mysql_select_db("xxx") or die(mysql_error()); $query= mysql_query("SELECT * FROM pcitems WHERE userid='$userid'")or die(mysql_error()); while($row= mysql_fetch_assoc($query)){ $iname= $row['$refiname']; echo "Working"; ................
View Replies !
View Related
MySQL Select Statement
$query = "SELECT DISTINCT albumName FROM fotoPhotos, fotoUsers WHERE fotoPhotos.userid = fotoUsers.id AND fotoUsers.username = ".$username." ORDER BY albumName ASC"; I don't get an error message. The variable $username is set and exists in the database. But there is something wrong that I cannot fathom.
View Replies !
View Related
MySQL Select From Array
I have two DBs, one is of dealerships and one is a zip code DB. I'm using ZipCodesRange.class from phpclasses.org Example: include("ZipCodesRange.class.php"); //initialization, pass in DB connection, from zip code, distance in miles. $zip = new ZipCodesRange($db,�',50); //do the work $zip->setZipCodesInRange(); //call to initialize zip array //zip code output, other processing can be done from this array. $zipArray = $zip->getZipCodesInRange(); It returns an array of zip codes and distances ($zipArray, $zipArray[0] = Zip, $zipArray[1] = Distance). What I'm trying to do is SELECT dealerships from the DB of dealership within the returned zip codes. But how do I SELECT from an array? Ideally, I would want to select dealerships from a given radius of a zip code and show the distance without using lat/lon.
View Replies !
View Related
Multiple Select Into Mysql
I want to insert multiple selection into mysql like this: <select name="time" multiple="multiple"> <option></option> </select> i tried this $arr = $_POST['position']; foreach($arr as $position){ $time=$position; } . $insert = mysql_query("insert into $table values ('NULL', '".$_POST['time']."' but it's not work it insert into mysql just one value i want when the user ctl+click to choose more than one to insert all selected values into mysql.
View Replies !
View Related
Php MySQL Select Fails
I have a mysql problem that has me completely stuck: If I run the following query in phpMyAdmin, I get 4 results: SELECT * FROM b4ads WHERE instr(lower(comments),'erika')>0 But, if I insert the query into a .php file as the following line, I only get 3 results: mysql_query("SELECT * FROM b4ads WHERE instr(lower(comments),'erika')>0",$dbq); Even if I use the working phpMyAdmin results via the "create PHP" link, it does not work when I insert it into the php file (I still only get the 3 results): $sql = 'SELECT * ' $sql .= 'FROM `b4ads` ' $sql .= 'WHERE instr( lower( comments ) , 'erika' ) > 0 LIMIT 0, 30' mysql_query($sql,$dbq); IMPORTANT HINT: If I Edit the excluded result in phpMyAdmin, and "Insert as a new row", the new (exact same) row DOES show in the php query.
View Replies !
View Related
Single Mysql Select
I have a simple array named j12stuff that is a list of words. Can I use one mysql query to select all words from a table that matches the words in the array that are nouns? The point is to use mysql to reduce the array list to nouns only.
View Replies !
View Related
Mysql Select Syntax
im trying to do a basic search query but i cant quite get the syntax down for what I want to do. I have something like this, im not quite sure what im missing. PHP Code: $search =$_POST['txtSearch']; echo "This is the search query: ". $search; $sql = "SELECT * FROM articles WHERE message LIKE '%search%' ORDER BY id DESC LIMIT $from, $max_results";
View Replies !
View Related
Multiple Select And Mysql
<select name="time" size="4" multiple="multiple"> <option selected="selected">None Selected</option> <option>Full Time</option> <option>Part Time</option> <option>Contract</option> <option>Temporary</option> you know this select but who know how to enter all of selected values to database couse when i tried to submit the form it's insert just one value from all values selected so how can i fix it.
View Replies !
View Related
Mysql Select Query
PHP Code: <?php include 'common.php' include 'db.php' if(!isset($_POST['register'])) { header("Location=register.php"); } else { dbconnect('rishaorg_members'); } if($_POST['newid']=='' or $_POST['firstname']=='' or $_POST['lastname']=='' or $_POST['address']=='' or $_POST['city']=='' or $_POST['state']=='' or $_POST['country']=='' or $_POST['birthcity']=='' or $_POST['birthstate']=='')........
View Replies !
View Related
MySql Query With SELECT
The following query used to work on older PHP. I have upgraded to PHP 4.3.2 and now it stopped working. No problems connecting to db can even print the variables used for search. But it seems as if the variables aren't presented to the query: $result = mysql_query("SELECT username, name, surname, email FROM forums_auth WHERE username ='$_POST[pnr]' OR name LIKE '$_POST[fnavn]' OR surname LIKE '$_POST[enavn]' ORDER BY surname, name ASC") OR DIE ( mysql_error() );
View Replies !
View Related
MySql Case Select
In my database i have some fields: reg2year reg5year reg10year i want to build a query that will select one of those fields according to a value that was posted from a form in a variable named: $regType.
View Replies !
View Related
MySQL - Select Question
Ive been fiddling around with a mysql query but cant get the result i want. Say i have the following table "orders": OrderID OrderName OrderQty 1 apple 4 2 oranges 2 3 grapes 2 4 peaches 2 5 apple 6 6 peaches 3 7 bananna 2 I want to return the data like so: apple 10 peaches 5 bananna 2 grapes 2 oranges 2
View Replies !
View Related
MySQL And SELECT FORM
PHP Code: <?php foreach ($_POST['farve'] as $key => $farve_output) {     print $farve_output;         echo ", "; } ?> <form method=POST> <select name="farve[]" size=10 MULTIPLE> <option>Grøn</option> <option>Rød</option> <option>BlÃ¥</option> </select> .......
View Replies !
View Related
Using PHP And MySQL To Populate (select) Menus
I am a newbie to php *gasp* and I am trying to make a <select> drop down menu, but I want the menus populated by information from a field in my database. There are a bunch of entries in the field MUD, that are identical......I would like the menu NOT to repeat identical names. EX... Each name only once, even though it is in the database many times.
View Replies !
View Related
MySQL: Insert...select - Update?
I was reading about insert select http://dev.mysql.com/doc/mysql/en/insert-select.html Thought this may be a better way to perform a query I'm doing. The differenc is that I need td select from one field, and then update another field in the same record (it is a backup/undo field). Is there a way to do this in one query? It's a large chunk of data (longtext) so I thought this would be faster than the alternative...
View Replies !
View Related
Select List/Menu Using PHP And MYSQL
Here is my code: <select name="country" class="sidelinks"> <?php do { ?> <option value="<?php echo $row_AllCountries['country_ID']." ";?>"<?php if ($row_AllCountries['country_ID'] = $acountry) { echo "selected"; }?> > <?php echo $row_AllCountries['countryname'];?></option> <?php } while ($row_AllCountries = mysql_fetch_assoc($AllCountries)); ?> </select> A few words to describe: -$row_AllCountries['country_ID'](get from MySQL) is a unique country ID number -$row_AllCountries['countryname'](get from MySQL) is the name of the country -$acountry is the country ID number that i want to be selected when the form loads I have all the values and country names named OK...the only problem is that when the form loads it selects the last country.
View Replies !
View Related
MySql Select Unique Rows?
I am have a table which contains recent search querys of another table. I am tryng to output this data into a list so the user can click, and re-run a recent search... The problem is that the table is full of duplicate searches from the same user. How do I select the searches without retrieving duplicates? SELECT id, term FROM project_term WHERE pid='$_SESSION[project_id]' Also, would it make more sense to store all serches of a paricular user, or stop the insert if the record exists? Is there a way I can do this without performing 2 queries (ie adding some sort of LIMIT or other xeyword to the INSERT query?) I can't make the column unique because two users could perform the same search...
View Replies !
View Related
Mysql SELECT With (varchar) Variable
I have been sent from the mysql forum to here, apparently my problem is strictly PHP related? This one is easy I expect - I need to make a variable that is readable as varchar by mysql - I just think it will be faster to ask here than search all the PHP/MYSQL functions to get it right. In my SELECT statement I would like to pass names (varchar in my database) via a variable called $membername e.g.: PHP Code:
View Replies !
View Related
Select Count(*) Prblm With PHP & MySQL
I am trying to create a login script that will check to see if it is a valid user. I have tried two different ways but neither one seems to work. Here they are: Attempt #1 $connection = mysql_connect($host,$user,$pswd); $result = mysql_db_query($db,$query,$connection); $cntr = mysql_result($result,0); if($result == 1) This gives me this error: Warning: Supplied argument is not a valid MySQL result resource in /home/lyates/gtstatskeeper-www/corecode/login.php on line 33 Attempt #2 $selectresult = mysql_query($query); if(mysql_num_rows($selectresult) == 1) This gives me this error: Warning: Supplied argument is not a valid MySQL result resource in /home/lyates/gtstatskeeper-www/corecode/login.php on line 33
View Replies !
View Related
Editing Mysql Database Row With Select Box
I have a small site, this small site has a few categories, now I can add items through my online admin area fine and delete them fine, but when it comes to editting them I am having some trouble, everything is working fine except the category column, because it is a drop down box I do not know how to have the category selected during the creation progress selected all the other info is loaded.
View Replies !
View Related
|