Jump to content

andyjcurtis

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by andyjcurtis

  1. try this if the code recieves the data and procces it? $connect=mysql_connect("localhost","root",""); mysql_select_db("bank",$connect) or die ("could not select database"); $nic =$_get['nic']; $full_name =$_get['full_name']; $name_with_initials =$_get['name_with_initials']; $address =$_get['address']; $contact_number =$_get['contact_number']; $gender =$_get['gender']; if(isset($_get['customer_id'])) { $customer_id=(int)$_get['customer_id']; $result = mysql_query("UPDATE customer SET nic = '$nic', full_name = '$full_name', name_with_initials = '$name_with_initials', address = '$address', contact_number = '$contact_number', gender = '$gender'") ; if($result){ echo "Your information has been successfully added to the database."; }else{ echo "Failed"; } } ?>
  2. Try doing this first. I always works for me. 1: create a test page for each query; 2: echo" each $variable onto the screen so you can see it work ( when ever is it used or modified)."; 3: run the query Directly onto the database changing all the $varlables to valid values to see the $result; 4:I'm not sure Update * from customer will work do step3. if you dont get a valid responce try Step 5 UPDATE (((* from ))) customerSET nic = '$nic', full_name = '$full_name', name_with_initials = '$name_with_initials', address = '$address', contact_number = '$contact_number', gender = '$gender'") ; 5: try this Directly onto the database replacing all the $variables with Valid Values (int's varchar's ect). UPDATE customer SET nic = '$nic', full_name = '$full_name', name_with_initials = '$name_with_initials', address = '$address', contact_number = '$contact_number', gender = '$gender'") ; gooduck
  3. I am trying to update a mysql table called AvItems with the value 'Torso' in the Equip "section?" I have been through the forums and cannot see anything to match. I dont mind if the page looses the onsubmit() and has a button instead. Though I would like to update the database and link back to the same page: There is a display that shows the item that is currently equiped, I have put this in to show it works, or doesn't as the case may be. Hope I got the code /code right this time. many thanks in advance Andy Curtis create table Items( ItemID integer unsigned auto_increment primary key, ItemName varchar(20) not null, Type varchar(10), UsedOn varchar(10), ); create table AvItems( AvItemID integer unsigned auto_increment primary key, AvID integer unsigned, ItemID integer unsigned, Equip varchar(); <?php $username="root"; $password="MyPassword"; $database="MyDataBase"; $AvName = "AndyJCurtis"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $AvAccR = mysql_query( " SELECT AvID FROM AvAcc WHERE AvName = '$AvName' " ); $AvID = mysql_result($AvAccR, 0, 'AvID'); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $Torso = mysql_query(" select ItemName from AvItems, Items where AvItems.itemID = Items.itemID AND AvItems.AvID = '$AvID' AND UsedON = 'Body' "); $TorsoE = mysql_query(" select ItemName from AvItems, Items where AvItems.itemID = Items.itemID AND AvItems.AvID = '$AvID' And UsedON = 'Body' AND Equip = 'Body' "); if(mysql_num_rows($TorsoE) != 0) { $TorsoItem = mysql_result($TorsoE ,0,"ItemName"); //mysql_close(); ?> <title></title> <head></head> <body> <form action="http://localhost/CI/Equip2.php" method="post"> <table border=1> <tbody> <tr> <td>Torso<BR> <?PHP echo "$TorsoItem <BR>"; ?> <select name="Torso" onchange="submit();" value =" Update"> <?PHP while($TorsoRow = mysql_fetch_array($Torso)) { echo "<option value=\"".$TorsoRow['ItemName']."\">".$TorsoRow['ItemName']."\n </option>"; } ?> </select> </td> </tr> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// <?php if($_POST['Torso'] == 'Update') { mysql_query("update AvItems set Equip = '' where Equip='Torso'") or die("cant update unequip"); mysql_query("update AvItems set Equip = 'Torso' where ItemID='{$_POST['ItemName']}'") or die("cant update equip"); } ?> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// </tbody> </table> </.form> </body> </html>
  4. dreamwest & wildteen88 Thank you so much, I really appreciate your help. The problem was I was using $_post where I shoud be using $_get or $_request in buy.php 2nd Problem was the 'ID is: 123' was not seen within my Echo href ......... I was seeing ID=?<?$ID?> Problem solved, I was not sending properly and not recieveing properly. ?> <td> <a href="http://localhost/CI/Buy.php?ID= <?=$ID?> "> <i>Buy</i></a> </td> <?; <?php if (isset($_GET['ID'])) { echo "<BR>ID: $ID"; echo '<BR>ID is: ' .$_GET['ID']; } ?> Have a :D each! thanks again
  5. thanks again for the pointers, I have tried using $_get and $_request, the secondpage still comes up blank? I think the data is not being sent across, though I am not sure where the problem is in the First page.
  6. yes they can. I still get a blank secondpage though.
  7. HI I'm kinda new to PHP Mysql, so I Dont really know how to define my problem properly to search for a solution. So far I have only found Solutions to update and Insert, I am having some problems sending data across to a different page. I am looking for a solution without using a onscreen button to submit tha data. I would like to send the data across via Href ( either javascript Submit or just a Href link) I have included both in my code. So if you could please point me in the right direction and inform me where i am going wrong that would br great. thank you In advance btw. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// FirstPageCode.php <form name="MyTable" method="POST"> <script type="text/javascript"> function submitMe() { document.MyTable.action="http://localhost/CI/Buy.php?ID=<?=$ID?>"; //document.MyTable.target="targetName"; document.MyTable.value="Send"; document.MyTable.submit(); return; } //$PostID = $_POST["PostID"]; mysql_connect('localhost', 'root', 'spe11gard'); @mysql_select_db(CI) or die( "Unable to select database"); $QueryQ="SELECT * FROM MyTable where ID"; //$QueryQ="SELECT * FROM MyTable where ID LIKE '%$PostID%'"; $ResultR=mysql_query($QueryQ);//30 $onN=mysql_numrows($ResultR); mysql_close(); echo "<b><center>on Smiths</center></b><br><br>"; ?> <table class="striped"> <tr class="header"> <td> Name </td> <td>zero </td> <td>one </td> <td>two </td> <td>three </td> <td>four </td> </tr> <?php //50 $i=0; while ($row = mysql_fetch_array($ResultR)) { $ID=$row['ID']; $zero=$row['zero']; $one=$row['one'];//60 $two=$row['two']; $three=$row['three']; $four=$row['four']; echo "<tr>"; echo "<td>$ID </td>"; echo "<td>$zero </td>"; echo "<td>$one </td>"; echo "<td>$two </td>"; echo "<td>$three </td>"; echo "<td>$four GP </td>"; echo '<td> <a href="http://localhost/CI/Buy.php?ID=<?=$ID?>"> <i>Buy</i></a> </td>'; echo '<td> <a href=javascript:this.submitMe();><i>Buy</i></a> </td>'; echo "</tr>"; $i++; } ?> </table> </form> /////////////////////////////////////////////////////////////////////////////////////////////// SecongPageCode.php <?php if (isset($_POST['$ID'])) { //$ID = $_REQUEST['ID']; echo "ID: $ID "; } ?>
×
×
  • 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.