Delete Column Names On A Match
I have a table with attributes like this:
catA_totals
catA_averages
catA_median
catB_totals
catB_averages
catB_median
catC_totals
catC_averages
catC_median
catD_totals
catD_averages
catD_median
.... etc
and I decide I no longer want to have the median tables, how can I select all these tables and drop them... something like drop *._medians or something like that.
I saw the alter table can use multiple drops, but only when all the column names are explicitly typed.
View Complete Forum Thread with Replies
Related Forum Messages:
Need Column Names, Not The Array Key...
I am running a script that exports a MySQL table into an excel file. The problem I am having is the column (header) names are not showing up in the final .xls file. I instead get the key value 0, 1, 2, etc. Here is the section of the code that should write the actual names. I can't figure out what's wrong. It looks good to me. Am I missing something? Code:
View Replies !
PHP - Column Names In Array
see the code below <? $rsQry = mysql_query ("select * from tblCustomer"); $arrQry = mysql_fetch_row($rsQry); ?> Now if I try to fetch a Customer's Name from the "Customer_Name" column from the "tblCustomer" table with the following code then I dont get anything: <? echo $arrQry["Customer_Name"]; ?> Why?
View Replies !
Do An Insert Without Specifying Column Names
If I use SQL Server with a table that has an identity column I can still do an insert without specifying column names. In MySql with a table that has an autoincrement column I have to specify all the column names when doing an INSERT.
View Replies !
Displaying MySQL Column Names Using PHP
I'd like to be able to display the column names of a table on a page. Is there a way to read that information in using SHOW? And then to display that information again? Or would I have to store these names in a seperate table and display these values? I tried this, but it sure didn't work: $result = mysql_query ("show columns from industries"); print ("<table>"); if ($row = mysql_fetch_array($result)) { do { print ("<tr><td bgcolor=#cccccc>"); print $row["field"]; print ("</td><td bgcolor=#cccc00>"); print $row["type"]; print ("</td><td bgcolor=#cccc00>"); print $row["null"]; print ("</tr>"); } while($row = mysql_fetch_array($result)); } else {print "Sorry, no records were found!";} print ("</table>");
View Replies !
Numeric Column Names In Mysql?
i am trying to create a table with a column name called 2004. But I keep getting a mysql error? Is there any workaround? Unable to execute: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near �� TEXT,2004_reference TEXT,2005 TEXT,2005_reference TEXT,200 CREATE TABLE test (id int(6) NOT NULL auto_increment, membership_number TEXT,first_name TEXT,last_name TEXT,spouse TEXT,phone_priv TEXT,phone_bus TEXT,address_street TEXT,addr_town TEXT,addr_city TEXT,membership TEXT,donor TEXT,1998sa TEXT,1999sa TEXT,2000sa TEXT,200s1 TEXT,2002sa TEXT,2003sa TEXT,2003_reference TEXT,2004 TEXT,2004_reference TEXT,2005 TEXT,2005_reference TEXT,2006 TEXT,2006_reference TEXT, PRIMARY KEY (id),UNIQUE id (id))
View Replies !
[ot] Using Original Column Names In Pages/forms
I just want to know if using the original column names in web forms is a good idea or is it better to use fake/alias names so those viewing the source will not get the original column names. However, alias names would add a level of complexity and might impact performance.
View Replies !
JOINING 2 Tables, Duplicate Column Names
I am trying to JOIN tables together to allow me to get data based on a lookup table: But it is displaying columns with identical column names as they are they same but from different tables. In this case its "module_id" and "student_id" being displayed twice. I have tried to edit it to only display one instance of each in the results, but am having no joy as yet. This wouldnt be such as problem but when I try and compare/pull the data with PHP identical column names (even if they contain the same data), wont PHP fall over? PHP Code:
View Replies !
Assign Column Names As Array Keys
Want to create an array that has db column names for the key names and field values as the array values. Is there an easy way to do this? If not possible directly, is there a way in php/mysql to get a list of column names in a table such that I could use those values as the keys?
View Replies !
Do A DELETE Statement To Remove Any Records That Don`t Match.
I`m just trying to figure out the best method to delete my records and wondered if it was possible to do a DELETE statement to remove any records that don`t match. Here is my code so far: $Query="select blah its huge:-)"; $RESULT=mysql_query($Query); $my_rows=mysql_num_rows($RESULT); for ($a=0; $a<$my_rows; $a++){ mysql_data_seek($RESULT, $a); $Array = mysql_fetch_array($RESULT); printf("%s<BR>", $Array['Email']);} My Query returns Matched Records, what I would like to achieve is deletion of the records that didn`t match, would it be possible to do that under the printf statement. So delete all the records in the table that don`t match up to $Array['Email']??
View Replies !
How Do I Delete A Column? MyQL PHP
I have a database where i want to be able to replace an image file in a folder and the associated database entry. I want to keep the rest of the data in the row. Here is the current FORM SUBMISSION CODE that I use to submit to the database. *** I would like to be able to delete the image file and the column "file" and replace it using a form. Currently I can look at the list and modify each music review but I cannot edit the 'file' field for the image - which is a FileField. THE SUBMISSION SCRIPT...
View Replies !
Delete Column Contents
Is there a way, through PHP, to delete the contents of a column without deleting the actual column. I know I could do it by deleting the column and adding it again but just wondering if there's a more efficient way.
View Replies !
New Record:Column Count Doesn't Match Value Count At Row 1
I get this error when I try to add a new record to my MySQL Database. "Column count doesn't match value count at row 1" So after searching through this forum it seems the problem is that the number of columns in my query doesnt match up to the number of columns in my table. Seems fairly easy to fix doesnt it. However my query has exactly the same number of columns as my table, they are also in the same order. Code:
View Replies !
Setting Variable Names Using Field Names?
I'm having trouble creating dynamic variables using field names. Basically I got a heap of fields named after Players and I want to grab the field name and make a variable called it while assigning it a value from a post variable which is also the player name. This is the code I'm using: $result=mysql_query("SELECT * FROM playerstats"); while($fld = mysql_fetch_field($result)) { if ($fld->name!='match_id' && $fld->name!='opponent' && $fld->name!='map') { $fld->name=$_POST[$fld->name]; } }
View Replies !
Match Array Key To Query Match
I have an array that I output through a loop. It's a list of states. Now I need to run a query ona table and if I find any results associated with this state in db mark this table with, say <strong>State</strong> tags. Having difficulties figuring it out. I'd hate to run a query 50 times to get the results. There's gotta be a better way.
View Replies !
Preg Match To Match A Url
Trying to use preg_match to match the following form http://www.example.com/user-45...what am i doing wrong? preg_match("/^http[://]+[www]+.[a-z0-9-_]+.[a-z.]{2,6}+[/a-z0-9-_]$/i",$_POST['url'])
View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong? <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $id="delete from todo where id='$id'"; mysql_query($id); mysql_close(); ?>
View Replies !
How To Query From One Column Then Sort Using Another Column
I am trying to get the last 100 albums I entered into my database using the album_id (Highest being the latest entry) then sort them alphabetically using the album_title column. I can get the latest 100 easily but cannot figure out how to also sort the results by the album_title before I display them. This is what I have so far which gets what I want but not in alphabetical order. <?php $sqlquery = mysql_query("SELECT * FROM albums ORDER BY album_id desc limit 100", $db); while ($result = mysql_fetch_row($sqlquery)) { echo "<a href='music_info.php?album_id=$result[0]'><span style='text-decoration: none'>$result[1]</span><br></a>"; } ?> I have been trying to add a second ORDER BY to the query like so. $sqlquery = mysql_query("SELECT * FROM albums ORDER BY album_id desc limit 100 ORDER BY album_title", $db); but this obviously isn't the way I should be doing it.
View Replies !
Mysql Delete - $query = Mysql_query("DELETE
how would i do the following ? $query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error()); im just getting "Unknown table 'notes' in MULTI DELETE" ?
View Replies !
PDF Mix & Match
I was wondering if anyone had any experience of splitting & appending PDF's? A client has a huge pdf, and he wants to give the user the ability to mix and match the chapters that they want to download. The final final will be 1 pdf, but may consist of various different chapters chosen from a list. The chapters will be ripped from 1 master pdf. Oh, and the PDF is not just text it contains all manner of images,links & the like! And that is what is required. I was wondering if anyone had any pointers regarding this? I'm thinking PDFLib, but I haven't fully looked into it yet.
View Replies !
Match Only Three
I have this code: $numbers = array("04","13","18","21","30","46","(05)"); foreach($data as $key => $value) { if($data[$key][5] == $numbers[0] && $data[$key][6] == $numbers[1] && $data[$key][7] == $numbers[2] && $data[$key][8] == $numbers[3] && $data[$key][9] == $numbers[4] && $data[$key][10] == $numbers[5] && $data[$key][11] == $numbers[6] )//did they win the jackpot? { echo "You have Won!<br /><br />"; } else { echo "You did not win this time :(<br /><br />"; } } The above code will check the $data[$key] array and match the values against the values in the $number array. That is fine. However what if I wanted to see if only 3 values in the $numbers array matched the numbers in the $data[$key] array. How would I do that?
View Replies !
Where Match () Against ()
i would like to change the following line WHERE MATCH (artists.artist) AGAINST ('$id') to WHERE DOESN'T MATCH (artists.artist) AGAINST ('$id') ie i would like to show all results where $id does not occure.
View Replies !
Match Against
I want use a match against in search engine on multiple tables. In other term I want to create an index and fulltext across 2 tables.
View Replies !
PHP Pattern Match
I need to convert the following pattern which I found in a php program into a perl regex... but I have NO CLUE WHAT IT DOES! &[^;]; <[^>]*> Actually, for the second one, I have an idea as to what it does, but I'm not sure... they are both used in this context:
View Replies !
Run SQL With Value Match To $array
I wonder if it is possible to do "select" in mySQL database with value matching to an $array. For example, $array = array("shanghai", "beijing"); I want to select cities whose names match the values in $array. Instead of using foreach(), is it possible to do the select with the array itself. I know some languages support this function. For example: SELECT fieldname FROM cities WHERE city_name in '$array' Is it possible in PHP with MySQL?
View Replies !
Regex: How Do I Match A Dot?
I am trying to match the dot, so that it actually matches "a dot" and not "everything". How do I write that? Example: the word "st." I have tried '/st./i' '/st./i' Sorry if this question is noobish. I have not been able to find the answer searching the net.
View Replies !
While Query Only Does First Match
I'm generating letters based on the date a lead was entered into the database. I've tried moving the } into several places. If I move it before the 2nd query I get all the letters but no dealers. If I move it to the bottom (as it now) I get 1 letter with the dealers. I can't figure out what to do to make the query generate all the letters with their associated dealers. PHP Code:
View Replies !
Trying To Match Date..
I am trying to make an Order History Lookup page for an E-commerce site. Now.. when an order is submitted the dateinserted is formated as date("U") and stored in the Db table. Now.. when I create the lookup date formfields I have them as such: Month (02) Day (25) Year (02) How would I go about getting these values so that I can compare exactly against the date("U") string that is stored in the DB?
View Replies !
Regex - How To Match Until Something
How do you replace an occurence until a certain point: You can see my example code below and the output: $string1 = 'Hello world today' $string2 = 'Hello blahblah' $string1 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string1 ); $string2 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string2 ); echo "$string1 - This should be Hello *** today "; echo "$string2 - This is correct "; Outputs: ====== Hello *** - This should be Hello *** today Hello *** - This is correct
View Replies !
Match Any Character But
Can I use any reg exp(mainly for mod rewrite) where I can match any character but a fixed list? I need to match a string that does not contain any /'s but I don't want to have to use a character search string. (I don't see any need to have to hardcode it) that is, .. matches any single charactr and (.*) matches any string what I want to do is use something like % that means ..%/ which means match any character but /. Of course it would need to be valid and I know I can't make up semantics for the reg ex. My point is is that, is that I don't want to have to use [a-z0-9-%&^$#@!etc...] to mean . but not /. Surely there is a way to exclude a few characters from . without having to increase the complexity of the expression 1000 fold? If you don't get that, then a simple example would be that I have an arbitrary string and I want to match only if that string does not contain an a. Sure I can so something like [bcdefghijklmnopqrstuv1234567890!@#$%^&*()_+]['/.,<>?:"{}+-=~`..........................] but surely reg exp has an easier way??? (again, this is specifically for mod rewrite)
View Replies !
Regex: Before And After The Match
I want to match a table and also capture the parts before and after the table: preg_match_all("|(.*)(<table.*table>)(.*)|",$text, $parts); But of course it doesn't work, presumably because the first .* is greedy. I tried adding an ? but that doesn't work either. How do I do this ?
View Replies !
Php Emails Do Not Match ??
i have created a registration script for my website and i have added a new featurer that makes you enter your email address twice and then it is supposed to check if they are the same and then if they are submit the form but if not show an error but even if the email addresses are the same it still shows the error below is the code for the email checking Code:
View Replies !
Match Title
I am trying to get a the title out of a html page, I have the html code loaded into a variable. The only thing is sometimes the title is not on the same line. <title>need this text</title> $title = preg_match(/<title>s</title>/i, $html); help me with this match syntax?
View Replies !
Match Number
below is my code it is no working as I thought it would though, I get no errors but when I try to echo out $arr_chk_privacy to see what it says it just shows "array" PHP Code: $arr_chk_privacy = $_POST['chk_privacy']; $cnt_chk_privacy = count($arr_chk_privacy); if ($cnt_chk_privacy > 0) { if (in_array(3, $arr_chk_privacy, true)) { $_SESSION['hideonline'] = 1; //hide online status $sql_delete="DELETE FROM friend_online WHERE userid='$info[auto_id]'";//delete from online table executeQuery($sql_delete); }else{ $_SESSION['hideonline'] = 0; //show online status } $chk_privacy_ids = implode(",", $arr_chk_privacy); }
View Replies !
Pattern Match
Where can I find infi or doc on "pattern match" used within WHERE clause (mysql). As I need to matche with PHP variables I'd prfer something adapted to PHP. In "PHP&MySQL Web Devlpt" (Luke Welling) I can't see much.
View Replies !
FULLTEXT Match Against
I have a fulltext column that contains many word, I am passing $search to it which has 3 words in it currently it finds all entries containing the 3 words but lists entries that also have one or 2 of the words here is my mysql request mysql_query("SELECT * FROM addresses WHERE MATCH(title) AGAINST('$search')") How do I get it ot only show entries which contain all 3 words only?
View Replies !
MySQL WHERE MATCH
I have the following table CREATE TABLE `fulltext_sample` ( `copy` text, FULLTEXT KEY `copy` (`copy`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `fulltext_sample` VALUES ('This is a test to see how mysql works'); Now I do a search for SELECT * FROM fulltext_sample WHERE MATCH(copy) AGAINST('mysql'); and it return 0 results. Can someone please help me with this?
View Replies !
Events Match
I have events recorder in db with the following type date format: 2005-05-31. How do I select the ones that are of this month?
View Replies !
Match An Array
i have this array $ary = array( "Today date is 1, our breakfast is 2 eggs and salad", "Today date is 13, our breakfast is 3 breads and beff", "Today date is 18, our breakfast is 2 toasts with egg", "Today date is 21, our breakfast is 5 wafels with honey", "Today date is 30, our breakfast is a bowl of sereal" ); i need to search and match the date (that i have bolded it) and then compare it to today date using this fuction date("j"); to find the date in the string i'm using this regex ([1-3][0-9]?)(?=, our). i have try everything but i cannot solve it so in the end, if today date is 18 i want to display only this string. Today date is 18, our breakfast is 2 toasts with egg can i do this?
View Replies !
Match A DB Entry
I need a way to match in the DB every entry in a row that has Ƈ/' at the beginning but it needs to only be Ƈ/' so entries that have ཋ/1/' should not be matched
View Replies !
Preg Match?
I'm trying to work on this basic preg_match that gets the </a> tag. For some reason, it doesn't work. preg_match('/(</a>)/i',$string,$match);
View Replies !
Difference Between WHERE LIKE And MATCH
I'm writing a search query using keywords - at the moment the search uses FULLTEXT fields and looks like this : "SELECT *, MATCH (".$fields.") AGAINST ('".$searchKey."') AS score FROM products WHERE MATCH (".$fields.") AGAINST ('".$searchKey."')" using that query i get the results in order of pertinence BUT as far as i can tell i can't use the '%' wildcard for searching with MATCH - is that correct ? if I want to use wildcard searching it seems i have to use SELECT * FROM prducts WHERE LIKE %bla% but, as far as i can tell, i don't get the results in order of pertinence so - is there a way of using wildcard matching but still getting the results in order of pertinence ?
View Replies !
New To Content To Match URL
I have a site where the database is not connected to PHP. I would like to know a command where the URL typed matches what is then displayed on the page. Ie url is www.mysite.co.uk/great-stuff or url is www.mysite.co.uk/not-so-good I would then like this to be show on the page (where I choose) For example my subject is great stuff as usual. or my subject is not so good as usual. Can I do this without a database. (something else I would have to learn) Or can it be done without.
View Replies !
Match Syntax
I still havent figured out how the match syntax works. anyone know of a good turorial on this. I am trying to match: (RE:123) where the 123 is any integer (but not likely more then 3 digits.
View Replies !
|