LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-09-2005, 10:09 AM   #1
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Rep: Reputation: 15
How to insert same text in one field for 10,000 records table


Hi

How can I insert a text (example: Yes) to the field (Approved) in a database table with 5 fields of 10,000 records instead of add one at a time?

Example:

Name Address Email Contact Numbers Approved
Edward 1111 1@1.com 11111111 No
Peter 1111 2@2.com 11111111 No


Thanks!
 
Old 06-09-2005, 10:26 AM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
what type of database is it?
 
Old 06-09-2005, 11:14 AM   #3
trevelluk
Member
 
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388

Rep: Reputation: 32
In most databases, you should be able to run a query something like the following, to set the Approved field to Yes for every record in tablename.

Code:
UPDATE tablename SET Approved = 'Yes';
 
Old 06-09-2005, 09:24 PM   #4
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Original Poster
Rep: Reputation: 15
Hi trevelluk

Thank you for code. Now I have another question. Someone has helped me with this php code for displaying 20 rows per page. If I want to edit a particular info like email or name in that page, how do I add the code for this listing so I can edit? If possible, can you show me the modified version. Thanks.

PHP Code:
<?php
  
include("config.php");
  
# new line to config or define in script
  
$limitvalue 20# max of 20 items per page
  #
  
print "<p class=head align=center>Listing</p>\n";
  
$dbConnect mysql_pconnect(null,$dbUserName ,$dbPassword);

  
$INFO['sql_db'] = "admin";
  
$INFO['sql_host'] = "localhost";

  
mysql_select_db($INFO['sql_db']) or die("Could not select database");

  
# get var from url
  
if (isset($_GET['page'])) {
      
$p $_GET['page'];
  } else {
      
$p 1# if no var in url show page 1
  
}
  
$startrow = ($p-1)*$limitvalue+1;
  
$query "SELECT * FROM Members WHERE Approved = 'No' And 1 ORDER BY 'UserID' DESC LIMIT $startrow$limitvalue";
  
$result mysql_query($query) or die('Error '.mysql_errno().' in query: <br />'.mysql_error().'<br />');

  while (
$row mysql_fetch_array($result)) {
      
$name $row['Fullname'];
      
$surname $row['Surname'];
      
$email $row['Email'];
      
$approved $row['Approved'];
      echo (
"
          <table width='95%' align='center'>
          <tr>
          <td class='outline' valign='top' style='padding-left:5px;'>
          <b>Full Name:</b> 
$surname $name<br />
          <b>Email:</b> 
$email<br />
          <b>Approved:</b> 
$approved<br />
          </td>
          </tr>
          </table>
          <br /> "
);
  }
$q mysql_query("select COUNT(UserID) AS t from Members");
$r mysql_fetch_assoc($q);
if (
$startrow $limitvalue $r['t']) {
//  if ($startrow + $limitvalue < mysql_num_rows($result)) { # if last showed value is not the last one show the link
$p++;
echo 
'<a href="'.$_SERVER['PHP_SELF'].'?page='.$p.'">Next page</a>' ;  }
  
?>
 
Old 06-11-2005, 10:41 AM   #5
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Original Poster
Rep: Reputation: 15
Hi

Is it possible to include editing while showing a list of 20 records? Or do I need to write another php to do the editing?

Thanks!
 
Old 06-13-2005, 03:30 AM   #6
trevelluk
Member
 
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388

Rep: Reputation: 32
(sorry for delay in responding)

PHP isn't really one of my strong points to be honest, so I can't really help you with this. Sorry.
 
Old 06-13-2005, 03:48 AM   #7
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Original Poster
Rep: Reputation: 15
Hi

It is okay as I am just as new as you with PHP and MySQL.

Anyone else out there has an idea how I can include the EDIT feature beside individual listing of 20 records to update?

Thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
caps sensitivity in mysql table/field name Swakoo Linux - General 0 11-14-2005 01:16 AM
text based system monitor - $1,000 reward!! fatrandy13 Linux - Software 6 05-07-2005 08:28 PM
Mysql - Howto insert 'admin' account into table ??? b:z Linux - General 6 03-29-2005 03:44 AM
delete records on table vickr1z Linux - Newbie 1 11-25-2004 05:27 AM
1,000,000,000 PCs by 2010 masand Linux - News 4 11-01-2004 01:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration