Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





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 Complete Forum Thread with Replies

Related Forum Messages:
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 !
Want To Delete The First Letter In A Column With 275 Records
table : product
column : code

in this column i have 279 records with bv. S1092734 i want to delete the first letter in all those records.

View Replies !
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 Replies !
Php-myql Delay
I have a script that inserts about 500 rows into a mysql database, but most of the rows don't get entered.  When I try with a small amount of data then the program works fine, but when I run it on all 500, then it goes wrong.  The INSERT statement is in $q and last three lines in my function are:

$res=mysql_query($q);
echo "res=".$res;
return;

The value it prints for $res is "still in process", but the query $q never actually completes.

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 !
Paging And Sorting Column By Column Name?
I am using below code to paging my data. I want to sort my data by Column time. Not getting where i do changes. Code:

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 !
Column To Use?
I have a table with the following:

upn|parent_upn|description|etc etc

What I want to do is, when the parent_upn is not Zero, I want it to select the parent_upn as the upn column.

I was thinking something like this:

SELECT IF(`parent_upn` != &#390;', `parent_upn` AS `upn`)
ELSE(`upn` AS `upn`)
FROM `products` WHERE ......

This doesn't work, what am I doing wrong.

View Replies !
Two Column Display.
I'm trying to display records in two columns. Here's my logic so far...

$numRows=get the total number of rows
$x=divide total rows in half (rounding up for odd #'s)

do a fetch_array on the query

I store the columns into two table cells, I start the main table here Start first table cell. First column of data=do a for loop from $i=1 to $x break into HTML and start the content. End First table cell

Start Second table cell. Second Column of data = do a for loop from $j=1 to $numRows-$x break into HTML and do content. End Second table cell

If anyone sees something inherently flawed with this or just knows a better way, hints and examples are always appreciated. I am an admitted newbie and very used to ASP, so I I think the problem comes from not being able to advance to another record manually. But then again, I really don't know what I'm talking about.

View Replies !
Adding Column
Let's say that I extract some data results from the database and I want to display it such as the following:

ColumnA ColumnB
---------------------------
Result X| Result A |
---------------------------
Result Y| Result B |
---------------------------
| Result C |
---------------------------
Result Z | Result D|
---------------------------

All results come from the same row , just dispatch in several columns.
If I have a variable saying that each result value is ' 1 '.

How do I add column A and display a total (in this case 3)?
How do I add column B and display a total (in this case 4)?

I have to precise that I don't know in advance how many results I 'll collect from the database. The ideal is to post total amount in each column.

View Replies !
Split The Value Column
how can I split the value column in the below option select so that I get back $var1 = 300001 $var2 = 400000? <option value="300001-400000">£300,001 - £400,000</option>

View Replies !
Updating The Column
I am updating the column ourpage in any row of the database busdir2 where cat = farming. It reads only rows where cat = farming correctly, but isn't getting the new ourpage value into the table. Code:

View Replies !
Column Type
when u r using combination of php and mysql to make a discussion board like this one is, then what column type do u use for storing all the posts into mysql database. Is it large text or something like that? I don't have experience with those columns too much.

View Replies !
Column Table
I have a table of records; the records belong to different user ids and are distinguishable by a reference number, Each record has a price. so theres a price column.

The problem isnt getting the total of the whole column. the problem is getting the total for the specific user id and displaying it at the bottom of the price column.

View Replies !
Column Value Blues
I am really struggling with the basics here.

PHP/MySQL

I have a database with three columns:

ID, Name, Phone

I want to return all the unique items in Name.

My Query is

$result = mysql_query ( "SELECT Name FROM database")

Let's say there are 20 entries. I want to return all twenty entries with
a <br /> between them.

I have tried to use foreach and while with mysql_fetch_row & _array, but
I can't get it to work.

View Replies !
Fetch A Column
Is it possible to fetch a column from a queryresult?

View Replies !
Column Sorting
I have found the below code to sort columns, but would like to hide it if another column is sorted as I have the following columns: username , age , online etc... so if online is sorted there is no text saying Sort ascending or Sory descending in username or age. Code:

View Replies !
MySql Column ??
What i want to do is this. I have an field in one of my database tables with money price of product, i want to display the total amount of the table,
i try to use "select sum(fieldname) from table where" but is not working.

View Replies !
Column Pagination
I have a problem in pagination of columns. 5 columns should be displayed in a page. Help me in displaying the rows based on columns. All the columns are displayed in first page. Code:

View Replies !
Column Names
how can i get the column names of ms access table?

View Replies !
Get Highest Value In Column, Then +1 To It.
i wanted to know how i can query a DB, get the highest value, or better yet what number comes next, +1 to it, and add put it in a field in my form. Code:

View Replies !
Set Column Default
we have a table  sistock with column cameramodel  varchar(30) and try to  set default value to blank with the following:

ALTER TABLE SISTOCK CHANGE COLUMN CAMERAMODEL CAMERAMODEL ENUM ('INSTOCK',
'BACKORDER','SERVICE','OBSOLETE') DEFAULT '';

and we get an error at the mysql prompt;

View Replies !
Asc And Desc For Column
How to sort in ascending and descending order for the particular column when clicked on header. Code:

View Replies !
Column Maximum +1
I have an interger column in my database. In one of my SQL statments I want to peform a query that will insert a value into that interger column that is equal to the record with the greatest value plus 1. I know about auto_increment, but this does not do what I want it to do. This field is also not being used as a key, it is being used for ordering. how to do this in a single query, and possibly know a way that will work on any/most SQL languages, not just MySQL?

View Replies !
Group By With New Column
i have a table 'children' like this :

id | child_id | startdate | enddate
------------------------------------------
1 | 1 | jan | jun
2 | 1 | jul | dec
3 | 2 | jan | mar
4 | 2 | apr | nov

Is it possible to group rows with the same child_id, but without loosing de startdate and enddate from other rows?

I want this as output :

id | child_id | startdate1 | enddate1 | startdate2 | enddate2
-------------------------------------------------------------------
1 | 1 | jan | jun | jul | dec
2 | 2 | jan | mar | apr | nov

Is this possible?

View Replies !
Automatically Add Column
I have a list of names being displayed, that currently use this basic code:

View Replies !
Index Every Column
I have an all-integer table for song info. It consists of the songid, and TINY INTs with ID's referencing seperate tables for genres and locations. It also has 9 STATS such as weekly, monthly, and total plays, downloads and score.

SONG_INFO (condensed)
songid - PRI KEY
genre1_id
genre2_id
region_id
country_id
weekly_plays
weekly_score

The nine STAT items are the target of WHERE equally, as are the 5 LOCATION items. You can use a simple sort like "show songs from England" or reference all like "find the highest weekly_score in Japan for Rap". So what do you do when they are all worthy of an index? I currently have a pri key on songid, and a two-column index on genre1-genre2. They are all TINY or SMALL INT, so is it not that big of a deal to index each column? Speed is more important than disk space and the charts are used many more times a day than songs are uploaded, so insertion times isn't a big concern either.

View Replies !
Values From Column
I have got a table where one of the columns has an enum column type. The column heading is "State" The enum string within the "State" column contains all of the fifty states of the union like so:

column heading: "State" enum( 'Alabama', 'Alaska', 'Arizona', 'Arkansas', ... and so forth)

Can I loop through the State column heading and extract each of the fifty enum values (or states) and output them on the page?

// example page output
Alabama
Alaska
Arizona
.....
If so, can anybody give me an idea about how it can be done?

View Replies !
Trying To Edit Column
I have an ID column at the beginning of my table. I want to edit it so that it's auto_increment and can support numbers up to 5 characters. The code phpMyAdmin tried to execute. SQL query:

ALTER TABLE `books` CHANGE `id` `id` INT( 11 ) NOT NULL DEFAULT &#391;' AUTO_INCREMENT

MySQL said: Documentation
#1067 - Invalid default value for 'id'

So I set the default value to 0 but I again get the same error.

View Replies !
Add All Data In A Column
I have a table called jobs that has a total column which contains integers between 0 and 25. I have a deal worked out with a client that caps the total per job at 9. How do I add multiple days to get the months total while capping any day whose total is over 9. I have tried looping it in php which I can't get to work, seems like it should be part of the query structure anyway.

View Replies !
Displaying Column(s)
I am having troubles displaying a query:

$query= "SELECT c.cardID, s.cardID FROM cards s, cards c where s.cardID <> c.cardID";

How can I display the columns ?

View Replies !
Search Column
I'm trying to build a query in mysql that searches for whether a column of strings contains any word from an array of words.

let's say the array is {'cats', 'dogs', 'bears'}

How can you perform a query in MySQL to return all rows that contain any of these words?

"SELECT * FROM table WHERE description=?

[edit: the column contains sentences]

View Replies !
Empty A Column
How do you empty a column (all rows) on information?

I know its possible to "TRUNCATE" a table, is it possible to do the same with just a column?

View Replies !
Referencing Row Column
$total = $type . "frequency";
$freq = $Row[$total];

this obviously isnt the right way to do it because i can manually input 'ptfrequency' and it works but building the variable also gives 'ptfrequency' so im guessing the "grabbing the row with a variable" syntax is incorrect. Ive tried..

$freq = $Row['$total'];
and
$freq = $Row["$total"];

also with no results.

View Replies !
Totaling A Column
I am writing a program to log hours worked on a project. There are clock-in times, and clock out times, then I used a php operator to subtract the two and find the hours. This works fine. BUT I have been searching for a way to then add all of these hours together and get a total hours. Here is the code for the table:

echo "<table border='1'><tr><th>Date</th><th>Time in</th><th>Time out</th><th>Hours</th><th>Notes</th>";

$query3 = mysql_db_query($db, "SELECT * FROM times WHERE clientID='$ID' ORDER BY date");

while($result = mysql_fetch_array($query3)) {

$date= $result["date"];
$IN = $result["timeIN"];
$OUT = $result["timeOUT"];

let me know of either a way to get a total hours from here, or a better way to get the same results, and the total.

View Replies !
Column Repeats Or Not
how you stop a specific table from repeating. I have a table thats showing my database info but there are cells on the right which i dont want to repat but are. I m sure its quite simple but im not sure ow to do it.

View Replies !
Mysql Add Column
$date = date("F j, Y");
$new = "ALTER TABLE closing ADD May 9, 2007 VARCHAR(30) NOT NULL;";

Is this wrong? mysql says :

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 &#399;, 2007 VARCHAR(30) NOT NULL' at line 1

Whts The prob?

View Replies !
Different Values For A Column
I have a table with a column called 'forename' and what I want to be able to do is put all the different values for forenames into a PHP array but only once each, i.e. if there are 20 instances of the forename "John" I only want one of them, in other words I want to capture all the different values. I could do this I guess by using an SQL GROUP query but was wondering if there was a better/more efficient way ?

View Replies !
Values Of Column
I was hoping to get some help with this thing that got me stalled. I am trying to get ALL the values contained in a column of a database (meaning I am trying to get all the values contained in a specific column of all the rows present in a table).

There is a mysql_fetch_row but there doesn't seem to be a mysql_fetch_col, so to speak.
My table rows have IDs but they are non-sequential (the IDs are pretty random). How can I do this?

View Replies !
Select Max Column
I have a categories column and a title column in one table. What I'm trying to do is select the most frequently listed title for each category. I would think that this sql statement would do, but it just returns every column.

select count(title) from table where title IN (select title from table where category = 'category');

To me the inner select should select every title that has a category = 'category'. Then the outside select should display a count of each title that has that one category listed in the inner select.

View Replies !
How To Query One Column?
this is php mysql query script from the patients table register, i want when i enter one value for example for sex m (male),the script will show only male patients all rows,but this script show all the registered parients in any query Code:

View Replies !
Mktime One Column
How can one go from a mktime output to a date when calling from a MySQL database.

What I have done it stored a date/time in the seconds since 1st Jan ... and now what I would like to do is get everything from the database and dump it into a table (Which I have done) but I wish to do the opposite of mktime (if someone could tell me what that is I would appreciate it) and then put that value in instead of the:

so instead of
1012618440
I have
02/02/02 13:54

View Replies !
Auto_increment Column
I have an 'id' column in my table which is set to auto_increment. I was working fine, assigning '1' to the first entry, '2' to the id of the next, etc. But for the last few they have all been assigned an 'id' on 127! Please can someone tell me why?? More importantly, can someone tell me the best way to fix these rows and any future rows. The database is live and new rows are being entered.

View Replies !
Last Variable In Column
i have a simple script where u input ur name, birthday, and favorite color, click submit and it writes in ur info and displays it. The problem is that i set the friend id to be unique and therefore cant be reused. I dont want the person to make up there own id, i want it to be the next consequetive #. Is there a way to find the largest number in the array and add 1 to it?

View Replies !
New Column From Variable
I am trying to create a new column in a table where the column name will be equal to the value of a variable.

$trendDate = date("F j, Y");

$newCol = "ALTER TABLE trendData ADD $trendDate INT(5)";

mysql_query($newCol);

However what's happening is that the new column is just being named $trendDate (not the actual value). Is it possible for me to do what I am trying to do?

View Replies !
Unknown Column
i have a problem with the following code:

$query = "SELECT * FROM demography WHERE uid=".$pid;
$result=mysql_query($query)
or die ("Error - ".mysql_error()."");

$pid comes from a GET method demography is the right name for the db, uid is the i right name for a table in demography it actually works when i replace $pid with one of the values in uid .

View Replies !
Displaying 1 Column
I have a table having 1 column, ID, having 9 records. I want to display the records in a table(3 rows and 3 columns) in my php page such that they the first record is in
(1st row,1st coumn) 2nd record is in (1st row,2nd column) 3rd record is in(1st row,3rd column) 4th record is in (2nd row,1st column) and so on.

View Replies !
Get All Of The Fields In The Column
I am trying to get all of the fields in the column 'size' in my database and add all their values together and then multiply the result by 1,048,576! I can't figure out how to do this.

View Replies !
Subtract 100 From Column
What would be the easiest way to this in sql: I need to subtract 100 from column `foo`, but if doing this makes the value of `foo` less than 0, then I need it to add 1 to column `bar`. Is there an IF command that would allow me to do this, or would i have to compare and subtract the values for each row individually?

View Replies !
Column Count
I am getting this error when I am inserting into a table of 124 fields only 64 fields..
from what knowledge I have. i can do that if i explicitely mention the column names. which I do.

View Replies !
Column Summations
I can combine the Sum Total of these 2 sql statements to get a " Grand Total " Figure? I would like to avoid doing a $x = $result1+$result2 type of solution if i can.

$sqlx= "SELECT Sum(TripTotal) FROM Travel WHERE id='$a' AND ( ( YEAR(Ending)=$Year && MONTH(Ending)>=1 ) || ( YEAR(Ending)=$Year1 && MONTH(Ending)<=12) )";
$resultx = mysql_query ($sqlx)
or die (mysql_error());
if ($myresult = mysql_result($resultx,0))

echo "<font color="RED">"; echo $myresult;

$sqly= "SELECT Sum(TripTotal) FROM Trip WHERE id='$a' AND ( ( YEAR(Starting)=$Year && MONTH(Starting)>=1 ) || ( YEAR(Starting)=$Year1 && MONTH(Starting)<=12 ) )";
$resulty = mysql_query ($sqly)
or die (mysql_error());
if ($myresult = mysql_result($resulty,0))
echo "<font color="RED">"; echo $myresult;

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved