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




How To Remove A Row In Mysql Table With A Checkbox ?


I'm having trouble writing the code for deleting a row with a checkbox.

My page allready contains an update and a insert form, which works great, but removing rows with a checkbox.This is my php code.

<?php require_once('../../Connections/fisherintranet.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO licenties (company, license) VALUES (%s, %s)",
GetSQLValueString($HTTP_POST_VARS['company'], "text"),
GetSQLValueString($HTTP_POST_VARS['license'], "text"));

mysql_select_db($database_fisherintranet, $fisherintranet);
$Result1 = mysql_query($insertSQL, $fisherintranet) or die(mysql_error());
}
if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form3")) {
$updateSQL = sprintf("UPDATE licenties SET company=%s, license=%s WHERE license=%s",
GetSQLValueString($HTTP_POST_VARS['company'], "text"),
GetSQLValueString($HTTP_POST_VARS['licupdate'], "text"),
GetSQLValueString($HTTP_POST_VARS['license'], "text"));

mysql_select_db($database_fisherintranet, $fisherintranet);
$Result1 = mysql_query($updateSQL, $fisherintranet) or die(mysql_error());

$updateGoTo = "licenties.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($HTTP_POST_VARS["MM_remove"])) && ($HTTP_POST_VARS["MM_remove"] == "form2")) {
$removeSQL = sprintf("Delete from licenties WHERE 'ID'==???????????");

mysql_select_db($database_fisherintranet, $fisherintranet);
$Result1 = mysql_query($removeSQL, $fisherintranet) or die(mysql_error());
$removeGoTo = "licenties.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$removeGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$removeGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $removeGoTo));
}
session_start();
if ($HTTP_SESSION_VARS["statusCheck"] != "Admin")
header("Location: menu.php");
$colname_licenties = "1";
if (isset($HTTP_SESSION_VARS['companyCheck'])) {
$colname_licenties = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['companyCheck'] : addslashes($HTTP_SESSION_VARS['companyCheck']);
}
mysql_select_db($database_fisherintranet, $fisherintranet);
$query_licenties = sprintf("SELECT license FROM licenties WHERE company = '%s' ORDER BY license ASC", $colname_licenties);
$licenties = mysql_query($query_licenties, $fisherintranet) or die(mysql_error());
$row_licenties = mysql_fetch_assoc($licenties);
$totalRows_licenties = mysql_num_rows($licenties);

$colname_alles = "1";
if (isset($HTTP_SESSION_VARS['companyCheck'])) {
$colname_alles = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['companyCheck'] : addslashes($HTTP_SESSION_VARS['companyCheck']);
}
mysql_select_db($database_fisherintranet, $fisherintranet);
$query_alles = sprintf("SELECT * FROM licenties WHERE company = '%s' ORDER BY license ASC", $colname_alles);
$alles = mysql_query($query_alles, $fisherintranet) or die(mysql_error());
$row_alles = mysql_fetch_assoc($alles);
$totalRows_alles = mysql_num_rows($alles);
?>

This is my code of my form :

<form name="form2" method="post" action="<?php echo $editFormAction; ?>">
<table width="30%" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#999966">
<tr>
<td colspan="2" bgcolor="#999900"><div align="center"> <font color="#FFFFFF" face="Times New Roman, Times, serif"><strong>licenses</strong></font></div></td>
</tr>
<?php do { ?>
<tr>
<td><div align="center">
<p>
<input name="<?php echo $row_alles['ID']; ?>" type="checkbox" id="<?php echo $row_alles['ID']; ?>" value="<?php echo $row_alles['ID']; ?>">
<font color="#FFFFFF"> </font></p>
</div></td>
<td><div align="center">
<p><font color="#FFFFFF"><?php echo $row_licenties['license']; ?></font></p>
</div></td>
</tr>
<?php } while ($row_licenties = mysql_fetch_assoc($licenties)); ?>
</table>
<p align="center">
<input name="MM_remove" type="hidden" id="MM_remove" value="form1">
<input type="submit" name="Submit" value="Remove selected license">
</p>
</form>




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Comparing PHP Array From Checkbox To MySQL Table
My problem involves updating a MySQL table using checkbox input. I'm relatively new to both PHP and MySQL so I'm looking for a little direction on the smartest way to accomplish my goal.

When a user goes to a project page, they are able to categorize their project by area. The user checks a series of checkboxes and the results are stored in an arrays called $category_ids. I'll called the project id $project_id.

What I want to do is compare the array $category_ids to entries in a MySQL table for $project_id. Then I want to add the links that aren't already in the table and delete the ones that need to be deleted. The table has these fields:

projects_cat_link (table)
----------------------
category_id ¦ project_id (fields)

Does anyone have any tips on how to do this? I've gathered that maybe there's a way to get the MySQL data into a similarly formed array and then use functions like array_diff to compare. But then I'm not sure how to use the comparison in a MySQL query to add/edit/delete the links.

Checkbox And Relational Table
I've a formular with a list of clients per work experience. I can have
several clients for a experience. So I have a table for "experience", one
for "client" and a relational table "rel_experience-client".
To retrieve the list of clients per work experience I use the query :
SELECT *
FROM experience, client, rel_experience_client
WHERE experience_ref=experience.id AND client_ref=client.id AND
experience_ref=12345
ORDER BY libelle

How can I retrive this information and add a checkbox on each client if they
are on the experience?
With the solution below, I can't find the ... solution!

<?php require_once('../../../Connections/metadeco_connect.php'); ?>
<?php
mysql_select_db($database_metadeco_connect, $metadeco_connect);
$query_rs1experience = "SELECT * FROM experience";
$rs1experience = mysql_query($query_rs1experience, $metadeco_connect) or
die(mysql_error());
$row_rs1experience = mysql_fetch_assoc($rs1experience);
$totalRows_rs1experience = mysql_num_rows($rs1experience);

mysql_select_db($database_metadeco_connect, $metadeco_connect);
$query_rs4_rel_experience_client = "SELECT * FROM experience, client,
rel_experience_client WHERE experience_ref=experience.id AND
client_ref=client.id AND experience_ref=12345 ORDER BY libelle";
$rs4_rel_experience_client = mysql_query($query_rs4_rel_experience_client,
$metadeco_connect) or die(mysql_error());
$row_rs4_rel_experience_client =
mysql_fetch_assoc($rs4_rel_experience_client);
$totalRows_rs4_rel_experience_client =
mysql_num_rows($rs4_rel_experience_client);

mysql_select_db($database_metadeco_connect, $metadeco_connect);
$query_rs7client = "SELECT * FROM client ORDER BY libelle ASC";
$rs7client = mysql_query($query_rs7client, $metadeco_connect) or
die(mysql_error());
$row_rs7client = mysql_fetch_assoc($rs7client);
$totalRows_rs7client = mysql_num_rows($rs7client);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body><form name="form1" method="post" action="">

<?php
if ($totalRows_rs7client>0) {
$nested_query_rs7client = str_replace("12345", $row_rs7client['id'],
$query_rs7client);
mysql_select_db($database_metadeco_connect);
$rs7client = mysql_query($nested_query_rs7client, $metadeco_connect) or
die(mysql_error());
$row_rs7client = mysql_fetch_assoc($rs7client);
$totalRows_rs7client = mysql_num_rows($rs7client);
$nested_sw = false;
if (isset($row_rs7client) && is_array($row_rs7client)) {
do { //Nested repeat
?>
<input <?php if
(!(strcmp($row_rs1experience['id'],$row_rs7client['id']))) {echo "checked";}
?> name="checkbox_client" type="checkbox" id="checkbox_client" value="<?php
echo $row_rs7client['id']; ?>">
<?php echo $row_rs7client['libelle']; ?><br>
<?php
} while ($row_rs7client = mysql_fetch_assoc($rs7client)); //Nested
move next
}
}
?>
<br>

<input type="submit" name="Submit" value="Submit">

</form>
</body>
</html>
<?php
mysql_free_result($rs1experience);
mysql_free_result($rs4_rel_experience_client);
mysql_free_result($rs7client);
?>

Checkbox In Mysql Fields
PHP selects and shows a list of records. Next to each record is a check
box. If user checks the box the record(s) is selected and appended to
another 2nd DB....when the user finally presses a button

Basically I hope you get my drift, pretty normal but powerful stuff...
Are there any tutorials or snips on how I'd do this?

