Table Aliases In A DELETE Statement
Is it possible to use table aliases to shorten a multi-table DELETE statement, or am I barking up the wrong tree, so to speak?
View Complete Forum Thread with Replies
Related Forum Messages:
Mysql_fetch_array And Table Aliases
I'm using mysql_fetch_array to run a query along these lines: SELECT A.name, B.name FROM A, B WHERE A.id = B.id I tried this code: while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['A.name']; } .... but the echo statement produces "Notice: Undefined index: A.name". Of course, using just 'name' would be ambiguous because the query also retrieves B.name (and my actual query will involve more tables and probably select '*' [i.e. all columns], so it isn't trivial to use 'AS' to provide individual column aliases).
View Replies !
Delete Statement Problem
I am using a simple delete statement in my php script (below) $q = "DELETE FROM commenttype WHERE TypeID=".$_POST['selectcat']; the problem is it doesnt delete the whole row it only deletes the text in one of the fields of the row. Has anyone else had a similar problem? It works when I run the sql directly from a program such as mysqlphp
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 !
Function Aliases
I have to write a dynamic page which has to run on several platforms, using different databases. Because of that, I want to write a small db-front-end which is an almost 1-on-1 mapping of the functions provided by the PHP API (and the proper front-end is loaded using a conditional include). Using the "C-way", I thought of using define(), but in PHP that can only be used for defining constants. I also though of using function variables, but then the feel of the code changes. The simplest method I have found sofar is the following (for mysql_connect): function sql_connect() { $p = func_get_args(); return ( call_user_func_array('mysql_connect', $p) ); }
View Replies !
Aliases In Like In Apache
In Apache, you can do something like: DocumentRoot d:/www/ Alias /myfolder/ D:/anotherfolder/ Which means that everytime d:/www/myfolder/ is accessed, Apache takes a equivalent file out of D:/anotherfolder/. I want to do the same with .php-files to do local testing under windows. Under linux, you would do a symbolic link, but thats not possible in windows xp My includes are always like: include $_SERVER["DOCUMENT_ROOT"]."/myfolder/test.php" and I hope I don't have to change them because there a lots ;-) I tried to extend the include_path in php.ini with "D:/anotherfolder/", but I'm not able to include anything out of this folder with that.
View Replies !
Wild Card Aliases
Is there a way to do <snip>SELECT table.* AS alias.*</snip>, or do I have to write additional code to automate the process.___________________________ "Contrary to popular belief, Unix is user friendly. It just happens to be very selective about who its friends are."
View Replies !
Can't Delete From Table!
I'm not to familiar to php and sql. I have this assignment to read from database in a table and I HAVE TO be able to push a button causing one costumer to vanish. something to do with id = $id... can anyone help me... and help me fast! This is my code:
View Replies !
Delete From Table
I get this error not sure what's wrong? Error: 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 'VALUES ('mortalsombat@hotmail.com')' at line 3 Code:
View Replies !
Delete Row From Table
I know that we're not really meant to request stuff, but I cannot do this script on my own. I need the bellow code to add delete links in the table so that the user will be able to delete requests. Code:
View Replies !
How To Delete A Table
I just need to know how to delete a table. Not its contents I know how to use the query DELETE FROM but how do I do the DROP TABLE one? the table name is "Events".
View Replies !
How To Auto Delete Table Row?
I Have A Page On My Site That The Database Outputs To. There Is A User That I Dont Want To Ban Yet , But I Do Want To Block Or auto Delete His Data. Now When Everyone Post New Data The Only Table That Would identify Them Is The Username Table, There Is No Member ID Table. Now I Would Like To querry The Database And Auto Delete Table (Username) BOBBY And The Row BOBBY Posted , So There Is No Data Output To My Site Page For BOBBY. Can Someone Give Me A Couple Codes To Try, And I Would Think The Code Would Need To Be On A New Page That I Need To Make Up Right?
View Replies !
Delete A Row From A Database Table
I'm trying to delete a row from a database table. I've made a connection yet it's not working. Is there something wrong with the following code? mysql_query("DELETE * from `contactinfo` WHERE Submission_Number = 1 ");
View Replies !
Delete Records From A Table
I have a table its called queue. It has a field called id. I want to delete all records in the table apart from the ones with id equals to 74 or 75 or 87. How do i do that?
View Replies !
Delete Records From Table 1
I have a script that doesn't delete records from one database when it should, and now I have to do this myself because database is big and causes problems on the server. What I have is: TABLE 1, field auction TABLE 2, field id so I would like to delete all records from TABLE 1 where the value of the field auction doesn't match the value of the field id in TABLE 2. Can someone help me on this, please? I need to get this database cleaned.
View Replies !
Insert Into New Table And Delete From Old
I've got 2 tables of users: 'pending' and 'approved'. The first table (pending) is a 'holding' table for unapproved users and when the user is approved I can click on a checkbox by their name and copy them over to the approved users table (INSERT INTO approved...) This all works fine but I'd also like to delete them from the 'pending' table at the same time. How would I do this? Something like (INSERT INTO approved, DELETE FROM pending)? I'd do a bit of trial and error but since it's on a live site, I don't want to muck it up and not be able to fix it! Code:
View Replies !
Delete Table Contents?
ive got a table thats too big to dump the records in myphpadmin, how can i dump all the fileds (i think there are 4 or 5) but keep the table and fileds intact to be used again?
View Replies !
Multiple Table Delete
I have 3 tables that all have b_id in them. Blog table has b_id, title,author,body,date then I have a tags table that has t_id,name,b_id_blog and a comments table that has c_id,c_body,c_name,c_email,c_url,b_id_blog. My question how can I remove all data from the 3 tables based off the b_id?
View Replies !
Delete Selected Records From Table.
Can anyone see why this connection doesn't work? It's suppose to delete selected records from my table. <?php if (isset($_POST['delete'])) // && isset($_POST['delcus'])) { foreach ($_POST['delcus'] as $val) { echo "$val"; $conn= mysql_connect( "localhost", "user", "password" ); $sql = mysql_select_db( "snow" ); $del = mysql_query("DELETE * FROM request WHERE qid =" .$val); //$rows = mysql_num_rows($del); $rs = mysql_query($conn, $sql, $del); if($rs) .........................
View Replies !
Delete Something From A Table Using A String Variable.
Basically, I am trying to delete something from a table using a string variable. $tsremove = "Available for All Windows Platforms"; $tscat = "solutions"; mysql_query("DELETE FROM techspecs_'$tscat' WHERE '$tscat' = '".$tsremove."'"); So the mysql_query should be DELETE FROM techspecs_solutions where solutions = "Available for All Windows Platforms";
View Replies !
Delete Textfile List From MySQL Table
I have a list of email addresses that I need to delete from my database and they are in a textfile, one on each line like below... a@b.com c@d.com e@f.com etc. does anybody have a snippet of PHP code that I could use to accomplish such a task?
View Replies !
How Do I Delete Selected Rows From MySQL Table?
I am trying to figure out how to delete selected rows from a MySQL database table. The web site that I am working on has a page that will extract rows, using the "SELECT * FROM .. etc." statement from a database and output them in a table - like the one below (bottom part). I've got that part figured out. What I am trying to figure out is if the user puts a checkmark in one of the checkboxes (below) how would I write the PHP code to delete one or two of the rows from the MySQL table? PHP Code:
View Replies !
Commands To Delete, Recreate And Repopulate A Table
I am in the middle of an assignment at uni which has lots of tasks which will eventually create 4 different dynamic pages. On one of the pages, I need to create a script to open a file containing MySql in it. The MySql has commands to delete, recreate and repopulate a table. I currently have; $handle=fopen("filename" , "r"); $lines=file("filename"); but I'm not entirely sure where to go from here.
View Replies !
SELECT Statement From MYSQL Table
I have at MYSQL table called "results" w/ the following fields: tournaments / team / participants / fish / weight / lunker Lake1 / team1 / participants1 / fish1 / weight1 / lunker1 Lake1 / team2 / participants1 / fish1 / weight1 / lunker1 Lake1 / team3 / / fish2 / weight2 / lunker2 Lake1 / team4 / / fish3 / weight3 / lunker2 Here is some of my code:
View Replies !
Create Table With Foreach Statement
I have a code that reads a page for a top 20 ranking type thing. The code works great but now I'm trying to build a table with it. Once it reads 5 names, I want it to start an new cell. Here's what I have so far. Code:
View Replies !
Multi Table Insert Delete Select Function Needed.
I am going nuts here and I know with all the functions out there, there must be an easier way to do this. Maybe someone can point me to the right tutorial or even show me how to do this. I have a $main_id and many $sub_id tables and like to “SELECT to view” INSERT and DELETE those. UPDATE must not be but would be nice. Here is how it looks:
View Replies !
Listing Table Data With An Option To Delete Each Individual Item.
Was wondering if anyone could help me with a PHP, MySQL problem. I am completely new to PHP and MySQL. I have been trying to find a way to list data from a table on a web page and after each individual item have a hyperlink to allow users to delete the information listed. Can anyone help? i.e. Name Age Sex ------------------------------------------ Adam 21 M delete Betty 22 F delete Chris 23 M delete Daisy 24 F delete ------------------------------------------------------------------------------------------------------------------------------ (delete after 'Sex' would be the hyperlink to delete that entire line (row) from the table).
View Replies !
MySQL SELECT Statement - Search A Field In Table
I am trying to search a field in my table for more than one likeness. Can I create a query that says: PHP Code: <?php $query = "SELECT * FROM $table WHERE $search_field (LIKE '%$this%) || (LIKE '%$that%')"; ?> OR, should I just do two different query statements and concatenate the results?
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 !
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 !
Convert An IF ELSE Statement To A SWITCH CASE Statement?
How do I convert an IF ELSE statement to a SWITCH CASE statement? The switch case below doesn't work. $textlen = strlen($descr); if($textlen>10 && $textlen<50) { $completeness = 1; $deduct = 1000; } elseif($textlen>50 && $textlen<100) { $completeness = 2; $deduct = 500; } else { $completeness = 0; $deduct = 2000; } switch($textlen) { case >10 && < 50: $completeness = 1; $deduct = 1000; break; case >50 && < 100: $completeness = 2; $deduct = 500; break; default: $completeness = 0; $deduct = 2000; break;
View Replies !
If Statement Construction Within An Echo Statement
I have a form that is being used to "update" user info and I need the information to be pulled from the users table. In order to get the variables into the form, I am echoing it in and using an mysql array to place them into the form. at the t-shirt size part of the form the code is as follows ....
View Replies !
Statement Within An Echo Statement
I have a series of fields being drawn from a db and displayed on the page. I would like to insert an image if the value of one of the fields == 1 otherwise no image I can't quite get my head around the right way to do this. I know the following syntax is wrong, but this is what I'd like it to do: PHP Code: echo "<p>" . $itemname . "<br />" . $itemdescription . "<br />" . (if ($showitem == 1) echo <img src="image.jpg">; ) . "</p>";
View Replies !
Grab Content From HTML Table And Place Into MySQL Table?
I am in the process of helping a co-worker upgrade some of his old static html pages into dynamic MySQL driven pages. He currently has a lot of pages with huge tables displaying data. Does anyone know if there is a script or class that can convert a table to a .sql file for upload?
View Replies !
Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for. Can anyone help me get the Agreed? table's background color to the colors above? Code:
View Replies !
How To Select Count From 2ndary Table On Matches In Primary Table?
I'm coming back after about a 4 year break, so even basic stuff is taking forever to re-learn - I have a feeling that this is going to be a dumb question. Any suggestions on the best way to: SELECT count(<other table entry id>) FROM <other table> WHERE <the entries in this table referencing other table id> = <entries in other table by other table entry id> Basically, I just want to construct multiple rows of data that say: "here's the details of a Topic, and there are 10 (or whatever) Entries for this Topic" It seems like it should be simple enough. Code:
View Replies !
Create A Table Say 3 Rows 3 Cols And Put An Include In Each Table Cell
I have been playing with php includes and thought it would be interesting to create a table say 3 rows 3 cols and put an include in each table cell pointing to other sites, i thought make each cell 500px wide and i would have a page with say four news sites from different countries, so i built my table added this in <?php include("http://www.cnn.com")?> plus others uploaded it then sat back to watch my master peice in action, but hey guess what! includes dont quite work like that, the sites all loaded under each other and the page was veery wide, and even my nav table include had the same rollover effect as the first site in the includes. Is there a way this can be done easily or should i forget this idea now, I have no need for this on my site I am just at the start of learning php so have tried this just for education reasons.
View Replies !
Drop Down A Table Is Suppose To Show Up To Give You The Geocache Table
Under the drop down a table is suppose to show up to give you the geocache table when I had the drop down setup as html it worked fine which leads me to believe something is conflicting in my code. I need an extra pair of eyes to look at it, cause I just cant catch what Im missing. PHP Code: <?php //include files to configure db and open it include 'config.php' include 'opendb.php' //pull name for drop down $query  = "SELECT name FROM geocache"; $result = mysql_query($query); $options = ""; // find the selected geo name $result2 = mysql_query("SELECT * FROM geocache WHERE name = '" . $_POST['name'] . "'"); ?> ........
View Replies !
Outputting A Table Or Form Using SHOW FIELDS FROM Table
In the code the MySQL database was queried using "SHOW FIELDS FROM table" which and the returned results of column names was then use to build an output for a form and a table with php using a series of if statements along the lines of if the returned field name matches something echo a text input field. I have never seen this done this way before, so I want to get the opinion of the devshed user. Does it seem like an unsual long process to build up a form. Is there a security advantage doing it this way? Has anyone ever done it this way before?
View Replies !
Finding Matches In A Table And Then Moving That Match To Another Table?
Ok, I have a database that has a table called critiera in this table is to fields on is ID and the other is critiera. Now I want to filter out all the one that don't apple to the list and move the one that match to a different database. I know how to open a connection, close, select but I don't know how I would inside of a database use another one as the way to create the list of critieras....
View Replies !
|