Jump to content

karl_009

Members
  • Posts

    28
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

karl_009's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello, I have a table that has information from a MySQL DB, there are two fields current stock and minimum stock. I would like some help with making the current stock table colour change depending want the minimum stock level is. So if the minimum stock is 2 and the current stock is 3 then the colour is green and in the current stock is 2 or 1 then the colour is red. Here is the code that I am currently using; <table bgcolor="#0066FF" border="0" width="75%" cellspacing="1" cellpadding="2"> <?php // Query for displaying data from computers table $query = "SELECT * FROM inv_consumable ORDER BY stockloc"; $result = @mysql_query ($query, $connection); // FOR loop, loops though each line of data to be displayed for ($i = 0; $i < @mysql_num_rows ($result); $i++) { $consid = mysql_result ($result, $i, "consid"); $consname = mysql_result ($result, $i,"consname"); $conserial = mysql_result ($result, $i,"conserial"); $currstock = mysql_result ($result, $i,"currstock"); $minstock = mysql_result ($result, $i,"minstock"); $stockloc = mysql_result ($result, $i,"stockloc"); $rows = ($result); // Alternates the colour of the rows for the table if ($i % 2) { $bg_color="#EEEEEE"; } else { $bg_color="#AAAAAA"; } // Displays the table echo ' <tr> <td width="15%" bgcolor="'.$bg_color.'"> <font face="arial" size="2"> <b>Consumable Name:</b> <a href="consumable_read.php?consid='.$consid.'">'.$consname.'</a> </font> <td> <td width="20%" valign="top" bgcolor="'.$bg_color.'"> <font face="arial" size="2"> <b> Serial Number: </b> '.$conserial.' </font> </td> <td> <td width="20%" valign="top" bgcolor="'.$bg_color.'"> <font face="arial" size="2"> <b> Current Stock: </b> '.$currstock.' </font> </td> <td> <td width="15%" valign="top" bgcolor="'.$bg_color.'"> <font face="arial" size="2"> <b> Minimum Stock: </b> '.$minstock.' </font> </td> <td> <td width="20%" valign="top" bgcolor="'.$bg_color.'"> <font face="arial" size="2"> <b> Stock Location: </b> '.$stockloc.' </font> </td> <td> <td width="5%" valign="top" align="center" bgcolor="'.$bg_color.'"><a href="consumable_edit.php?consid='.$consid.'"><img src="buttons/update.png" title="Update"></a> <font face="arial" size="2"> </font> </td> <td> <td width="8%" valign="top" align="center" bgcolor="'.$bg_color.'"><a href="consumable_del_ac.php?consid='.$consid.'"><img src="buttons/delete.png" title="Delete"></a> <font face="arial" size="2"> </font> </td> </tr> '; } ?> </table> Thanks for any help Karl
  2. Sorted... Just added the code below the function and it works great. onload = SelectChanged; Thank You for all your help on this. For awhile I didn’t think it would get going. Once again Thanks for all your help kickstart.
  3. Hello, I have put a mock-up on a free hosting site... http://karl_009.hyperphp.com/main1.php If you click on "Contract New Record" fill out all the details if you dont validation will get you somewhere on the form. All data on that form goes into a table except for Street Address, Address Line2, City, Region, Postcode, and Country. When you go to edit the form by clicking on Contract Names in the table, the supplier name that was selected when entering the data is not set even though that data is in the database. Now how do you get that to display while displaying the rest of the data from the other table eg... Street Address, Address Line2, City, Region, Postcode, and Country. Thanks Karl
  4. Hello, The first lot of code is for someone when entering in new contract details, the selection from the dropdown menu is entered into the contracts table as “suppname”. So I have a second form for editing, when I open it up I can see the data that I entered in the first form except for the supplier name which is in the contract database. So when am on the editing form I would like it to get the supplier name and still display the additional fields from the first form. So I have; Contract_new.php and contract_edit.php I hope that’s a bit clearly. Thanks Karl
  5. Hello.. How would I get this dropdown menu to carry on doing the task its doing, BUT also get a field of information out of the database a display its result in the dropdown menu therefore the fields of data that have been disabled will display the information without anyone selecting anything from the dropdown menu. <?php $DropDownList .= "<select name='suppname' id='suppname' class='field select medium' onchange='javascript:SelectChanged();'> ".$vbCrLf; $DropDownList .= "<option value=''></option> ".$vbCrLf; while($row = mysql_fetch_row($result)) { $heading = $row[0]; $DropDownList .= "<option value='$heading'>$heading</option> ".$vbCrLf; $Add1ArrayPhp .= 'Add1Array["'.$heading.'"]="'.$row[1].'";'.$vbCrLf; $Add2ArrayPhp .= 'Add2Array["'.$heading.'"]="'.$row[2].'";'.$vbCrLf; $CityArrayPhp .= 'CityArray["'.$heading.'"]="'.$row[3].'";'.$vbCrLf; $RegionArrayPhp .= 'RegionArray["'.$heading.'"]="'.$row[4].'";'.$vbCrLf; $PostCodeArrayPhp .= 'PostCodeArray["'.$heading.'"]="'.$row[5].'";'.$vbCrLf; $CountryArrayPhp .= 'CountryArray["'.$heading.'"]="'.$row[6].'";'.$vbCrLf; } $DropDownList .= "</select> ".$vbCrLf; ?> Thanks... Karl
  6. Hello, I might have used the wrong wording then. The $DropDownList that is created by the PHP gets data from a table, and when you select that data it retrieves the data and displays it in a number of fields on the form. The dropdown menu called $DropDownList enters the selected value into the database "suppname". The fields of data that this retrieves are not entered into the new table. But this form is to view data that has already been selected and entered, so when a user opens this form to view a record, the saved value in the database for suppname which is selected by dropdown menu called $DropDownList is not retrieves and the information is not shown. Here is the full code; <?php require ("include/db_config.php"); $connection = @mysql_connect ($db_host, $db_user, $db_pass) or die ("Error with Connection"); mysql_select_db ($db_name, $connection); // Get value from address bar $contid=$_GET['contid']; // Get data from database $query = "SELECT * FROM man_contracts WHERE contid='$contid'"; $result = mysql_query ($query); $rows = mysql_fetch_array ($result); ?> <?php $vbCrLf = chr(13).chr(10); // open connection to MySQL server $connection = mysql_connect('localhost', 'root', 'pass') or die ('Unable to connect!'); //select database mysql_select_db('cmp') or die ('Unable to select database!'); //create and execute query $query = 'SELECT suppname, suppadd1, suppadd2, suppcity, suppregion, supppostc, suppcountry FROM man_suppliers ORDER BY suppname'; $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); //create selection list $DropDownList .= "<select name='suppname' id='suppname' class='field select medium' onchange='javascript:SelectChanged();'> ".$vbCrLf; $DropDownList .= "<option value=''></option> ".$vbCrLf; while($row = mysql_fetch_row($result)) { $heading = $row[0]; $DropDownList .= "<option value='$heading'>$heading</option> ".$vbCrLf; $Add1ArrayPhp .= 'Add1Array["'.$heading.'"]="'.$row[1].'";'.$vbCrLf; $Add2ArrayPhp .= 'Add2Array["'.$heading.'"]="'.$row[2].'";'.$vbCrLf; $CityArrayPhp .= 'CityArray["'.$heading.'"]="'.$row[3].'";'.$vbCrLf; $RegionArrayPhp .= 'RegionArray["'.$heading.'"]="'.$row[4].'";'.$vbCrLf; $PostCodeArrayPhp .= 'PostCodeArray["'.$heading.'"]="'.$row[5].'";'.$vbCrLf; $CountryArrayPhp .= 'CountryArray["'.$heading.'"]="'.$row[6].'";'.$vbCrLf; } $DropDownList .= "</select> ".$vbCrLf; ?> <html> <head> <title> Contract Details </title> <script language="Javascript" type="text/javascript"> var Add1Array = new Array(); <?php echo $Add1ArrayPhp; ?> var Add2Array = new Array(); <?php echo $Add2ArrayPhp; ?> var CityArray = new Array(); <?php echo $CityArrayPhp; ?> var RegionArray = new Array(); <?php echo $RegionArrayPhp; ?> var PostCodeArray = new Array(); <?php echo $PostCodeArrayPhp; ?> var CountryArray = new Array(); <?php echo $CountryArrayPhp; ?> function SelectChanged() { var Company = document.getElementById('suppname').value; document.getElementById('suppadd1').value = Add1Array[Company]; document.getElementById('suppadd2').value = Add2Array[Company]; document.getElementById('suppcity').value = CityArray[Company]; document.getElementById('suppregion').value = RegionArray[Company]; document.getElementById('supppostc').value = PostCodeArray[Company]; document.getElementById('suppcountry').value = CountryArray[Company]; } </script> </head> <body id="public"> <img id="top" src="images/top.png" alt="" /> <div id="container"> <form id="contracts" name="contracts" class="" autocomplete="off" enctype="multipart/form-data" method="post" action="contract_view.php"> <div class="info"> <h2>Contract Details</h2> <div></div> </div> <ul> <li id="foli1" class=" "> <label class="desc" id="title1" for="Field1"> Contract Name <span id="req_1" class="req">*</span> </label> <div> <input id="contname" name="contname" type="text" class="field text large" value="<?php echo $rows['contname']; ?>" maxlength="255" tabindex="1" /> </div> </li> <li id="foli3" class=" "> <label class="desc" id="title3" for="Field3"> Supplier Name <span id="req_3" class="req">*</span> </label> <div> <?php echo $DropDownList; ?> </div> </li> <li id="foli7" class=" "> <label class="desc" id="title7" for="Field7"> Type of Contract <span id="req_7" class="req">*</span> </label> <div> <select id="conttype" name="conttype" class="field select medium" value="" tabindex="3"> <option value=""></option> <option value="Hardware Maintenance" <? if($rows['conttype'] == "Hardware Maintenance") echo "selected"; ?>> Hardware Maintenance </option> <option value="Software Maintenance" <? if($rows['conttype'] == "Software Maintenance") echo "selected"; ?>> Software Maintenance </option> <option value="Printing Lease" <? if($rows['conttype'] == "Printing Lease") echo "selected"; ?>> Printing Lease </option> <option value="Leasing" <? if($rows['conttype'] == "Printing Lease") echo "selected"; ?>> Leasing </option> <option value="Location" <? if($rows['conttype'] == "Printing Lease") echo "selected"; ?>> Location </option> </select> </div> </li> <li id="foli9" class=" "> <label class="desc" id="title9" for="Field9"> Status <span id="req_9" class="req">*</span> </label> <div> <select id="contstatus" name="contstatus" class="field select medium" value="<?php echo $rows['contstatus']; ?>" tabindex="4"> <option value=""><?php echo $rows['contstatus']; ?></option> <option value="Awaiting Approval">Awaiting Approval</option> <option value="Active">Active</option> <option value="Expired">Expired</option> </select> </div> </li> <li id="foli11" class=" "> <label class="desc" id="title11" for="Field11"> Contract Notes </label> <div> <textarea id="contnotes" name="contnotes" class="field textarea medium" rows="10" cols="50" tabindex="5"> <?php echo $rows['contnotes']; ?> </textarea> </div> </li> <li id="foli12" class=" "> <label class="desc" id="title12" for="Field12"> Start Date </label> <span> <input id="contsd" name="contsd" type="text" class="field text" value="<?php echo $rows['contsd']; ?>" size="2" maxlength="2" tabindex="6" /> / <label for="param1">DD</label> </span> <span> <input id="contsm" name="contsm" type="text" class="field text" value="<?php echo $rows['contsm']; ?>" size="2" maxlength="2" tabindex="7" /> / <label for="param2">MM</label> </span> <span> <input id="contsy" name="contsy" type="text" class="field text" value="<?php echo $rows['contsy']; ?>" size="4" maxlength="4" tabindex="8" /> <label for="param3">YYYY</label> </span> </li> <li id="foli13" class=" "> <label class="desc" id="title13" for="Field13"> End Date <span id="req_13" class="req">*</span> </label> <span> <input id="conted" name="conted" type="text" class="field text" value="<?php echo $rows['conted']; ?>" size="2" maxlength="2" tabindex="9" /> / <label for="Field13-1">DD</label> </span> <span> <input id="contem" name="contem" type="text" class="field text" value="<?php echo $rows['contem']; ?>" size="2" maxlength="2" tabindex="10" /> / <label for="Field13-2">MM</label> </span> <span> <input id="contey" name="contey" type="text" class="field text" value="<?php echo $rows['contey']; ?>" size="4" maxlength="4" tabindex="11" /> <label for="Field13">YYYY</label> </span> </li> <li id="foli14" class=" "> <label class="desc" id="title14" for="Field14"> Address </label> <div class="column"> <span class="full"> <input id="suppadd1" name="suppadd1" type="text" class="field text addr" value="" tabindex="12" disabled /> <label for="Field14">Street Address</label> </span> <span class="full"> <input id="suppadd2" name="suppadd2" type="text" class="field text addr" value="" tabindex="13" disabled /> <label for="Field15">Address Line 2</label> </span> <span class="left"> <input id="suppcity" name="suppcity" type="text" class="field text addr" value="" tabindex="14" disabled /> <label for="Field16">City</label> </span> <span class="right"> <input id="suppregion" name="suppregion" type="text" class="field text addr" value="" tabindex="15" disabled /> <label for="Field17">State / Province / Region</label> </span> <span class="left"> <input id="supppostc" name="supppostc" type="text" class="field text addr" value="" tabindex="16" disabled /> <label for="Field18">Postal / Zip Code</label> </span> <span class="right"> <input id="suppcountry" name="suppcountry" type="text" class="field text addr" value="" tabindex="17" disabled /> <label for="Field19">Country</label> </span> </div> </li> <li id="foli20" class=" "> <div class="column"> <label class="desc" id="title20" for="Field20"> Cost / Cost Duration </label> <span class="symbol">£</span> <span> <input id="contcospo" name="contcospo" type="text" class="field text" value="<?php echo $rows['contcospo']; ?>" size="4" maxlength="4" tabindex="18" /> . <label for="Field20">Pounds</label> </span> <span> <input id="contcospe" name="contcospe" type="text" class="field text" value="<?php echo $rows['contcospe']; ?>" size="2" maxlength="2" tabindex="19" /> <label for="Field20-1">Pence</label> </span> <span class="right"> <select id="contcosps" name="contcosps" class="field select large" value="<?php echo $rows['contcosps']; ?>" tabindex="20"> <option value=""><?php echo $rows['contcosps']; ?> </option> <option value="Weekly" >Weekly</option> <option value="Monthly">Monthly</option> <option value="Yearly">Yearly</option> </select> <label for="Field17">Duration</label> </span> </div> </li> <li class="buttons"> <input id="saveForm" class="" type="Submit" value="Main Contracts" /> <input type="hidden" value="<?php echo $rows['contid']; ?>" name="contid" id="contid"> <input type="hidden" value="TURE" name="submitted"> </li> <li style="display:none"> <label for="comment">Do Not Fill This Out</label> <textarea name="comment" id="comment" rows="1" cols="1"></textarea> </li> </ul> </form> </div><!--container--> <img id="bottom" src="images/bottom.png" alt="" /> </body> </html>
  7. Hello, I have a HTML form that displays data from a MySQL database using PHP & JavaScript. The JavaScript is dynamically getting data into fields from the database via a dropdown menu, the value in the menu that is selected when the form is submitted is also submitted to the database, only the dropdown menu value is being submitted not the dynamic fields. I have set up a form where the data is to be viewed; however the dropdown menu needs to have someone select the data again to display the relevant information. I believe it’s to do with the dropdown menu part but I am unable to find a solution. Many Thanks Karl <?php require ("include/db_config.php"); $connection = @mysql_connect ($db_host, $db_user, $db_pass) or die ("Error with Connection"); mysql_select_db ($db_name, $connection); // Get value from address bar $contid=$_GET['contid']; // Get data from database $query = "SELECT * FROM man_contracts WHERE contid='$contid'"; $result = mysql_query ($query); $rows = mysql_fetch_array ($result); ?> <?php $vbCrLf = chr(13).chr(10); // open connection to MySQL server $connection = mysql_connect('localhost', 'root', 'pass') or die ('Unable to connect!'); //select database mysql_select_db('cmpkaspi') or die ('Unable to select database!'); //create and execute query $query = 'SELECT suppname, suppadd1, suppadd2, suppcity, suppregion, supppostc, suppcountry FROM man_suppliers ORDER BY suppname'; $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); //create selection list $DropDownList .= "<select name='suppname' id='suppname' class='field select medium' onchange='javascript:SelectChanged();'> ".$vbCrLf; $DropDownList .= "<option value=''></option> ".$vbCrLf; while($row = mysql_fetch_row($result)) { $heading = $row[0]; $DropDownList .= "<option value='$heading'>$heading</option> ".$vbCrLf; $Add1ArrayPhp .= 'Add1Array["'.$heading.'"]="'.$row[1].'";'.$vbCrLf; $Add2ArrayPhp .= 'Add2Array["'.$heading.'"]="'.$row[2].'";'.$vbCrLf; $CityArrayPhp .= 'CityArray["'.$heading.'"]="'.$row[3].'";'.$vbCrLf; $RegionArrayPhp .= 'RegionArray["'.$heading.'"]="'.$row[4].'";'.$vbCrLf; $PostCodeArrayPhp .= 'PostCodeArray["'.$heading.'"]="'.$row[5].'";'.$vbCrLf; $CountryArrayPhp .= 'CountryArray["'.$heading.'"]="'.$row[6].'";'.$vbCrLf; } $DropDownList .= "</select> ".$vbCrLf; ?> <html> <head> <script language="Javascript" type="text/javascript"> var Add1Array = new Array(); <?php echo $Add1ArrayPhp; ?> var Add2Array = new Array(); <?php echo $Add2ArrayPhp; ?> var CityArray = new Array(); <?php echo $CityArrayPhp; ?> var RegionArray = new Array(); <?php echo $RegionArrayPhp; ?> var PostCodeArray = new Array(); <?php echo $PostCodeArrayPhp; ?> var CountryArray = new Array(); <?php echo $CountryArrayPhp; ?> function SelectChanged() { var Company = document.getElementById('suppname').value; document.getElementById('suppadd1').value = Add1Array[Company]; document.getElementById('suppadd2').value = Add2Array[Company]; document.getElementById('suppcity').value = CityArray[Company]; document.getElementById('suppregion').value = RegionArray[Company]; document.getElementById('supppostc').value = PostCodeArray[Company]; document.getElementById('suppcountry').value = CountryArray[Company]; } </script> </head> <body id="public"> <img id="top" src="images/top.png" alt="" /> <div id="container"> <form id="contracts" name="contracts" class="" autocomplete="off" enctype="multipart/form-data" method="post" action="contract_view.php"> <div class="info"> <h2>Contract Details</h2> <div></div> </div> <ul> <li id="foli1" class=" "> <label class="desc" id="title1" for="Field1"> Contract Name <span id="req_1" class="req">*</span> </label> <div> <input id="contname" name="contname" type="text" class="field text large" value="<?php echo $rows['contname']; ?>" maxlength="255" tabindex="1" /> </div> </li> <li id="foli3" class=" "> <label class="desc" id="title3" for="Field3"> Supplier Name <span id="req_3" class="req">*</span> </label> <div> <?php echo $DropDownList; ?> </div> </li>
  8. Hello kickstart, Thank you for the code it works great exactly what I was thinking of. I do have a auto id field called "conid", I have had a play around trying to include the auto id field in the code so that duplicates wont only display the first record it comes to. If I understand I would have to make users select the company name by id number and not by name, on my tests its only displayed the id number not the name and then duplicates have worked how would have make this work with the names nor just the id number? I don’t think I will allow duplicates, but if I did what to what would I need to change in the code to be able to do so? Also the code gives these messages; But the code still works I have just suppressed the notice messages, any idea why these might be popping up? Many Thanks for your help; I thought this was going to be a lost battle. Thanks again Karl
  9. Here is an exmple, the dropdown menu is working but when data is selected from the dropdown menu the data is not showing up in the form. Any ideas? Here is the code <html> <head> <title>DropDown</title> </head> <body> <form name="events" method="post" action="<?= $_SERVER['PHP_SELF']?>"> <table> <tr> <td> </td> <td> <?php // open connection to MySQL server $connection = mysql_connect('localhost', 'root', 'pass') or die ('Unable to connect!'); //select database mysql_select_db('db') or die ('Unable to select database!'); //create and execute query $query = 'SELECT company FROM man_contacts ORDER BY company'; $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); //create selection list echo "<select name='Company'>\n"; while($row = mysql_fetch_row($result)) { $heading = $row[0]; echo "<option value='$heading'>$heading\n"; } echo "</select>" ?> </td> </tr> <tr> <td align="right" valign="top"><p>First Name:</p></td> <td> <input type="text" name="first" id="first" class="heading" value="<?php echo $row['first']; ?>"> </td> </tr> <tr> <td align="right" valign="top"><p>Email:</p></td> <td> <input type="text" name="email" id="email" class="date"value="<?php echo $row['email']; ?>"> </td> </tr> <tr> <td align="right" valign="top"><p>Company:</p></td> <td> <textarea name="company" id="company" class="details"value="<?php echo $row['details']; ?>"></textarea> </td> </tr> <tr> <td> </td> <td> <input name="submit" type="submit" class="submitForm" value="Submit"> </td> </tr> </table> </form> </body> </html> Many Thanks Karl
  10. Hello, I am trying to create a dropdown menu list that has a column of data from a table in MySQL that is the first step. The next which I think is a bit harder, when a user selects the data from the dropdown menu / list I would like a number of fields to be populated from the from the table data that the dropdown menu comes from. Then I would like to submit the data that was not entered into the form by the drop down menu to another table. Is there any help that any one can give or point me in the direction of, I have tried to search on Google but not found anything. Many Thanks Karl
  11. Thank you for the response. I tried the code, what happens is because of the; header ('Location: contact_view.php'); exit; The code is redirected straight away, and if i take out the header then the form is not displayed, but if I take out the exit the form is displayed but all the error messages are also displayed, this is with the code above. All the PHP and HTML code in on the same page. Thanks Karl
  12. Hello again, I have been working on a form, the form is finished that it enters data into the database, but am looking to include some basic validation. So in nothing is entered a message is shown on screen saying that it was missed off, I was able to put a very basic validation on but no message informing the user. Am hoping you are able to see a easy solution or could point me in the right direction. Here is my PHP code; <?php require ($_SERVER['DOCUMENT_ROOT']."cmstesting/config/db_config.php"); $connection = @mysql_connect ($db_host, $db_user, $db_pass) or die ("Error with Connection"); mysql_select_db ($db_name, $connection); $first1 = $_POST["first"]; $len = strlen($first1); if ($len > 0) { $title1 = $_POST["title"]; $last1 = $_POST["last"]; $suffix1 = $_POST["suffix"]; $company1 = $_POST["company"]; $address11 = $_POST["address1"]; $address21 = $_POST["address2"]; $city1 = $_POST["city"]; $town1 = $_POST["town"]; $country1 = $_POST["country"]; $postcode1 = $_POST["postcode"]; $website1 = $_POST["website"]; $email1 = $_POST["email"]; $hp11 = $_POST["hp1"]; $hp21 = $_POST["hp2"]; $hp31 = $_POST["hp3"]; $mp11 = $_POST["mp1"]; $mp21 = $_POST["mp2"]; $mp31 = $_POST["mp3"]; $notes1 = $_POST["notes"]; $query = "INSERT INTO contacts (conid, title, first, last, suffix, company, address1, address2, city, town, country, postcode, website, email, hp1, hp2, hp3, mp1, mp2, mp3, notes) VALUES (NULL, '$title1', '$first1', '$last1', '$suffix1', '$company1', '$address11', '$address21', '$city1', '$town1', '$country1', '$postcode1', '$website1', '$email1', '$hp11', '$hp21', '$hp31', '$mp11', '$mp21', '$mp31', '$notes1')"; mysql_query($query, $connection) or die("MySQL Query Error"); header ('Location: contact_view.php'); exit; } ?> Here is my Form, this is only part of it; <html> <body> <form id="contact" name="contact" class="" autocomplete="off" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <div class="info"> <h2>New Contact</h2> <div></div> </div> <ul> <li id="foli0" class=" "> <label class="desc" id="title0" for="Field0"> Name </label> <span> <input id="title" name="title" type="text" class="field text" value="" size="2" tabindex="1" /> <label for="Field0">Title</label> </span> <span> <input id="first" name="first" type="text" class="field text" value="" size="8" tabindex="2" /> <label for="Field1">First</label> </span> <span> <input id="last" name="last" type="text" class="field text" value="" size="12" tabindex="3" /> <label for="Field2">Last</label> </span> <li class="buttons"> <input id="saveForm" class="btTxt" type="submit" value="Submit" /> </li> </body> </html> I have tryed to do something simple like this, but before I even submit the page the error is displayed; <?php if (! strlen($_POST['flavor'])) { print 'You must enter your favorite ice cream flavor.'; } ?> Thanks for any help Karl
  13. Hello, I have a from and I have been able to set it up so the list/menu adds and updates the data in the database, but it always shows the menu as blank on the edit page. How would I go about getting the current record in the database to be shown in that list menu when I come to edit it? Here is the List/Menu Code HTML; <select id="country" name="country" class="field select addr" tabindex="11" value="<?php echo $rows['country']; ?>"> <option value="" selected="selected"></option> <option value="United Kingdom">United Kingdom</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Belgium">Belgium</option> <option value="China">China</option> <option value="Egypt">Egypt</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="Germany">Germany</option> <option value="Greece">Greece</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Ireland">Ireland</option> <option value="Italy">Italy</option> <option value="Norway">Norway</option> <option value="Poland">Poland</option> <option value="Russia">Russia</option> <option value="United States">United States</option> </select> An here is the PHP code that is on the page; <?php require ($_SERVER['DOCUMENT_ROOT']."cmstesting/config/db_config.php"); $connection = @mysql_connect ($db_host, $db_user, $db_pass) or die ("Error with Connection"); mysql_select_db ($db_name, $connection); // Get value from address bar $conid=$_GET['conid']; // Get data from database $query = "SELECT * FROM contacts WHERE conid='$conid'"; $result = mysql_query ($query); $rows = mysql_fetch_array ($result); ?> Many Thanks for any help... Karl
  14. I found a solution, it did not use PHP but I thought I would post it anyway. <?php if ($result) { // Successful popup message, redirected back to view contacts echo "<script type='text/javascript'>alert('Successful - Record Updated!'); window.location.href = 'contact_view.php';</script>"; } else { // Unsuccessful popup message, redirected back to view contacts echo "<script type='text/javascript'>alert('Unsuccessful - ERROR!'); window.location.href = 'contact_view.php';</script>"; } ?> Thanks for the replies Karl
  15. Thanks for that, the page now redirects to the page... Is there away to have a popup message popup, then continue on to the page... <?php if ($result) { // echo "Successful"; // echo "<BR>"; // echo "<a href='contact_view.php'>View</a>"; echo "<script type='text/javascript'>alert('Successful')</script>"; header("Location: http://localhost/cmstesting/contact_view.php"); } else { echo "ERROR"; } ?> I have included; echo "<script type='text/javascript'>alert('Successful')</script>"; Is there away to execute this code then the header code after this has been OK... Many Thanks Karl
×
×
  • 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.