Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. I may be having a bad day but 'mysqli_fetch_array' fetches ONE row of data stored in array format. No? Where is the 2nd row coming from to complete the first table row? The OP's original logic is clearly flawed and my comments should help him see that, as well as give him a method to get two rows of data in each pass thru his loop.
  2. ginerjm

    multi query

    1 - Stop using MySQL_* functions. They are soon to be defunct. Check the manual for proof and then research mysqlI or PDO for your db acitviity. 2 - You have a delele query already. Only problem is you need to sanitize your input argument to be sure it is valid and does not contain any malicious data in it. Or - when you switch to PDO (my preference) use a prepared query statement instead. 3 - How are you going to get the data from the deleted record to insert into the other table? Personally, I would do a query to read the 'old' record, insert that data into the new table, and then go back and do the delete of the old record. (Of course there is probably a cleaner more efficient way to accomplish this but since I've never had to do this, I haven't researched this.)
  3. Add some echoes to see where you logic is actually taking you to debug this.
  4. ?? Pravins solution utilizes an array. Of course he doesn't give the OP any guidance on creating an array that fits his situation, but yes, it can easily be done. My solution simply uses what is at hand and avoids that.
  5. My solution works without loading an array and was addressed to the OP, not PravinS
  6. You need to fetch a second row in the middle of your loop. Currently you create a row, insert a td element and 3 values from the first row. After that you need to do another fetch (while still inside your loop) and insert a 2nd td and the fields from the new row, THEN end that row and let the loop repeat. Of course if the second fetch fails (you need to check that), you need to output an empty td element and still close the row. After the loop you close the table (you only need one table element)
  7. Sorry - but since I don't understand what "shorten links" means at all, and since your code doesn't help me to understand, I can't offer any help.
  8. Yes you do - so why did you state just the opposite in your item #1? Writing chunks of html code and populating it with php vars is the way to go. Leave the php logic out of the end result. Your ex. of the two syntaxes is meaningless since you can achieve the same outcome in either syntax without an echo. It's just that the alt. syntax is so rarely seen and therefore rarely used. Of course it may have had more usage years ago - I wasn't around then. But again - your example is a poor one if you truly intend to separate your php code and html code. It sounds like your attempt to pre-plan your standards for your upcoming large project may be poorly thought out. Without significant experience in writing some heavy duty code you will surely end up making mistakes and using unsound practices. Not a criticism - merely preparing you for the day you look thru your efforts and (with increased awareness) discover that you didn't fully understand things back then. If this large project is something you are doing on your own, I suggest that you continue to grow on some smaller stuff first. Having only been using php for a little over 3 years I marvel at some of my earliest scripts (just simple single modules) and the way I wrote things back then. Whatever was I thinking??
  9. Sorry - I don't click on posted links. If you can't show the code, oh well.....
  10. 'shorten links' ? That means less to me than shrinking links. What are you talking about? An apache re-write rule perhaps?
  11. You can't embed php code inside a js function. You need to let your js function return true/false to your submit button and that will determine if your submit calls the php script that will do the update <input name = "btn_seatOccupied" type = "submit" class="btnFORM" value="CONFIRM" onClick="return seatOccupied()" action='postdata.php'> Note the addition of 'return' - this will either submit the form and call the script to do the update for you. Or not.
  12. "shrinking links" ? What be they?
  13. I have problems with this statement: I am looking to use the alternative syntax for control structures as to make the php code inside my html readable and easier to manage but in terms of OOP when is it best for me to use classes vs functions? a) you should not be considering how your php code looks inside your html code. It should not even Be There!! b) and whatever does 'alternative syntax' have to do with design considerations? IMHO - using the alternative syntax is a surefire method of confusing the next person who looks at this code. What's wrong with the 'recommended' or 'non-alternative' syntax? Why do you want to use the one that few use? (Isn't that why it's called alternative?)
  14. Your last post is just fine. If you the file does not exist where you think it should be, you'd get an error message from your browser. Period. Unless you have some kind of apache re-write rule in place(?). More likely is that this exact piece of code is NOT what you are executing on your client. Display the source of your web page before clicking the link and ensure it is the current file.
  15. Does this script belong to a CMS package?
  16. 1 - you say you're familiar with css - why don't you build a css file and include THAT so you don't have ALL THAT MESS of CSS in your html? 2 - you say over and over how your includes aren't working yet the code you posted does not have a single include (or require) in it. How are we supposed to help you?
  17. Let's see. You have a head tag, then you include some code, then you call a function from that include which re-issues a head tag, close the head, and then you issue a second end head tag. AND you open and close your html inside of the header section. I would think that any browser would have a huge problem handling this mess. BTW - why a function? You're including static html code - why make it a php function?
  18. Can you show us this call? That would be so much easier to debug than taking a flying leap at whatever you are talking about.
  19. You may be trying to avoid some work here in order to make this necessary change, but you eventually will have to do a whole lot of work to Stop using the deprecated MySQL_* functions and move to mysqlI or pdo.
  20. Cronix - Not familiar with array_fill_keys() nor range() but after reading the manual I think there is a flaw in this. Your range will produce a set of values ending with whatever is the highest EXISTING key in the array. Then array_fill_keys assigns a 0 value to all of the indices in the range set. What about the days that were not in the original array higher than the existing max day?
  21. for ($I = 1; $I < $lastday; $I++) if (array_key_exists($I,$ar)) echo "$I is $ar[$I] <br>"; else echo "$I is 0<br>";
  22. your code is impossible to read. What did you do? Did you even look at your post to see it?
  23. Why not follow the instructions you have been given? Use phpadmin (?) and create the db and then create the tables your instructor says you need?
  24. People Have been very specific. From the get-go! OP - Run one query at a time to make sure you are doing it right. Simple as that! When you are confident in your skills, take the next step and run multiples. Simple as that. From the sidelines I've seen everyone say the same stuff and you are not listening at all!
  25. May I ask how a proposed php login is going to secure your "game"? Is this game written in php and did you write it? If not php, how will a php login interface with it? And if it is php, how will you write the code to ensure the user did in fact login.?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.