-
Insert same text for all in one table
Hi
How can I insert a text (example: Yes) under the field called Approved in a database table of 10,000 records without doing it one by one?
Thanks!
-
Sounds like an update query to me.
I always have to look up the proper formating on the web when I need to do something like this.
This should help get it done.
http://sunsite.mff.cuni.cz/MIRRORS/f...en/UPDATE.html
Google has more answers that may be more relevant than this.
Check out my ebay auction for my signature space on JLC.
Hey if people can sell advertising space on thier bodies, I figure I can make $.02 on my signature space.
-
Hi
I went and check but do not understand as I am still new to database.
Do you know how to write in PHP?
Thanks!
-
Sorry, still reading the PHP books. But we have plenty of php gurus around here that could help you out.
What database are you using I guessed it was mysql.
/edit
maybe this will help
http://www.ku.edu/acs/documentation/...ysql-php.shtml
/edit
Last edited by JamminJoeyB; 06-09-2005 at 11:36 AM.
Check out my ebay auction for my signature space on JLC.
Hey if people can sell advertising space on thier bodies, I figure I can make $.02 on my signature space.
-
Try:
Code:
update <tablename> set Approved = 'Yes'
(This is the SQL statement you have to run from PHP)
Hope this helps.
- Suramya
--------------------------------------------------
My Website: http://www.suramya.com
My Blog: http://www.suramya.com/blog
Registered Linux User #: 309391
--------------------------------------------------
*************************************************
Disclaimer:
Any errors in spelling, tact, or fact are transmission errors.
*************************************************
-
Hi Suramya
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>' ; }
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|