SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 28th, 2003, 01:16 AM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
A PHP and MySQL problem I am not sure of how to solve

On my news system there is a way for administrators to delete articles. However when I delete one of my test articles it causes me problems. It won't show articles past the first couple on any of the pages that look at the news.

Now i know what the problem is. On my table i have two numeric columns. One called id which is an auto increment and one called rownum. I know this might be overkill but it was the original solution to this problem. However I now found it is not working as well as I thought.

Now when I add an article I have it query the table to find the highest rownumber I then add 1 to it for the insert operation
PHP Code:
 $newsquery=mysql_query('select*from news order by rownum DESC");
$news=mysql_fetch_Array($newsquery);
$numrow=$news['
rownum'];
$numrow++;
mysql_query("insert into news (rownum) values $numrow"); 


Now if I delete row 5 of the 10 rows in my table when I query it later it will stop querying where the deleted row was (or go on some infinite loop). What is the best way for me to update the other rows with a new row number (or id) when I delete one row
__________________
CHornJr
"One day I'll know what I am doing"
My Blog
Suanhacky Lodge #49
Rebel Squadrons

Reply With Quote
  #2  
Old June 28th, 2003, 10:51 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
I'm still not understanding why you have id and rownum.
Show a desc of your table.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old June 28th, 2003, 01:47 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Originally the table had a column for id(auto_increment), type of news, date posted(timestamp(10)), news title and the article body. When I did the script to delete articles I just deleted the newest article. For instance let's say I deleted article #10. When I added another article It numbered it #11 instead of 10. S to overcome this problem I created another coumn called rownum and set the script that adds the new articles to find the highest number of of rows,a dd 1 to it and insert it into that column.

After getting my edit news script workign properly the other day I went throught o fix up the delete script cause it had similar problems ot the edit script with pulling out the right types of articles. When I tested it I deleted one of the articles in the middle.

And now that I typed this whole thing I think I have an idea on how to fix the script to solve my problem and I will post if it works or not. Gonna go ty it out now.

Reply With Quote
  #4  
Old June 28th, 2003, 01:55 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Well my iea didn't work. It gave me the same problem. It stopped when there was a void in the id (ie. 33, 32, then the next id is 30)

Reply With Quote
  #5  
Old June 28th, 2003, 09:15 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
There doesn't seem to be a point to, or need for rownum.
Use a date field or something like that to do ordering.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #6  
Old June 29th, 2003, 01:22 AM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
when doing the orderby function isn't the problem. It is displaying the news. How do I get it to go to the next row in the table. I can't go $date-- cause one date could be today and the next one is from two weeks ago. That's the problem

Reply With Quote
  #7  
Old June 29th, 2003, 09:15 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Are you not familiar with recordsets and looping? Unless i'm missing something, it sounds like you might need to brush up on a few of the basics of handling database records.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > A PHP and MySQL problem I am not sure of how to solve


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway