-   Linux - Newbie (
-   -   How to insert same text in one field for 10,000 records table (

edhan 06-09-2005 11:09 AM

How to insert same text in one field for 10,000 records table

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?


Name Address Email Contact Numbers Approved
Edward 1111 11111111 No
Peter 1111 11111111 No


DrOzz 06-09-2005 11:26 AM

what type of database is it?

trevelluk 06-09-2005 12:14 PM

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.


UPDATE tablename SET Approved = 'Yes';

edhan 06-09-2005 10:24 PM

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:

# 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'>
          <td class='outline' valign='top' style='padding-left:5px;'>
          <b>Full Name:</b> 
$surname $name<br />
$email<br />
$approved<br />
          <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
'<a href="'.$_SERVER['PHP_SELF'].'?page='.$p.'">Next page</a>' ;  }

edhan 06-11-2005 11:41 AM


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?


trevelluk 06-13-2005 04:30 AM

(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.

edhan 06-13-2005 04:48 AM


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?


All times are GMT -5. The time now is 02:54 AM.