Jump to content

m00ch0

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

m00ch0's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Anyone I'm still stuck with the script ???
  2. I'm newish at php and I just can't seem to get this to work anymore about a month ago it was working fine the same script but now thats not even working the code is straight from http://www.phpeasystep.com/mysql/8.html so any help would be greatly appreciated! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Untitled Document</title> </head> <body> <?php $host="xxxx"; // Host name $username="xxxx"; // Mysql username $password="xxx"; // Mysql password $db_name="xxx"; // Database name $tbl_name="test_mysql"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> </body> </html>
  3. I'm looking for a password script to keep out the regular user but I have searched through the internet most of today found a few but everytime I try to add them into this script they dont work. I would like a small login box where it gives u access to this page otherwize your cant access it. I'm stuck at the moment I have little php knowledge <?php $host="xxxxxxx"; // Host name $username="xxxx"; // Mysql username $password="xxxxx"; // Mysql password $db_name="xxxxx"; // Database name $tbl_name="xxxxxx"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY scan ASC"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td><img src="sclogo.gif" width="210" height="29"></td> </tr> </table> <form name="form1" method="post" action=""> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="35" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Scan</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Manufacturer</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Description </font></td> <td width="45" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Code</font></td> <td width="200" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Part Number</font></td> <td width="60" nowrap="nowrap" bgcolor="391d4c" align="center"><font color="#6cba00" size="1" face="Verdana">Delete</font></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr class="data"> <td><? echo $rows['scan']; ?></td> <td><? echo $rows['manufacturer']; ?></td> <td><? echo $rows['description']; ?></td> <td><? echo $rows['code']; ?></td> <td><? echo $rows['partno']; ?></td> <td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td align="center" class="data"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php if(isset($_POST['delete'])) { foreach($_POST['checkbox'] as $row_id) { $sql = "DELETE FROM $tbl_name WHERE id='$row_id'"; $result = mysql_query($sql); if($result === FALSE) die("Error occured deleting row ".$row_id."!"); } echo "<meta http-equiv=\"refresh\" content=\"0;URL=sc_testing_with_delete.php\">"; } ?> </table> </form> <?php if (!isset($_POST['submit'])) { ?> <form action="" method="post"> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="35" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Scan</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Manufacturer</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Description</font></td> <td width="45" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Code</font></td> <td width="200" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Part number</font></td> <td width="60" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Submit</font></td> </tr> <tr class="data"> <td ><font color="#6cba00" size="1" face="Verdana"><input name="scan" type="text" size="5" maxlength="4" class="data"></font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="manufacturer" type="text" class="data" size="40"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="description" type="text" class="data" size="40"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><select name="code" class="data"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> </select></font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="partno" type="text" class="data" size="32"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><input type="submit" name="submit" value="Add Part" class="data"> </font></td> </tr> </table> </form> <?php } else { $scan = $_POST['scan']; $manufacturer = $_POST['manufacturer']; $description = $_POST['description']; $code = $_POST['code']; $partno = $_POST['partno']; mysql_query("INSERT INTO scontrol (scan, manufacturer, description, code, partno) VALUES ('$scan', '$manufacturer', '$description', '$code', '$partno')"); echo "<br><p class=\"style1\">"; echo "The new part has been added to the database!!"; echo "<br>"; echo "<br>"; echo "<a href=\"sc_testing_with_delete.php\" title=\"Sc_testing_with_delete page\">Click here to add another part</a><br/>"; echo "</p>"; } ?> </td> </tr> </table> <p> </p> <?php } ?>
  4. Thanks alot works prefect i used the Or insted of and cheers
  5. "SELECT * FROM scontrol WHERE scan LIKE '%$search%'" Currently its only search through scan as you can see above thanks in advance
  6. It turned out that i needed to get rid of the ` around scontrol mysql_query("INSERT INTO `scontrol` (scan, manufacturer, description, code, partno) VALUES ('$scan', '$manufacturer', '$description', '$code', '$partno')"); echo " <p class=\"style1\">";
  7. This is the part which isn't working it suppose to add into the database but it doesn't <?php } else { $scan = $_POST['scan']; $manufacturer = $_POST['manufacturer']; $description = $_POST['description']; $code = $_POST['code']; $partno = $_POST['partno']; mysql_query("INSERT INTO `scontrol` (scan, manufacturer, description, code, partno) VALUES ('$scan', '$manufacturer', '$description', '$code', '$partno')"); echo " <p class=\"style1\">"; echo "The new part has been added to the database!!"; echo " "; echo " "; echo "<a href=\"sc_testing_with_delete.php\" title=\"Sc_testing_with_delete page\">Click here to add another part[/url] "; echo "</p>"; } ?>
  8. I had this full script working on another webhost but now ive changed it wont work. I'm hoping its in the code and someone can help me located the problem! <html> <head> <title>Displaying MySQL Data</title> <link href="tables.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <style type="text/css"> <!-- body { background-color: #6cba00; } .style1 { font-family: Verdana; color: #391D4C; } --> </style> </head> <body> <p> <?php $host="xxx"; // Host name $username="xxx"; // Mysql username $password="xxx"; // Mysql password $db_name="xxx"; // Database name $tbl_name="scontrol"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY scan ASC"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td><img src="logo.gif"></td> </tr> </table> </td> </tr> <tr> <td> <form name="form1" method="post" action=""> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="35" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Scan</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Manufacturer</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Description </font></td> <td width="45" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Code</font></td> <td width="200" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Part Number</font></td> <td width="60" nowrap="nowrap" bgcolor="391d4c" align="center"><font color="#6cba00" size="1" face="Verdana">Delete</font></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr class="data"> <td><? echo $rows['scan']; ?></td> <td><? echo $rows['manufacturer']; ?></td> <td><? echo $rows['description']; ?></td> <td><? echo $rows['code']; ?></td> <td><? echo $rows['partno']; ?></td> <td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td align="center" class="data"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php if(isset($_POST['delete'])) { foreach($_POST['checkbox'] as $row_id) { $sql = "DELETE FROM $tbl_name WHERE id='$row_id'"; $result = mysql_query($sql); if($result === FALSE) die("Error occured deleting row ".$row_id."!"); } echo "<meta http-equiv=\"refresh\" content=\"0;URL=sc_testing_with_delete.php\">"; } ?> </table> </form> <?php if (!isset($_POST['submit'])) { ?> <form action="" method="post"> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="35" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Scan</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Manufacturer</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Description</font></td> <td width="45" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Code</font></td> <td width="200" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Part number</font></td> <td width="60" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Submit</font></td> </tr> <tr class="data"> <td ><font color="#6cba00" size="1" face="Verdana"><input name="scan" type="text" size="5" maxlength="4" class="data"></font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="manufacturer" type="text" class="data" size="40"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="description" type="text" class="data" size="40"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><select name="code" class="data"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> </select></font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="partno" type="text" class="data" size="32"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><input type="submit" name="submit" value="Add Part" class="data"> </font></td> </tr> </table> </form> <?php } else { $scan = $_POST['scan']; $manufacturer = $_POST['manufacturer']; $description = $_POST['description']; $code = $_POST['code']; $partno = $_POST['partno']; mysql_query("INSERT INTO `scontrol` (scan, manufacturer, description, code, partno) VALUES ('$scan', '$manufacturer', '$description', '$code', '$partno')"); echo "<br><p class=\"style1\">"; echo "The new part has been added to the database!!"; echo "<br>"; echo "<br>"; echo "<a href=\"sc_testing_with_delete.php\" title=\"Sc_testing_with_delete page\">Click here to add another part</a><br/>"; echo "</p>"; } ?> </td> </tr> </table> <p> </p> </body> </html> Full script above but I'm struggling with the below part <?php } else { $scan = $_POST['scan']; $manufacturer = $_POST['manufacturer']; $description = $_POST['description']; $code = $_POST['code']; $partno = $_POST['partno']; mysql_query("INSERT INTO `scontrol` (scan, manufacturer, description, code, partno) VALUES ('$scan', '$manufacturer', '$description', '$code', '$partno')"); echo "<br><p class=\"style1\">"; echo "The new part has been added to the database!!"; echo "<br>"; echo "<br>"; echo "<a href=\"sc_testing_with_delete.php\" title=\"Sc_testing_with_delete page\">Click here to add another part</a><br/>"; echo "</p>"; } ?>
  9. <?php //connect to mysql mysql_connect("localhost","x","x"); mysql_select_db("x"); $tbl_name="x"; // Table name $search=$_POST["search"]; $result = mysql_query("SELECT * FROM $tbl_name WHERE scan LIKE '%$search%'"); while($row=mysql_fetch_array($result)) { $scan=$row["scan"]; $manufacturer=$row["manufacturer"]; $description=$row["description"]; $code=$row["code"]; $partno=$r["partno"]; $id=$r["id"]; echo "$scan <br> $manufacturer <br> $description <br> $code | $partno <br>"; } ?> the code as you can see searchs only in the scan column how can I get it to search every column apart from id?
  10. I'm moving onto another part of my site at the moment I'm going to close this and say its solved as its not as important as a other features thanks for all your help guys anyway my bad code writting doesnt help at all
  11. changed the sql line but still same two errors appear
  12. <html> <head> <title>Displaying MySQL Data</title> <link href="tables.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <style type="text/css"> <!-- body { background-color: #6cba00; } .style1 { font-family: Verdana; color: #391D4C; } --> </style> </head> <body> <p> <?php $host="localhost"; // Host name $username="m00ch00"; // Mysql username $password="m00ch00"; // Mysql password $db_name="m00ch00_zendurl0"; // Database name $tbl_name="sc_parts"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM table ORDER BY ".$_GET['sort']." ".$_GET['order'].""; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td><img src="logo.gif"></td> </tr> </table> </td> </tr> <tr> <td> <form name="form1" method="post" action=""> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="35" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana"><a href="http://www.zendurl.com/m00ch00/sc_testing_with_delete_and_sort.php?sort='scan'&order=ASC">Scan</a></font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Manufacturer</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Description </font></td> <td width="45" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Code</font></td> <td width="200" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Part Number</font></td> <td width="60" nowrap="nowrap" bgcolor="391d4c" align="center"><font color="#6cba00" size="1" face="Verdana">Delete</font></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr class="data"> <td><? echo $rows['scan']; ?></td> <td><? echo $rows['manufacturer']; ?></td> <td><? echo $rows['description']; ?></td> <td><? echo $rows['code']; ?></td> <td><? echo $rows['partno']; ?></td> <td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td align="center" class="data"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php if(isset($_POST['delete'])) { foreach($_POST['checkbox'] as $row_id) { $sql = "DELETE FROM $tbl_name WHERE id='$row_id'"; $result = mysql_query($sql); if($result === FALSE) die("Error occured deleting row ".$row_id."!"); } echo "<meta http-equiv=\"refresh\" content=\"0;URL=sc_testing_with_delete.php\">"; } ?> </table> </form> <?php if (!isset($_POST['submit'])) { ?> <form action="" method="post"> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="35" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Scan</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Manufacturer</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Description</font></td> <td width="45" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Code</font></td> <td width="200" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Part number</font></td> <td width="60" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Submit</font></td> </tr> <tr class="data"> <td ><font color="#6cba00" size="1" face="Verdana"><input name="scan" type="text" size="5" maxlength="4" class="data"></font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="manufacturer" type="text" class="data" size="40"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="description" type="text" class="data" size="40"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><select name="code" class="data"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> </select></font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="partno" type="text" class="data" size="32"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><input type="submit" name="submit" value="Add Part" class="data"> </font></td> </tr> </table> </form> <?php } else { $scan = $_POST['scan']; $manufacturer = $_POST['manufacturer']; $description = $_POST['description']; $code = $_POST['code']; $partno = $_POST['partno']; mysql_query("INSERT INTO sc_parts (scan, manufacturer, description, code, partno) VALUES ('$scan', '$manufacturer', '$description', '$code', '$partno')"); echo "<br><p class=\"style1\">"; echo "The new part has been added to the database!!"; echo "<br>"; echo "<br>"; echo "<a href=\"sc_testing_with_delete.php\" title=\"Sc_testing_with_delete page\">Click here to add another part</a><br/>"; echo "</p>"; } ?> </td> </tr> </table> <p> </p> </body> </html>
  13. I just keep getting error after error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/zendurl/public_html/m/xxxxx/sc_testing_with_delete_and_sort.php on line 36 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/zendurl/public_html/m/xxxxx/sc_testing_with_delete_and_sort.php on line 62 this is really starting to annoy me and I dont like asking you guys all the time and this is the easiest way to do it my god!
  14. $sql="SELECT * FROM table ORDER BY ".$_GET['sort']." ".$_GET['order']""; adding the two extra "" Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/zendurl/public_html/m/xxxxx/sc_testing_with_delete_and_sort.php on line 32 its definitly the $sql line as its 32
  15. the more I add to my code the more errors I get I'm now getting what am i doing wrong it seems like it should work?!? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/zendurl/public_html/m/xxxxx/sc_testing_with_delete_and_sort.php on line 36 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/zendurl/public_html/m/xxxxx/sc_testing_with_delete_and_sort.php on line 62 <html> <head> <title>Displaying MySQL Data</title> <link href="tables.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <style type="text/css"> <!-- body { background-color: #6cba00; } .style1 { font-family: Verdana; color: #391D4C; } --> </style> </head> <body> <p> <?php $host="localhost"; // Host name $username="user"; // Mysql username $password="pass"; // Mysql password $db_name="xxxxx"; // Database name $tbl_name="table"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql=$sql="SELECT * FROM table ORDER BY ".$_GET['sort']." ".$_GET['order']; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td><img src="logo.gif"></td> </tr> </table> </td> </tr> <tr> <td> <form name="form1" method="post" action=""> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="35" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana"> should be a arrow here a href="http://www.zendurl.com/xxxxx/sc_testing_with_delete_and_sort.php?sort='scan'&order=ASC">Scan</a></font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Manufacturer</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Description </font></td> <td width="45" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Code</font></td> <td width="200" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Part Number</font></td> <td width="60" nowrap="nowrap" bgcolor="391d4c" align="center"><font color="#6cba00" size="1" face="Verdana">Delete</font></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr class="data"> <td><? echo $rows['scan']; ?></td> <td><? echo $rows['manufacturer']; ?></td> <td><? echo $rows['description']; ?></td> <td><? echo $rows['code']; ?></td> <td><? echo $rows['partno']; ?></td> <td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td align="center" class="data"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php if(isset($_POST['delete'])) { foreach($_POST['checkbox'] as $row_id) { $sql = "DELETE FROM $tbl_name WHERE id='$row_id'"; $result = mysql_query($sql); if($result === FALSE) die("Error occured deleting row ".$row_id."!"); } echo "<meta http-equiv=\"refresh\" content=\"0;URL=sc_testing_with_delete.php\">"; } ?> </table> </form> <?php if (!isset($_POST['submit'])) { ?> <form action="" method="post"> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td width="35" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Scan</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Manufacturer</font></td> <td width="250" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Description</font></td> <td width="45" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Code</font></td> <td width="200" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Part number</font></td> <td width="60" nowrap="nowrap" bgcolor="391d4c"><font color="#6cba00" size="1" face="Verdana">Submit</font></td> </tr> <tr class="data"> <td ><font color="#6cba00" size="1" face="Verdana"><input name="scan" type="text" size="5" maxlength="4" class="data"></font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="manufacturer" type="text" class="data" size="40"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="description" type="text" class="data" size="40"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><select name="code" class="data"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> </select></font></td> <td><font color="#6cba00" size="1" face="Verdana"><input name="partno" type="text" class="data" size="32"> </font></td> <td><font color="#6cba00" size="1" face="Verdana"><input type="submit" name="submit" value="Add Part" class="data"> </font></td> </tr> </table> </form> <?php } else { $scan = $_POST['scan']; $manufacturer = $_POST['manufacturer']; $description = $_POST['description']; $code = $_POST['code']; $partno = $_POST['partno']; mysql_query("INSERT INTO sc_parts (scan, manufacturer, description, code, partno) VALUES ('$scan', '$manufacturer', '$description', '$code', '$partno')"); echo "<br><p class=\"style1\">"; echo "The new part has been added to the database!!"; echo "<br>"; echo "<br>"; echo "<a href=\"sc_testing_with_delete.php\" title=\"Sc_testing_with_delete page\">Click here to add another part</a><br/>"; echo "</p>"; } ?> </td> </tr> </table>
×
×
  • 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.