Checkbox Forms, Php & Mysql
I'm about to add some checkboxes to a form, and then store the data in
a column on a MySQL database. Just wanted to know best practice, at the
moment I'm writing and thinking .. God that's ungly code ...

<input type="checkbox" name="delta" <?php if ($delta==1) { echo
"checked"; }?>> Delta<br>
<input type="checkbox" name="mastercard" <?php if ($mastercard==1) {
echo "checked"; }?>> Mastercard<br>
<input type="checkbox" name="solo" <?php if ($solo==1) { echo
"checked"; }?>> Solo<br>
<input type="checkbox" name="switch" <?php if ($switch==1) { echo
"checked"; }?>> Switch<br>
<input type="checkbox" name="visa" <?php if ($visa==1) { echo
"checked"; }?>> Visa<br>

MySQL database fields ...
delta binary(1) No 0
mastercard binary(1) No 0
solo binary(1) No 0
switch binary(1) No 0
visa binary(1) No 0

When I output the fields, I get "on" or empty, and am wondering whether I am
making a good decision to do the code this way. Now I need to figure out how
to update the database based on the forms output.

Declaring A Checkbox In A Mysql
I have a html form that consists of drop down menus, text boxes and two checkboxs. I can get all the data to be sent to a mysql db via php. But when i try to insert the checkboxes into the db i get an error stating the following:

Could not insert data: 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 ('6','a1','b1','3','c1','1234','1234','1234@1234.com Code:

Entering Mutiple Value With Checkbox Into Mysql
My form only seems to select one value when i may have selected 1 or more values from checkbox.

I want to be able to insert none or all selected from checkbox into mysql database....

Adding Checkbox Input To Mysql Db
how to pass a value from a form with a checkbox on a html page to a mysql database. I've preloaded some data and can populate a box if the data is already present in the db. But I would like to be able to check the box or uncheck the box and pass that value to the db (being able to change the value depending on whether it's checked or not). Code:

Passing A Checkbox Variable To A MySQL Db
Im the webmaster for a boxers website, and rather frequently, the publicist sends me links to articles about the boxer that I need to post. So, I set up a form that allows me to pull the information as needed and post it.

Basically I have it set up to post the Article Title, Article URL, and Article Date, and I call that information from the db. However, on occassion, one of these links will be a press release, and the only thing that changes is that the text Press Release: is added in front of the article title.

I was thinking about creating an extra field in the table called article_pr, and referencing that on the page, and if the row is empty, it would just pull up a space, and if its marked it just pulls up whatever is in there.

However, on the form, I need to have a check box that asks if it is a press release. If so, I would need it to print this in the code Press Release:<br> Is there a way to have the check box indicate whether it will put that code in the db field?

Checkbox Values Stored In Mysql
I have a series of checkboxes and need to store their values in a MySQL
table.

I'm wondering what data type people recommend:

varchar or text, exp. "True/False", "Yes/No"
tinyint, exp. "0/1"

Maybe it depends on the usage or maybe it doesn't matter and/or is a choice
of personal preference.

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?

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:

Mysql Fetch_field Gets Table Alias, Not Real Table Name
After a SQL 'select .... from tablename alias'
the mysql_fetch_field function returns a value $result=>table which
will contain the alias, not the actual table name.
Is there a way to get the actual table name ?

I am running mysql 4.1 and php 4.4

Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'.

There is one of each item in products and each product has it's own unique 'prodno'

There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example:

id = 1
prodid = 7001
qty = 300
price = 12.5

id = 2
prodid = 7001
qty = 400
price = 15.5

I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table.

Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item..

This is all very confusing to me, and I'm the one writing it. Let's try one last time..

Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.

Pesky Checkbox Arrays And A MySQL Song Database
I'm not one who likes to ask for help, so for the last three days my brain has been turning to mush while I try to create a DJ Request Song Wish List. Anyone who can help me out will be saving me from severe insanity. :)

My goal is to:

1. Display search results for song title, artist and genre. (accomplished)
2. Allow the user to add songs to their Wish List. This is done by displaying checkboxes with the corresponding value equal to the songID. (working on it)
3. Allow the user to update their wishlist by adding/deleting songs.

So far I have a form that retrieves the song info from a database in a repeating region. In Dreamweaver:

<input name="songID[]" type="checkbox" id="songID[]" value="<b><?php echo $row_RecordsetSearchResults['Title'];?></b> by <?php echo $row_RecordsetSearchResults['Artist'];?>">

This puts the corresponding songID number into a checkbox value, which in turn is submitted by form POST action to the following page as an array.

To process this array I have:

if(isset($_POST['songID']))
{
$songID = $_POST['songID'];

print '<p>Song IDs:</p>'
// process items
$n = count($songID);
for($i = 0; $i <= $n; $i++)
{
//See if the values are being passed from POST
echo $songID[$i];
echo '<br>'
}
$songsInsert = '*'.implode('*',$_POST['songID']).'<br>'
$insertSQL = sprintf("INSERT INTO wishlist (Username, Title) VALUES (%s, %s)",
GetSQLValueString($MM_Username, "text"),
GetSQLValueString($songsInsert, "text"));

mysql_select_db($database_ToneDeaf, $ToneDeaf);

$Result1 = mysql_query($insertSQL, $ToneDeaf) or die(mysql_error());
}

The problem is, I'm using implode. It does store the songs, but only as one long block of text. So if the user picks "New York by Frank Sinatra" and "Hot In Here by Nelly" it is stored as "*New York by Frank Sinatra*Hot In Here by Nelly*" Obviously this gives me no options to make this actually readable, let alone allow the user to remove one of those songs from their list (both would be have to be removed.)

Also, referencing only the songID number as stored in the music database doesn't seem a good option, since the song database will be changing frequently and song data may be overwritten. Not sure if there's a viable workaround there.

Originally I wanted to store Title, Artist, Genre under seperate columns so I could link them to something like "See more songs from this Artist." However the more I read about arrays and multidimensional arrays, I realize I'm not ready to go there yet. (I just started learning PHP two weeks ago.)

Sending Extracted Array Data From MySQL To Checkbox
I have a list of checkboxes set up as a form that stores the data to a database cell in a comma separated string: For example: "12,13,18,110,118,21,28,31"

Each checkbox has a name of "categories" with different values. What I'd like to do is the following:

1) Extract the data from the database
2) Separate each number it into an individual array value
3) Make the checkboxes in categories.php reflect the selected or non-selected state, based upon the results from the database (selected being the numbers in the database)

Step 1 - I know how to do.
Step 2 - I assume I need to use the explode function, no?
Step 3 - Not a clue.... Code:

Remove " From Data In Mysql
I finally managed to get all the data in from a text file (all the data was enclosed in " marks". I used to use PHP Code:

From CSV To MySQL Table
I've a CSV file with 3 columns

ID - Price1 - Price2

How I would like to update the records of a MySQL tables that has the
same ID of the CSV files.

How Can I do this? Read from CSV and update MySQL table?

Exporting MySQL Table
Hi,

How do you export a MySQL table to a tab-delimited text file so I can put it into excel?

Select From A Mysql Table
I want to pull one field from a mysql table. How do I do that? Do I use SELECT? The field name is $sip_visitornum. And I want the last value that was inputted in to the db. I already have the code to get the visitor number but I don't know how to display data from the database properly. Thanks.

How To Create A MySQL Table With PHP?
How to create a MySQL table with PHP?

Getting Mysql Table Info?
Suppose I have a table with name 'tablename' in my database.

If I have no idea what are the contents of this table, is it still possible to retrieve the structural info in this table, like the field names and sizes?

Get Max Value In MySQL Table Field
I have a 2-field table "pageref".

The fields are: "pagerefno" - which is index and primary key, and "url".

I need to find the max value in "pagerefno", so wrote the following code:

$query ="SELECT max(pagerefno) FROM pageref";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
$row = mysql_fetch_row($result);
echo row[0];

But this results in a blank screen. I'd be grateful for a steer, here.

Search A MySQL Table
I want to create a php script to search a mySQL table. I started to create the script myself, but I got stuck, because the script became VERY complex. The reason why it's complex is this:

*the script must be able to search all four columns of the table.
if the user defines four different values to search (one for each type of variable (ie.: for each column)). If he doesn't give four values but by example only two, the script needs to search on these two values...

*the script needs to return all four values of all the rows that match the query

*the script may not return each result more than one time

*if possible, the script needs to return 'the best match' on top

examples:
consider a table with four columns:
animal_type |age | name | sex
horse | 5 |beauty| female
horse | 4 |bless |male
cat | 9 |***** |female

the query (horse,5,beauty,female) must return
horse | 5 |beauty| female (only one time!!! this sounds logic, but it isn't!!!)

the query(female) must return
horse | 5 |beauty| female
cat | 9 |***** |female

the query (horse, female) must return
1) horse | 5 |beauty| female
2) horse | 4 |bless |male
3) cat | 9 |***** |female
(number 1 must be on top; 2 and 3 may be changed of place, because they only match one variable!!)

