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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-09-2005, 10:09 AM
|
#1
|
Member
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93
Rep:
|
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!
|
|
|
06-09-2005, 10:26 AM
|
#2
|
Senior Member
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185
Rep:
|
what type of database is it?
|
|
|
06-09-2005, 11:14 AM
|
#3
|
Member
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388
Rep:
|
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';
|
|
|
06-09-2005, 09:24 PM
|
#4
|
Member
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93
Original Poster
Rep:
|
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>' ; }
?>
|
|
|
06-11-2005, 10:41 AM
|
#5
|
Member
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93
Original Poster
Rep:
|
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!
|
|
|
06-13-2005, 03:30 AM
|
#6
|
Member
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388
Rep:
|
(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.
|
|
|
06-13-2005, 03:48 AM
|
#7
|
Member
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93
Original Poster
Rep:
|
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!
|
|
|
All times are GMT -5. The time now is 10:58 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|