Jump to content

pocobueno1388

Members
  • Posts

    3,369
  • Joined

  • Last visited

    Never

Everything posted by pocobueno1388

  1. It's because your using a timestamp. Change the "timeout" field type to datetime. Then when you do your query, just use the NOW() function. UPDATE members SET timeout = NOW() WHERE username = '" . $_SESSION['myusername'] . "'
  2. I think $_POST is case sensitive, and you have it as $_Post. Change switch($_Post['train']) To switch($_POST['train'])
  3. Take out the NULL. If you don't specify a field, it will enter a null automatically. So try this instead $sql = "INSERT INTO i_usr (usrname, usrpass, usremail, usrhandle) VALUES ('$username, '$password, '$email', '$handle')";
  4. This should help you http://www.tizag.com/phpT/postget.php
  5. Before you do the update, just do a select query that has the same WHERE clause as the update query.
  6. You just want to display everything from the "option" field? It's as simple as this: <?php $query = mysql_query("SELECT option FROM table")or die(mysql_error()); while ($row = mysql_fetch_assoc($query)){ echo $row['option'] .'<br />'; } ?>
  7. Just search google for "javascript image gallery", I'm sure you will come up with plenty for what your looking for.
  8. Nope, unless you want to use an Iframe, which technically uses a page refresh.
  9. If you want it to happen without a page refresh your going to have to look into a client side language, such as JavaScript.
  10. So does that answer all your questions?
  11. <?php $text = "Blah blah blah"; //add something to end $text .= " something else"; echo $text; ?>
  12. Give this a try <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>University</title> </head> <body> <p> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php //check if they pressed delete button if (isset($_POST['submit'])){ //make sure they checked something if (!empty($_POST['delete'])){ //execute delete query $query = "DELETE FROM table WHERE id IN(" .implode(', ', {$_POST['delete']}) . ")"; if ($result = mysql_query($query)) echo "Successfully Deleted"; else echo mysql_error(); } else { echo "Nothing Selected to Delete"; } } if(!$name && !$sfield && !$sroll) { echo "Please Enter NAME or FIELD or ROLL NUMBER"; } $db = mysql_connect("localhost"); mysql_select_db("university",$db); if($name) { echo "<h1>Searched By Name:</h1>"; $query = "select * from nu where name like '%".$name."%'"; echo "<table width = '100%' border = '0'"; echo "<tr bgcolor = 'lightblue'><td><P><B>Select</p></B></td> <td><p>Roll No</p></td> <td><p>Name</p></td> <td><p>Father Name</p></td> <td><p>phone No</p></td> <td><p>Address</p></td> <td><p>Field</p></td>"; while($record = mysql_fetch_assoc($result)) { //Where it says $record['unique_id'], you need to change that to whatever the unique ID for the table your deleting from is echo "<tr> <td width= 84><input name='delete[]' type='checkbox' id='delete' value='{$record['unique_id']}'></td> <td width = 350><p>".$record["rollNo"]."</p></td> <td><p>".$record["name"]."</p></td> <td><p>".$record["fatherName"]."</p></td> <td><p>".$record["phoneNo"]."</p></td> <td><p>".$record["address"]."</p></td> <td><p>".$record["field"]."</p></td>"; } } if($sfield) { echo "<h1>Searched By Field:</h1>"; $query = "select * from nu where field like '%".$sfield."%'"; $result = mysql_query($query); echo "<table width = '100%' border = '0'"; echo "<tr bgcolor = 'lightblue'><td><P><B>Select</p></B></td> <td><p>Roll No</p></td> <td><p>Name</p></td> <td><p>Father Name</p></td> <td><p>phone No</p></td> <td><p>Address</p></td> <td><p>Field</p></td>"; while($record = mysql_fetch_assoc($result)) { echo "<tr> <td width= 84><input name='checkbox' type='checkbox' id='checkbox'></td> <td width = 350><p>".$record["rollNo"]."</p></td> <td><p>".$record["name"]."</p></td> <td><p>".$record["fatherName"]."</p></td> <td><p>".$record["phoneNo"]."</p></td> <td><p>".$record["address"]."</p></td> <td><p>".$record["field"]."</p></td>"; } } if($sroll) { echo "<h1>Searched By Roll Number:</h1>"; $query = "select * from nu where rollNo like ".$sroll.""; $result = mysql_query($query); echo "<table width = '100%' border = '0'"; echo "<tr bgcolor = 'lightblue'><td><P><B>Select</p></B></td> <td><p>Roll No</p></td> <td><p>Name</p></td> <td><p>Father Name</p></td> <td><p>phone No</p></td> <td><p>Address</p></td> <td><p>Field</p></td>"; while($record = mysql_fetch_assoc($result)) { echo "<tr> <td width= 84><input name='delete' type='checkbox' id='delete' value='yes'></td> <td><p>".$record["rollNo"]."</p></td> <td><p>".$record["name"]."</p></td> <td><p>".$record["fatherName"]."</p></td> <td><p>".$record["phoneNo"]."</p></td> <td><p>".$record["address"]."</p></td> <td><p>".$record["field"]."</p></td>"; } } ?> <BR> <BR> <a href = "search.html">If you want to search more then Please Click HERE[/url] <BR> <BR> <a href = "adddata_nu.html">If you want to add more then Please Click HERE[/url]</p> <label for="Submit"></label> <input type="submit" name="Submit" id="Submit" value="Delete"> </form> <p><BR> <BR> </p> </body> </html> I only did it for the if($name) statement, so make sure your testing it with that one. If that works, try to do the others yourself by looking at what I did.
  13. You don't use $result['type']...you have to use $row['type']. So do $type = $row['type'];
  14. You were trying to use the $result variable, which is just the query handle. You need to extract the fields from the database by doing $row = mysql_fetch_assoc($result); Does that make sense?
  15. Try <?php else { // create query $query = 'SELECT type FROM reviews WHERE id = '.$id.''; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $row = mysql_fetch_assoc($result); switch ($row['type']) { case show: include('reviews/show.php'); break; case album: include('reviews/album.php'); break; case venue: include('reviews/venue.php'); break; } }
  16. I wrote up an example script for you to reference, although I didn't test it for errors. <?php //check if they pressed delete button if (isset($_POST['delete'])){ //make sure they checked something if (!empty($_POST['ids'])){ //execute delete query $query = "DELETE FROM table WHERE id IN(" .implode(', ', {$_POST['ids']}) . ")"; if ($result = mysql_query($query)) echo "Successfully Deleted"; else echo mysql_error(); } else { echo "Nothing Selected to Delete"; } } //Select info from DB $query = mysql_query("SELECT id FROM table")or die(mysql_error()); //create checkboxes echo "<form>"; while ($row = mysql_fetch_assoc($query)){ echo "<input type='checkbox' name='ids[]' value='{$row['id']}' />"; } echo "<input type='submit' name='delete' value='Delete' />"; echo "</form>"; ?>
  17. Show us your code so we can tell you what your doing wrong.
  18. You can manually insert a record and set the ID as 100, then it will go up from there...if that would be an option for you.
  19. Do you get an error? foreach($_POST as $key-->$value) Should be foreach($_POST as $key => $value)
  20. You could do this <?php $query = mysql_query("SELECT name FROM users ORDER BY RAND() LIMIT 1")or die(mysql_error()); $row = mysql_fetch_assoc($query); echo $row['user']; ?>
  21. Look into CSS, this has nothing to do with PHP.
  22. Your doing it correctly. Usually you would only do that if you had two tables with the same field name and you had to differentiate between the two...or if you were selecting the sum of two fields or something like that. But what your doing should work. Have you tried it?
  23. Try <?php if(mysql_result(mysql_query("SELECT * FROM `products` WHERE `barcode`='{$barcode}'"), 0)){ mysql_query("UPDATE `products` SET `quantity`=(`quantity` + $quantity) WHERE `barcode`='{$barcode}'") or die(mysql_error()); } else { //Nope, add a new one. mysql_query("INSERT INTO products (id, name, barcode, price, quantity) VALUES('$id', '$name', '$barcode', '$price', '$quantity') ") or die( mysql_error()); } echo "<center><h3>Product Added - Returning!</h3></center>"; ?>
  24. Instead of just using $bod, your going to have to probably use $_GET['bod'].
×
×
  • 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.