Creating Mysql Table
I have PHP script that creates a mysql table. My problem is when I goto the following php page to access the table it says "missing table 'table name'" I look in phpmyadmin and its clearly there. Eventually after refreshing the page like ten times it detects and works. Do I have to reconnect the mysql connection or something?

PHP MySQL Updating Table Row
I have a small database of books that a client can add, search and edit (hopefully) books; all online (something very simple). So far I've been successful in creating the adding of books and searching and retrieving the info in fields to edit; but I haven't been able to execute the edits. Here's the script I have to retrieve the database info and place them in the fields to edit (I didn't copy all the mysql connection script, it works fine): PHP Code:

How To Get A Field In The Last Row Of Mysql Table.
There is a certain field that I wish to get in the last row (it will always be in the last row, even if I add to the table) of my mysql table. How do I output this? I assumed that I would be using a LIMIT command and a DESCRIBE command, however I looked at mysql.com and couldn't find anything .

Table Dump With MySQL
I have recently moved from a host that provided only 1 mySQL db, to a host that allows multiple db's. How do I dump a table, or tables from the single db...into a new db(s)?
I've used this before (to dump the entire db):

mysqldump -h mysite.com -q mysite_dbname > db_dump.sql -pmysitepassword

but I want to extract specific table(s) from the origian db and move them into newly created db's of their own on the new server.

Mysql Empty Table
does anyone know what the mysql comand to empty and table?

MySQL Table Create
Here is the code I'm trying to create the database with (I'm using phpMyAdmin so I just select the file I want to use and press submit and it creates the tables).

CREATE TABLE bips (
banned_ip varchar(15) NOT NULL);

CREATE TABLE messages (
entry_id double(16,4) DEFAULT &#390;.0000' NOT NULL auto_increment,
name varchar(25) NOT NULL,
email varchar(35) NOT NULL,
icq int(11) NOT NULL,
http varchar(50) NOT NULL,
message mediumtext NOT NULL,
when int(12) NOT NULL,
ip varchar(15) NOT NULL,
UNIQUE entry_id (entry_id),
PRIMARY KEY (entry_id));

------------------------
phpMyAdmin gives me an error with that, (none of those tables exists btw)... the error is

MySQL said: You have an error in your SQL syntax near 'when int(12) NOT NULL, ip varchar(15) NOT NULL, UNIQUE entry_id (entry_i' at line 8 .

Getting Mysql Table Size?
How would I go about getting the size of a table in a mysql database with php? I am unable to find info on this in the manual. Which page is it on?

PHP Variables From Mysql Table
I have a PHP script which parces a mySQL table and shows which
sections meet on which day by using an array containing (mon,...Fri)
and another lisitng sections. I then have the PHP do to selecrt
statements on to list those sections that are mixed and those that are
not.

I have a title "Open to Boys and Girls" then it cycles through the
applicable groups. I want to hide this title if there are no group
from the mysql search but can't figure out how as the actual varaible
$result is set once the search is done even if it pulls nothing back

Code is below,

