
May 5th, 2000, 02:31 AM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hi All.
First time poster at this forum!
Great to see the support here.
Well, my question is a newbie question, that I'm sure is pretty easy, but I just can't figure it out!
I've got a simple PHP & MySQL database script that I'm working with. I have figured out how to 'add' and 'view' the data in the database, but I can't figure out how to delete the data.
To get to the code here...
Here are my variables: (not real, just for example sake)
$hostname = "YourHostName";
$username = "YourUsername";
$password = "YourPassword";
$userstable = "LinksTable";
$dbName = "YourDatabaseName";
Here are my tables fields:
ID
LinkName
LinkURL
LinkDescription
email
UserName
UserPassword (which I don't use yet!)
Ok, with that stuff out of the way...
I am in need of the syntax code to be able to place within my admin.php3 file to be able to delete a line from within the database table.
Ok, now here is my complete admin.php3 code:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
<html>
<head>
<title> Links Database - Admin Page </title>
</head>
<body text=black link=red vlink=red alink=yellow>
<?
/* declare variables */
$hostname = "YourHostName";
$username = "YourUsername";
$password = "YourPassword";
$userstable = "LinksTable";
$dbName = "YourDatabaseName";
$VLDir = "http://www.PathToYour/Diretory";
// set this to the directory where your main files are!
// DO NOT include a closing "/" on the $VLDir variable!
/* make connection to database */
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
@mysql_select_db( "$dbName") or die( "Unable to select database");
/* Select all from within database */
$query = "SELECT * FROM $userstable";
$result = MYSQL_QUERY($query);
/* How many users are there? */
$number = MYSQL_NUMROWS($result);
/* Print these results to the screen */
$i = 0;
IF ($number == 0) :
PRINT "<P><font face=Verdana Size=1><a href="$VLDir/insert.php3"><B>Add A Link</B></a>";
PRINT "<p><br>";
PRINT "<I><B>There Are Presently No Links!</B></I>";
ELSEIF ($number > 0) :
PRINT "<P><font face=Verdana Size=1>Total Number of Links: $number | <a href="$VLDir/insert.php3"><B>Add Your Link</B></a>";
PRINT " <hr color=black width=60% align=left><BR>";
WHILE ($i < $number):
$LinkName = mysql_result($result,$i,"LinkName");
$LinkURL = mysql_result($result,$i,"LinkURL");
$LinkDescription = mysql_result($result,$i,"LinkDescription");
$email = mysql_result($result,$i,"email");
$UserName = mysql_result($result,$i,"UserName");
$UserPassword = mysql_result($result,$i,"UserPassword");
PRINT "<font face=Verdana Size=1><B>Site Name:</B> $LinkName<BR>";
PRINT "<font face=Verdana Size=1><B>Site URL:</B> <a href="$LinkURL" target="_blank">$LinkURL</a><BR>";
PRINT "<font face=Verdana Size=1>S<B>ite Description:</B> $LinkDescription<BR>";
PRINT "<font face=Verdana Size=1><B>* User Name:</B> $UserName<BR>";
PRINT "<font face=Verdana Size=1><B>* User Password:</B> $UserPassword<BR>";
PRINT "<font face=Verdana Size=1><B>* Email address:</B> <a href="mailto:$email">$email</a><BR>";
PRINT "<BR><BR>";
$i++;
ENDWHILE;
PRINT "</CENTER>";
ENDIF;
?>
<p><br>
<hr width=40% align=left color=black>
Copyright © 4CM, 1996-2000 - <a href="http://www.4cm.com" target="_blank">www.4cm.com</a><br>
Links Database Powered By: <a href="http://www.4cm.com" target="_blank">www.4cm.com</a>
</body>
</html>
[/code]
Can anyone here help me with the next step of this admin page... I need a way to be able to "DELETE" a given entire.
I would be really grateful!
(sure hope all this makes sense!)
Later All.
------------------
--- -- -- --- -- -- ---
John B. Abela
Owner, 4CM
http://www.4cm.com/
URL
|