|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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:
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
||||
|
||||
|
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. |
|
#4
|
||||
|
||||
|
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)
|
|
#5
|
||||
|
||||
|
There doesn't seem to be a point to, or need for rownum.
Use a date field or something like that to do ordering. |
|
#6
|
||||
|
||||
|
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
|
|
#7
|
||||
|
||||
|
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.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > A PHP and MySQL problem I am not sure of how to solve |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|