Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Assigning values automatically by PHP
Hello, I have been modifying a MySQL db, and I was trying to reorder
stuff. I ended up adding a "ordre" column to my tables that
I will increment by 5.

Now, I got a huge problem: one of the tables contains more than 200
records! I can't change this by hand, it's gonna be
awfully too long. I had the idea to create a PHP script to to this
for me, type of record by type of record.

Here is te code I came up with:

--------

<?php
include ("include/dbconnect.php");

select = "SELECT * FROM "
.langue. "publilol WHERE type=" . type;
result =
mysql_query(select,db);
total =
mysql_num_rows(result);
if(total)
{
max = (total*5)+10;
i = 1;
while(publication =
mysql_fetch_array(result))
{
query1 = "UPDATE
".langue."publilol SET ordre = ".max."
WHERE identification =
".publication['identification']." AND
url=".publication['url']." AND
type=".publication['type'];
query2 =
mysql_query(query1,db);
max = (max-5);
echo "Done for ".i."
enregistrements";
++i;
}

}

include ("include/dbclose.php");
?>

--------

It does not work... The loop to make the # of records show up works,
but nothing updates.

Thanks for your help,
Bruno M-A, Summer intern at LARIM, Polytechnique, Montreal.



----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums



Report this thread to moderator Post Follow-up to this message
Old Post
tox_yray
08-18-04 08:57 PM


Re: Assigning values automatically by PHP
Anybody out there?



----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums



Report this thread to moderator Post Follow-up to this message
Old Post
tox_yray
08-18-04 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:47 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.