Jump to content

Sigmahokies

Members
  • Posts

    89
  • Joined

  • Last visited

Recent Profile Visitors

4,209 profile views

Sigmahokies's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Never mind! I found a solution! I used wrong method. Now, I corrected method, Now, it won't go to sub number anymore. If you want to see my solution, let me know, I can put in those code in next reply.
  2. No, that is not what I mean. I mean if there is 0 in field, do nothing. if more than 0, do something. I tried to put null, but it doesn't work. I need something method that do nothing to prevent message error in browser, because I put unsigned in field in the database. I put do something after else because it's not 0 in field. for example, In switch system, this method "break;" can stop the function. Now, I need something method to stop function when it comes to 0.
  3. Hi everyone, I'm trying to stop the programming to subtract more that will go to below from 0, I set up the unsigned in phpmyadmin, but it went sentence error if it come to -1 or below. I mean, if start with 3 or 4, then subtract by 1, till reach 0, then stop, I need something that can ignore program to subtract if it reach 0. for example: $sql = $GaryDB->prepare("SELECT howMany from bracelets"); $check = $sql->execute; if($check->rowCount() == 0) { No program in this function } else { do program } Get it? How you do that?
  4. There is a reference in url already. I set up the loop in link like this: bracelets.php?=bracelets earrings.php?=earrings kids.php?=kids necklaces.php?=necklaces rings.php?=rings then There is file name already - bracelets.php, earrings.php, kids.php, necklaces.php, and rings.php. So, $_GET should grab reference key from those string in URL, but it didn't. I think $_GET doesn't grab when it come with array. I used implode to convert array to string, but still not work.
  5. Hi everyone, I don't know why $_GET didn't get string from URL from another page. can you help? here my code: First page: <?php require("connection.php"); error_reporting(E_ALL); $sql = $GaryDB->prepare("SHOW TABLES"); $list = ""; $list2 = ""; $sql->execute(); while ($row = $sql->fetch()) { $list .= "<a href='$row[0].php?=$row[0]'>".$row[0]."</a><br />"; } ?> <!DOCTYPE HTML> <html lang="en"> <head> <title>Pinky's</title> <link href="paparazzi.png" rel="icon"> <style> * { font-family: Helvetica; text-decoration: none; } body { margin-left: 300px; margin-top: 100px; margin-right: 300px; } </style> </head> <body> <table> <tr><td>Please Select</td><td></td></tr> <tr><td><?php echo $list ?></td></tr> </table> </body> </html> link at left-bottom show localhost:8888/Braclets.php?=Braclet Then why can't $_GET get this strong "Bracelets"? next page: <?php require("connection.php"); $kids = $_GET['Kids']; echo $kids; $sql = $GaryDB->prepare("SELECT * FROM $kids"); echo $sql; ?>
  6. Yeah, ID exists, I put rowCount(), it said it is not successful. I don't see any error reporting...
  7. Yes, Select is successful. I tested it by echo quote SELECT before go to form. Problem is it won't get in database as updated. I should checked step by one, like update one, then next two, then next three...I'm trying to get used with PDO instead of mysqli because it's getting old. I can tell PDO is more easier than mysqli.
  8. Niche, There is no error show, even I put the error: $updatesql->execute() or die(print_r($updatesql->errorInfo(), true)); Still no show error. This method didn't update into database (Phpmyadmin)...
  9. Hello everyone I tried to create update site with PDO method, but not success. Can you help? I followed what instruct from w3school, but none of them are work. <?php include("connection.php"); if($_GET['update']) { $data = $_GET['update']; $prepare = "SELECT * FROM Members WHERE ID = $data"; $sql = $GaryDB->prepare($prepare); $sql->execute(); if($row = $sql->fetch()) { $form = "<tr><td>ID</td><td><input type='text' name='updated1' value='".$row['ID']."' readonly></td></tr> <tr><td>First Name:</td><td><input type='text' name='updated2' value='".$row['FirstName']."'></td></tr> <tr><td>Last name:</td><td><input type='text' name='updated3' value='".$row['LastName']."'></td></tr> <tr><td>Address:</td><td><input type='text' name='updated4' value='".$row['Address']."'></td></tr> <tr><td>State:</td><td><input type='text' name='updated5' value='".$row['State']."'></td></tr> <tr><td>Zip:</td><td><input type='text' name='updated6' value='".$row['Zip']."'></td></tr> <tr><td colspan='2' style='text-align: center'><input type='submit' name='submit' value='UPDATE'></td></tr>"; } } else { $form = "<tr><td>No ID in URL</td></tr>"; } if(isset($_POST['submit'])) { $id = $_POST['update1']; $first = $_POST['update2']; $last = $_POST['update3']; $address = $_POST['update4']; $state = $_POST['update5']; $zip = $_POST['update6']; $updatesql = $GaryDB->prepare("UPDATE Members SET FirstName = :first, LastName = :last, Address = :address, State = :state, Zip = :zip WHERE ID = :id"); $updatesql->bindParam(':id', $id, PDO::PARAM_INT); $updatesql->bindParam(':first', $first, PDO::PARAM_STR); $updatesql->bindParam(':last', $last, PDO::PARAM_STR); $updatesql->bindParam(':address', $address, PDO::PARAM_STR); $updatesql->bindParam(':state', $state, PDO::PARAM_STR); $updatesql->bindParam(':zip', $zip, PDO::PARAM_STR); $updatesql->execute(); if($updatesql->rowCount()) { $success = "<script>alert('success update')</script>"; } else { $success = "<script>alert('Not success update')</script>"; } } ?> <!DOCTYPE HTML> <html> <head> <title>Update site</title> <link href="red-sigma.png" rel="icon"> <link href="default.css" rel="stylesheet" type="text/css"> </head> <body> <a href='demonstration.php'>return to demonstration</a><br /> <h2>Welcome to Gary Taylor's Demonstration in update in database</h2> <?php echo $data ?> <?php echo $id, $first, $last, $address, $state, $zip; ?> <form action="update.php" method="post"> <table> <?php echo $form ?> <?php echo $success ?> </table> </form> </body> </html>
  10. Hi dsonesuk, I tried that, it won't work. I used session to save first call name from html to post, so i can use session string in second block in php to insert string in SQL syntax. I know it's not properly to do that, do you know how to save string for second block in php? It's about user pick table, then pick column in table that user picked. Like this: User pick name of table, then move this string word to SQL syntax, then user pick name of column, then move this strong to SQL syntax. Like - SELECT (picked name of column by user) FROM (picked name of table by user). Plus, how can you post as code form in this thread? I mean, screen of gray and courier font on display Thank you
  11. In HTML <table> <tr><td colspan="2">Sample of SELECT in column's name in table.</td></tr> <tr><td>SELECT <select name="col[]"> <?php echo $list ?> </select> FROM <?php echo $table2 ?></td><td><input type="submit" value="selected"></td></tr> </table> in PHP if (isset ($_POST['col'])) { $col = $_POST['col'][0]; $table3 = $_POST['col'][1]; $selsql = "SELECT $col FROM $table3"; /*$colquery = $GaryDB->query($selsql); while ($row2 = $colquery->fetch()) { $list2 .= "<tr><td>" . $row2[0] . "</td></tr>"; }*/ output: SELECT Name FROM (blank)
  12. No, add two dot before and after table2 is not solution. SQL syntax will not work. my original shows without dot is working. my point is name in select in html did not take two of them, just one took in.
  13. I said show tables work fine. my point is inside html, name in select didn't take TWO names. I set up array to take two. Like this: in HTML - <select name="col[]"> in PHP - $col = $_POST['col'][0]; $table3 = $_POST['col'][1]; so, it didn't take name col to second array to post, get it?
  14. I wish I can show you by record screen, but this forum limit to 500 KB
  15. I did that, show tables is work. it's what not work is name in html did not take two array to post, to send to SQL syntax. It took one name from, not two. my echo shows : Welcome to Gary Taylor's demonstration in PHP page. SELECT FirstName FROM Please select table: Memberscityuser_details Sample of SELECT in column's name in table. SELECT FROM SELECT FirstName FROM Look at "Select FirstName FROM" that's where table name is missing
×
×
  • Create New...