473,387 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

deleting distinct from database

Hi all,
New to this forum, so to start 'A big hello to you all'.

My question:
I have a drop down menu that is created from the username in my database but is distinct:

<td><class="tdText"><strong><?php echo $lang['admin']['adminusers']['show_emptysessions'];?></strong></td>
<td align="right">
<?
$query= mysql_query("SELECT DISTINCT username FROM CubeCart_admin_sessions");
echo "<form action=removebyname.php method=POST><select name=users>";
while ($r = mysql_fetch_array($query))
{
$user = $r["username"];
echo "<option value=$user>$user</option>";
}
echo "</select>";
?>
<INPUT TYPE=submit NAME=users VALUE="Go!">
</form>



Then my removebyname.php file:

mysql_connect($glob['dbhost'],$glob['dbusername'],$glob['dbpassword']);
@mysql_select_db($glob['dbdatabase']) or die( "Unable to select database");

// DETERMINE WHICH RECORDS TO DELETE
$query="SELECT loginid FROM CubeCart_admin_sessions WHERE username='$user'";
mysql_query($query);

//SHOW WHICH RECORDS TO DELETE
$query="SELECT * FROM CubeCart_admin_sessions WHERE loginid='$user'";
mysql_query($query);

//DELETE CHOSEN USER RECORD
$query="DELETE FROM CubeCart_admin_sessions WHERE loginid='$user'";
mysql_query($query);

//DELETE THE ID COLUMN
$query="ALTER TABLE CubeCart_admin_sessions DROP COLUMN loginId";
mysql_query($query);

//RECREATE THE ID COLUMN STARTING FROM ONE
$query="ALTER TABLE CubeCart_admin_sessions ADD COLUMN loginId INT NOT NULL AUTO_INCREMENT PRIMARY KEY";
mysql_query($query);

//PRINT SUCCESS STATEMENT TO SCREEN
echo "All records relating to $user have been purged successfully";

mysql_close();
?>

<META HTTP-EQUIV="refresh" content="0;URL=sessions.php">


The distinct drop down works fine in my session.php file and locates the removebyname.php file but just prints the success message (minus the varaible i set) returns to the session.php but nothing is deleted.

Any ideas my friends ??????
And thanks for reading.

Jon
Sep 14 '06 #1
4 1970
ronverdonk
4,258 Expert 4TB
How do you know if a mysql statement is executed successfully? You just assume that it is! Set your errors on and investigate the result of each MySql statement. Then you can pinpoint where it went wrong.

Ronald :cool:
Sep 15 '06 #2
To be honest, I dont even think the $user isn't being passed to the removebyname.php file?????

I tried echoing $user at the very top of the removebyname.php and...Nothing!!!!!

It gives me the distinct usernames from my login database okay in dropdown ???

Jon
Sep 16 '06 #3
To be honest, I dont even think the $user isn't being passed to the removebyname.php file?????

I tried echoing $user at the very top of the removebyname.php and...Nothing!!!!!

It gives me the distinct usernames from my login database okay in dropdown ???

Jon
think your better off with: $_POST['user'] , try googleing for $_GET, $_POST, $_COOKIE, $_SESSION, you will learn alot from it...
Sep 21 '06 #4
Thanks for the help.
It was the Get method I needed.
Thaks again
Sep 22 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Matan Nassau | last post by:
Hello. i have a composite which i want to delete. this is a composite which represents a boolean expression (see a previous post of mine with more details at...
1
by: Alex Satrapa | last post by:
I have a table from which I'm trying to extract certain information. For historical reasons, we archive every action on a particular thing ('thing' is identified, funnily enough, by 'id'). So the...
18
by: mathilda | last post by:
My boss has been adamant that SELECT DISTINCT is a faster query than SELECT all other factors being equal. I disagree. We are linking an Access front end to a SQL Server back end and normally are...
2
by: Zak McGregor | last post by:
Hi all I have a table, for simplicity's sake containing one field, called unid. for example, select unid, oid from table gives me something like this: unid | oid ---------+---------
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
6
by: yc022 | last post by:
Hi all, this is my first time using this so i'm not really sure how it works. please bear with me. i am trying to delete a row in a database using a select list. First of all i have a query to...
1
by: martinley | last post by:
Hi, I have a table that contains data similar to the below, apologies for the table layout: employee_number balance_name balance_value a1 Gross Pay 100 a1 ...
1
by: ebusiness | last post by:
I am trying to create nicknames for tables in a remote database. The federated database and remote database are both DB2 UDB V8.2, both OS are AIX. Could anyone tell me how to create a nickname...
4
by: sphinney | last post by:
I'm not exactly sure how to start this post. My question is pretty simple, but it will take a little bit of context before I can state it. (And thanks in advance for taking the time to read this!) ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.