CODE
-------------------------------------------
$result = @mysql_query("SELECT Group_Name FROM `groups` where
".$section."_comment like '%".$day."%' and ".$section."_comment like
'%mixed%'");
echo "<u>Open to Boys & Girls</u></br>";
while($row = mysql_fetch_array( $result )) {
$Group_Name = $row['Group_Name'];
echo "&bull; ".$Group_Name."</br>";
}// end Group Name loop mixed

Creating Table Using PSP And MySQL
Ok, so Ive overcome the first hurdle of connecting to MySQL and MyDatabase on my
web server using PHP scripts. Now I want to create a simple table with 3
fields. Don't have a clue where to start using PHP.

Date Into Mysql Table?
how I can add a date to a mysql table with php? I am wanting to add the date when an article has been entered into the table.

Table Locking In MySQL
As there is no concept of Record locking in MySQL, Table has to be locked. If a Table is locked by one user, what happens to the other user who is accessing the table at that precise moment. Both are trying for a write access. What if the table is locked for more than a stipulated time. How should the script be written so that the other table who does not get write access waits.

Random Row From MySQL Table
I'm using PHP3, does anyone know how I can pull a random row from a mySQL table?

Make A Table In MySQL
How do I make a PHP script that is able to make tables with fields? I want to be able to have a HTML form submit the fields. I just want to know the PHP scriptlet that will make a table.

Create Mysql Table
I'm trying to create a mysql table in php. i have no problems doing a select, insert or anything else. i just don't know what the proper code is to create a table if it even exists.

Deleting From Mysql Table
i'm trying to replace a record in a mysql table but i'm having problems. First i've got a page to store existing film name values using:

<input type="hidden" name="Name" value= "<?printf($row["Name"])?>">

The second page is supposed to delete the existing record by comparing the stored name value with the database name but it only creates a a duplicate record. Here is the code for this: Code:

Mysql Query Table
i got a problem with an multidimensional array out of a sql DB after each table print he should select the next line of $thismember but i don't know how to do. PHP Code:

How To Get Last Insert ID In MYSQL Table
May I know how to retrieve the last inserted ....

Table Limits (MySQL)
I made a database of links. I now have a real long list of links when I list them on a page, I was wondering if there was a way to limit this list within a table. Basically instead of having a long list of 30 links, I would like a table with three columns of ten. Is there any way to do this with PHP and/or MySQL.

Last Line In MYSQL Table
I wrote a news script to post news posts in reverse chronological
order.

I'd like a page to post the last 6 posts from a page, from newest to
oldest.

But as it is, I don't know how to find the number of the last row in
the table. So I have to count down from 100, skipping blank entries
along the way.

Is there a simple way to find what how many rows are in a mysql table?

MySQL, Backup A Table In PHP
Assuming the table MYTABLE, i want to run a script to backup the table.
But there does not seem to be a straight forward function in MySQL to
achieve it,

Something like
COPY TABLE MYTABLE, bkpMYTABLE;

What would be the easiest way to do that using php?

I know that i can create a table bkpMYTABLE and INSERT the data from MYTABLE
to bkpMYTABLE but the problem is that i will be using the script to run
updates so i will not always know the structure of the data that the user is
copying, (because the script(s) will be precisely used to update the
structure of the table).

Maybe there is a function to retrieve the current structure and then copy
the data?

Also is there a way of testing if a table exists? and to test if a field
within that table exists?

Filling MySQL Table From Within PHP
I don't seem to get the following right.

In the following I try to fill a MySQL table named 'mutation'. The first
element is a date but MySQL sees this as 0000-00-00 instead of the
date 2002-11-01. Other problem is the textstring in
$_POST['verklaring1'], in MySQL this stays empty.

<?php
$query = "insert into mutation values (2002-11-01, 1, 4, 1, 4, 10, 330 ,
' $_POST['verklaring1'] ',N,N,N,N)";
mysql_db_query("projects", $query);
?>

Php, Mysql And Update Table
I have one mysql table and I need to update it by form. But what is the best way.
I think First I need atleast following php-files:

list.php --> list all data rows from my table included link to select certain row and
update.php --> ...when selected you will get form view where you can update field
updated.php --> update your database table.

Best Way To Do A Mysql Lookup Table
I have a table full of dictionary words. I want to store them in another database by id.

Creating A MySQL Table
I'm trying to create a table in PHP.  I can use phpmyadmin to do it but I can't create it in PHP.  I even copied the code generated in phpmyadmin and it still didn't work.  Here is the code:

Searching A Table In Mysql
I've searched through these forums about searching and didnt really find anything. All the questions that were asked were unanswered. I searched google and came up with this: http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

except I am not sure if thats what I should be using nor do I understand how to write a query using that. Ill just be searching 1 field in 1 table. Can somone help me with an example query string ? Also I set the field as TEXT since I will just be adding keywords separated by commas into them. Should it be something else?

Move Table (mysql)
how can i move a table from a database to another?


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