Jump to content

Html

Members
  • Content Count

    595
  • Joined

  • Last visited

Everything posted by Html

  1. And that example of the delete user, that is only for a specific name. How would I know exactly how to remove a user that is id 4, or 5? Based on that example? Get id, I tried this before for the image upload, the first example. The second example looks like it could work since I have user_id and not id # Get passed product id and assign it to a variable. if ( isset( $_GET['id'] ) ) $id = $_GET['id'] ; # Get passed product id and assign it to a variable. if ( isset( $_GET['user_id'] ) ) $user_id = $_GET['user_id'] ;
  2. For the moment, i am just going to keep going on with this with the example files. I think I'll need to start from the beginning for php 7. But I will have a difficult time with this, I don't think just going to start I will somehow get the hang of this, of where exactly would you be suggesting? I want a change password feature and display only the logged in user's posted message forum.php will be a profile index. Of course that will need to be changed to remove only a logged in user's permission to view it, as it would need to be a public page forum.php?=1 or what ever it will look like.
  3. I didn't do with with maths and language, when I was in education. I think I mentioned this before in a previous topic. So there is a repeating pattern. There have been many people who have tried php and mysql, and never got far with it. I have managed to stick with it, even though I am all over the place with this.
  4. I thought you'd eventually see what I am seeing, you are partly correct, I chase after specific examples to get what I need, I can't go from A-Z. Sure I found a few examples on different sites on sunday, and I tinkered with it. And it worked, if I had done this six months ago, I wouldn't of been here, at least not yet.๐Ÿ™„
  5. DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste'; This? That isn't an id as such, id would be like 2, 3.
  6. Hmm, okay. What about the mysql code that is needed for a specific id? What I have there is for only a column? Not an actual user which is logged in. In the W3schools, there is no example section on that?
  7. Okay here is the example code as is, So the sql line isn't enough to change to get the logged in user's messages to display only on the forum.php so that is a profile page. It isn't public since it requires only logged in use to view that forum, but it is close enough for now. forum.php?=1 or something, profile.php? <?php # DISPLAY COMPLETE FORUM PAGE. # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # Set page title and display header section. $page_title = 'Forum' ; include ( 'includes/header.html' ) ; # Open database connection. require ( '../connect_db.php' ) ; # Display body section, retrieving from 'forum' database table. $q = "SELECT * FROM forum" ; $r = mysqli_query( $dbc, $q ) ; if ( mysqli_num_rows( $r ) > 0 ) { echo '<table><tr><th>Posted By</th><th>Subject</th><th id="msg">Message</th></tr>'; while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td> <td>' . $row['subject'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } # Create navigation links. echo '<p><a href="post.php">Post Message</a> | <a href="shop.php">Shop</a> | <a href="home.php">Home</a> | <a href="goodbye.php">Logout</a></p>' ; # Close database connection. mysqli_close( $dbc ) ; # Display footer section. include ( 'includes/footer.html' ) ; ?>
  8. So the example code is meaningless if edit a snippet of it, because I don't full understand anything about php? That example code is functioning in the user site I have setup. The whole thing was loaded in and bang, done, I've only tried to edit and add to it. Obviously I can't get the function working, so I'm now looking back at trying to display the message from the logged in user on it's own. Just where are the syntax errors, this is the complete code?
  9. Are you referring to $user_id being in black, instead of green like the others. Is it to with the "." and so on? That is all I have changed, just so you know this is exact copy from the source files. $q = "SELECT * FROM forum WHERE id="$user_id" ; It will need a where, as forum alone only displays all messages, so WHERE clause will be needed for the current logged in user viewing the forum.php quite obvious. forum.php is the profile index for any logged in user.
  10. I sent an email to a user on the youtube site who produces tutorials, see what that person has to state about the code. I am not sure what I am going to do if I can get this code working. I also want to have a post message to the profile index, still haven't got that working yet, change password, upload an image to the user profile. And remove data is one of them, as well a directory of new users created, and an inbox and outbox system, and that would be it. So far it is only register, and login using the example code, and using the example code forum. I tried to modify that to display on the logged in user's message. Instead of just all of them who ever posts to a public forum/display message page. <?php # DISPLAY COMPLETE FORUM PAGE. # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # Set page title and display header section. $page_title = 'Forum' ; include ( 'includes/header.html' ) ; # Open database connection. require ( 'connect_db.php' ) ; # Display body section, retrieving from 'forum' database table. $q = "SELECT * FROM forum WHERE id="$user_id" ; $r = mysqli_query( $dbc, $q ) ; if ( mysqli_num_rows( $r ) > 0 ) { echo '<table><tr><th>Posted By</th><th>Subject</th><th id="msg">Message</th></tr>'; while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td> <td>' . $row['subject'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } # Create navigation links. echo '<p><a href="post.php">Post Message</a> | <a href="shop.php">Shop</a> | <a href="home.php">Home</a> | <a href="goodbye.php">Logout</a></p>' ; # Close database connection. mysqli_close( $dbc ) ; # Display footer section. include ( 'includes/footer.html' ) ; ?> I haven't a clue if that alone would do this, it can't be that difficult compared to a function delete.๐Ÿค”
  11. I'm no where near there then, besides that is PDO or what ever, I am using php 5. Considering php & Mysql was published in 2012. That code is more useful for if I attempt to learn php 7 from scratch.
  12. Result mode, so now there is more than one mysqli_query to be used, This is certainly new to me.๐Ÿคจ Yeah. Now what.๐Ÿ˜•
  13. <?php # Access session. session_start() ; # Connect to the database. require ('connect_db.php') ; { deleterecord(); // call the function function deleteRecord( $dbc, $q, $r , $user_id) $q = 'DELETE * FROM users WHERE id' = '$user_id'; $r = mysqli_query( $dbc , $q, $user_id ) ; } # Close database connection. mysqli_close( $dbc ) ; ?> Okay, I am probably not going anywhere with this.
  14. I wonder whos head that will be.๐Ÿ˜•
  15. I don't know why I am not using user_id, I haven't a clue. <?php # Access session. session_start() ; # Connect to the database. require ('connect_db.php') ; { deleterecord(); // call the function } function deleteRecord( $dbc, $q, $r ) { $q = 'DELETE * FROM users WHERE id = $user_id'; $r = mysqli_query( $dbc , $q ) ; } # Close database connection. mysqli_close( $dbc ) ; ?>
  16. ๐Ÿ˜‘ Yeah sure is. <?php # Access session. session_start() ; # Connect to the database. require ('connect_db.php') ; deleterecord(); // call the function function deleteRecord( $dbc, $q, $r ) { $q = 'DELETE * FROM users WHERE id = $user_id'; $r = mysqli_query( $dbc , $q ) ; } # Close database connection. mysqli_close( $dbc ) ; ?>
  17. { deleterecord(); // call the function function deleteRecord( $dbc, $q, $r ) $q = "DELETE * FROM users WHERE id = '$user_id'" ; $r = mysqli_query( $dbc , $q ) ; }
  18. Right, This is a function from the Php & Mysql code example. <?php # Create a global variable. $result = 5 + 5 ; function square() { $result = 5 * 5 ; echo "Local Square Result = $result<br>" ; } function cube() { $result = 5 * 5 * 5 ; echo "Local Cube Result = $result<br>" ; } echo "Global Sum Result = $result<br>" ; square(); cube(); ?>
  19. Ineasysteps has a website, but have no customer support, but a person can send recommendations, so that was what I did end of last month, I sent the code here, and hopefully the work was mostly done, even though it didn't make much sense. I tried the book, it is too much in it. I looked back at php 7 book from ineasysteps on functions, I then looked back at the w3schools example, so I'm confused on all of it. One example states this, and then another. <?php # Access session. session_start() ; # Connect to the database. require ('connect_db.php') ; { deleterecord(); // call the function function deleteRecord( $dbc, $q, $r ) $q = 'DELETE * FROM users WHERE id = $user_id'; $r = mysqli_query( $dbc , $q ) ; } # Close database connection. mysqli_close( $dbc ) ; ?> Updated this, no rows. W3 schools first example write message, so I wasn't sure what is where.
  20. Perhaps, the book is pretty basic, the one I have, ineasysteps is the name, it doesn't really give a solid understanding of php. Cheaper books won't be that in depth. <?php # Access session. session_start() ; # Connect to the database. require ('connect_db.php') ; function deleteRecord( $dbc ) { $q = 'DELETE * FROM users WHERE id = $user_id'; $r = mysqli_query( $dbc , $q ) ; $num = mysqli_num_rows( $r ) ; if ( $num > 0 )' } deleterecord(); // call the function # Close database connection. mysqli_close( $dbc ) ; ?> if ( $num > 0 )' <?php # Access session. session_start() ; # Connect to the database. require ('connect_db.php') ; function deleteRecord( $dbc ) { $q = 'DELETE * FROM users WHERE id = $user_id'; $r = mysqli_query( $dbc , $q ) ; $num = mysqli_num_rows( $r ) ; if ( $num > 0 ) deleterecord(); // call the function } # Close database connection. mysqli_close( $dbc ) ; ?> No problem with this in php checker. <?php # Access session. session_start() ; # Connect to the database. require ('connect_db.php') ; function deleteRecord( $dbc, $q, $r ) { $q = 'DELETE * FROM users WHERE id = $user_id'; $r = mysqli_query( $dbc , $q ) ; $num = mysqli_num_rows( $r ) ; if ( $num > 0 ) deleterecord(); // call the function } # Close database connection. mysqli_close( $dbc ) ; ?>
  21. Yeah, i guess, and sure I thought about that in the past, but I just felt I had to keep going with this example code to try and get what I wanted working. Like I stated, I emailed the company who published the book, and they didn't respond to trying to make sense of my example code. Not sure what is going on there, could be that the book is too old for anyone there to want to add a tutorial on removing data. Seems obvious to include that with a user site login, I am sure everybody here thinks that is a must. <?php # Access session. session_start() ; # Connect to the database. require ('connect_db.php') ; function deleteRecord( $dbc ) { $q = 'DELETE * FROM users' WHERE id = '$user_id'; $r = mysqli_query( $dbc , $q ) ; $num = mysqli_num_rows( $r ) ; if ( $num > 0 ) } deleterecord(); // call the function # Close database connection. mysqli_close( $dbc ) ; ?> I don't know.
  22. Unfortunately, I was like with this python and visual basic. Your post reminds me of when I had tried to this, I seem to switch off on the learning curve. I did try the php 7 book by ineasysteps, it wasn't all that, just code really that works, very basic explanation. The book you suggested is much more thick with explanation, but I couldn't quite get it.
  23. There is a lot there on the functions. The first one seems pretty basic, and useless the rest go onto something else. I thought the SQL line was correct? So now it isn't. ๐Ÿ™„ So what, there is no longer the use for WHERE?
  24. Well, I got my source from the youtube site, no where else. One video shows one example, and then another. So I just tried what there was. So what is the step to get the function going then?
  25. The last two no. The first and second, The first is the sql line the variable is instructed to remove the logged in user from the id column. And the second line is the database connection and the variable part of the mysqli function. Not sure what else.
×
×
  • Create New...