
Dan06
Members-
Posts
103 -
Joined
-
Last visited
Never
Everything posted by Dan06
-
Thanks for the tip on using CSS sprites. I've put together the code for it, but unfortunately does not work as I'd like it to. I'm able to get the top border, the left border, and content, to show correctly but am not able to get the right border, bottom border to show correctly. Also, I don't know how to get the left and right border to adjust based on the length of the content. If anyone has any suggestions or ideas, let me know. Thanks! Below is the css and html code: .topLeftBorder, .topCenterRightBorder, .bottomLeftBorder, .bottomCenterRightBorder, .leftBorder, .rightBorder{ background: url(Images/bg_byn_box_1000x1000.gif) no-repeat; } .topLeftBorder{ background-position: 0 0; width: 10px; height: 39px; position: absolute; top: 0px; left: 0px; } .topCenterRightBorder{ background-position: -700px 0; max-width: 500px; min-width: 300px; height: 39px; text-align: center; position: absolute; top: 0px; left: 10px; } .leftBorder{ background-position: 0 -39px; width: 10px; min-height: 50px; max-height: 966px; position: absolute; top: 39px; left: 0px; } .containerContent{ background: transparent; position: absolute; top: 39px; left: 10px; width: auto; height: auto; margin: 10px 10px 10px 10px; } .rightBorder{ background-position: -990px -39px; width: 10px min-height: 50px; max-height: 966px; position: absolute; top: 39px; right: 0px; } .bottomleftBorder{ background-position: bottom left; width: 10px; height: 39px; position: absolute; left: 0px; bottom: 100%; } .bottomCenterRightBorder{ background-position: bottom right; min-width: 400px; max-width: 500px; height: 39px; position: absolute; left: 10px; bottom: 100%; } <div class="topLeftBorder"></div> <div class="topCenterRightBorder">Title for "AdditionalLocations" Goes Here.</div> <div class="leftBorder"></div> <div class="containerContent">Testing 1,2,3...</div> <div class="rightBorder"></div> <div class="bottomLeftBorder"></div> <div class="bottomCenterRightBorder"></div>
-
I'm trying to create a content container - like the ones found on linkedin and the yellowpages. Ideally, I'd like to do this with one background image, rather than having multiple images for each section and then combining the images to form the container. Is there a way to do that? Do give you a better idea of what I mean by content container I've attached the image I'd like to use. The title of the content goes in the top green portion and the actual content goes in the white portion. Any thoughts/ideas? Thanks. [attachment deleted by admin]
-
Thanks for the help. I was able to get my code to work. I separated the code in two files and I adjusted the js script by defining the url variable (I set it to the php file) and set document.getElementById("targetDiv").innerHTML = XMLHTTPRequestObject.responseText. By making these changes I was able to get the content to display, as formatted in a table (in the HTML file).
-
Thanks. I did not know that the php code needed to be in a different file - I thought that since HTML could be in the same file, so could php. As for the dataSource variable - that is where I'm confused. As I understand it, in AJAX when using the GET method and a text file, I would use the dataSource variable to hold the text file name and then use the .responseText method to retrieve the information from the text file. But I don't understand if or how I would use the dataSource variable with the POST method.
-
I'm trying to learn AJAX. I've gone through a few tutorials and books, and I want to practice/implement what I've learned. To that end, I created a simple php file that connects to a MySQL database and displays the stored content (which is made up superheros). I'm now trying to use AJAX techniques to have the content displayed when a button is clicked. I've put together some code, but am confused/lost as to what I should do next to make the code work. If anyone can tell me what I've done right, wrong, and the next steps it would be appreciated. Below is the code so far: <html> <head> <title>Heros!</title> <script type="text/javascript" src="ajaxgold.js"></script> <script language="javascript"> function getData(dataSource){ var XMLHttpRequestObject = false; if (window.XMLHttpRequest){ XMLHttpRequestObject = new XMLHttpRequest(); } else if (window.ActiveXObject){ XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp"); } if(XMLHttpRequestObject){ XMLHttpRequestObject.open("POST", url, true); XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); XMLHttpRequestObject.onreadystatechange = function(){ if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200){ callback(XMLHttpRequestObject.responseText); delete XMLHttpRequestObject; XMLHttpRequestObject = null; } } XMLHttpRequestObject.send(null); } } </script> </head> <center><h1>Heros!</h1></center> <body> <center> <input type="button" name="viewHeros" id="viewHeros" value="View Heros" onClick="getData()"> </center> <script language = "php"> //make db connection $conn = mysql_connect("localhost", "username", "password"); if (!$conn){ print "Unable to connect to the database"; exit(); } mysql_select_db("database", $conn); //create query $sql = "SELECT * FROM heroinfo"; $result = mysql_query($sql, $conn); print "<center><table border = 1> \n"; //get field names print "<tr>\n"; while ($field = mysql_fetch_field($result)){ print " <th>$field->name</th>\n"; } //end while //get row data while ($row = mysql_fetch_assoc($result)){ print "<tr>\n"; //look at each field foreach ($row as $col=>$val){ print " <td>$val</td>\n"; } //end foreach print "<tr>\n\n"; } //end while print "</table></center>\n"; </script> </body> </html>
-
I made the change to: <?php echo "<input type='checkbox'" . " name= Products[]" . " id=" . "'" . $row_ProdType['TypeName'] . "'" . " value=" . "'" . $row_ProdType['TypeName'] . "'" . "/>" ?> The update query and print_r($_POST) returns, when Computer Software and Electronics are checked: UPDATE businessprofile SET ProductListing=NULL, ServiceListing=NULL WHERE Id='m7h16v' Array ( [Products] => Array ( [0] => Computer Software [1] => Electronics ) [listingSave] => Save [submitList] => TypeSpecForm ) It's still giving me null values... could the quotes around the Products[] array be an issue? When I remove the Products[] from quotes I get an error stating: Unexpected '['
-
Yes, I want multiple values to be checked. And yes, all these values are supposed to be updated in the same place. For example, the current form as 3 checkboxs - Computer Hardware, Computer Software, Electronics. I want the user to check one of them, two of them, or all of them, and have the selections updated in the same table colum. Now as for renaming the checkboxes the same thing and adding [] that is a bit more difficult. Right now the form is created from stored data in a table. The form pulls this data and loops through $_rowProdType['TypeName'] creating checkboxs and their appropriate label. How can I rename them, if I wan the table to be dynamically created?
-
With the replaced code the update query now returns: UPDATE businessprofile SET ProductListing='Computer Software', ServiceListing=NULL WHERE Id='m7h16v'. The code works when Computer Software is selected. However, the problem is still present when I don't choose Computer Software; if I choose any other option say Electronics - the update query returns: UPDATE businessprofile SET ProductListing=NULL, ServiceListing=NULL WHERE Id='m7h16v' The form code for submit is below: <input name="ListingSave" type="submit" id="ListingSave" value="Save"/> </p> </center></p><input name="SubmitList" type="hidden" id="SubmitList" value="TypeSpecForm" /></td> </tr> </form>
-
The echo $updateSQL result, when checking computer software and electronics checkboxs, is: UPDATE businessprofile SET ProductListing=NULL, ServiceListing=NULL WHERE Id='m7h16v' The NULL values are because the GetSQLValueString function places NULL values in place of empty data or "". Which when taken inconjunction with the print_r($_POST) information means that the problem is in the update code, because the print_r($_POST) shows there are values in the $_POST array. As far as using the $_POST actual key rather than the variable key, I thought I was. Isn't the actual key based on the name/id of the input variable? And in my dynamic form that is generated by $row_ProdType['TypeName'], so I placed that in the $_POST[...]. I posted the submitting action/code in my earlier post, but here it is again: if ((isset($_POST["SubmitList"])) && ($_POST["SubmitList"] == "TypeSpecForm")) { $updateSQL = sprintf("UPDATE businessprofile SET ProductListing=%s, ServiceListing=%s WHERE Id=" . "'" . $_SESSION['Reg'] . "'", GetSQLValueString($_POST[$row_ProdType['TypeName']], "text"), GetSQLValueString($_POST[$row_ServType['TypeName']], "text")); mysql_select_db($database_dbConnection, $dbConnection); $Result1 = mysql_query($updateSQL, $dbConnection) or die("Query error in UPDATE query! Query text: $updateSQL<br>Error:" . mysql_error()); $updateGoTo = "securityregister.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); }
-
I've done the "view the source" of my page and the form elements are being built correctly each input type has a unique name and id, for example here is a part of the view - <td> <input type='checkbox' name='Computer Software' id='Computer Software' value='Computer Software'/> </td> <td>Computer Software</td> </tr> <tr> <td> <input type='checkbox' name='Electronics' id='Electronics' value='Electronics'/> </td> <td>Electronics</td> </tr> I've also done the print_r($_POST) and this is what I get: Array ( [Computer_Software] => Computer Software [Electronics] => Electronics [listingSave] => Save [submitList] => TypeSpecForm ) Computer Software and Electronics are the two selections made. Thus the $_POST array DOES contain the selected inputy variable (checkbox) at this point, but when I try to update the target table with the appropriate $_POST array values - there are no values, it is empty. I can't figure out why.
-
Did you mean - alcohol? It looks like the error is caused by misspelling.
-
My form values are not being added to the $_POST[] array, when selected, and thus the $_POST[] array is continually empty/null. Can anyone tell me why the input variables are not being added to the $_POST[] array? Here is code for my form: <table> <form action="<?php echo $editFormAction; ?>" id="TypeSpecForm" name="TypeSpecForm" method="post"> <tr> <td><div id="ProdTbl"> <p><strong>Which Type of Products?</strong></p> <table border="1" align="center"> <?php do { ?> <tr> <td> <?php echo '<input type="checkbox"' . " name=" . $row_ProdType['TypeName'] . " id=" . $row_ProdType['TypeName'] . " value=" . $row_ProdType['TypeName'] . '/>' ?> </td> <td><?php echo $row_ProdType['TypeName']; ?></td> </tr> <?php } while ($row_ProdType = mysql_fetch_assoc($ProdType)); ?> </form> </table> </div> Below is the code for updating the target table (I've already checked the GetSQLValueString function and it is working correctly): if ((isset($_POST["SubmitList"])) && ($_POST["SubmitList"] == "TypeSpecForm")) { $updateSQL = sprintf("UPDATE businessprofile SET ProductListing=%s, ServiceListing=%s WHERE Id=" . "'" . $_SESSION['Reg'] . "'", GetSQLValueString($_POST[$row_ProdType['TypeName']], "text"), GetSQLValueString($_POST[$row_ServType['TypeName']], "text")); mysql_select_db($database_dbConnection, $dbConnection); $Result1 = mysql_query($updateSQL, $dbConnection) or die("Query error in UPDATE query! Query text: $updateSQL<br>Error:" . mysql_error()); $updateGoTo = "securityregister.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); }
-
I tried the new code, but it doesn't work. There are no error messages, but it also does not update the target table. Any other thoughts or suggestions?
-
I have a form which is dynamically created from data in a table and uses the post method. The form is made of checkboxs and each checkbox is apart of an associative array. When the user selects a checkbox I would like the selected checkbox to update a target table. To do this I'm using the following code: if ((isset($_POST["SubmitList"])) && ($_POST["SubmitList"] == "TypeSpecForm")) { $updateSQL = sprintf("UPDATE businessprofile SET ProductListing=%s, ServiceType=%s WHERE Id=" . "'" . $_SESSION['Reg'] . "'", GetSQLValueString($_POST['{$row_ProdType['TypeName']}'], "text"), GetSQLValueString($_POST['{$row_ServType['TypeName']}'])); But unfortunately, I'm getting the following error: Parse error: syntax error, unexpected T_STRING, expecting ']' in D:\Apache\htdocs\listingregister.php The problem seems to be in the GetSQLValueString($_POST[...]) parts of the code. And the GetSQLValueString function adds ' ' around the $_POST value. Any ideas on how to solve this? Thanks.
-
Associative array and post method to update mysql table?
Dan06 replied to Dan06's topic in PHP Coding Help
The GetSQLValueString function puts ' ' around the values that are represented by %s in the sprintf. The hunch I have is that the way I'm using the associative array with the post method is some how wrong. Can anyone tell me if I'm using the $row_ProdType['TypeName'] & $row_ServType['TypeName'] in the update query incorrectly? Below is my update query code: if ((isset($_POST["SubmitProdList"])) && (isset($_POST["SubmitServList"])) && ($_POST["SubmitProdList"] && ($_POST["SubmitServList"]) == "ListingForm")) { $updateSQL = sprintf("UPDATE businessprofile SET ProductType=%s, ServiceType=%s WHERE Id=" . "'" . $_SESSION['Reg'] . "'", GetSQLValueString($row_ProdType['TypeName'], "text"), GetSQLValueString($row_ServType['TypeName'], "text")); Below is the code for the dynamic form: <?php do { ?> <tr> <td><form action="<?php echo $editFormAction; ?>" id="ProdTypeSelection" name="ProdTypeSelection" method="post"><input type="checkbox" name = "$row_ProdType['TypeName']" id="$row_ProdType['TypeName']" value="$row_ProdType['TypeName']"/> <input name="SubmitProdList" type="hidden" id="SubmitProdList" value="ListingForm" /> </form></td> <td><?php echo $row_ProdType['TypeName']; ?></td> </tr> <?php } while ($row_ProdType = mysql_fetch_assoc($ProdType)); ?> </table> <p> </p> </div> <div id="ServTbl"> <p><strong>What Type of Services?</strong></p> <p> </p> <table border="1" align="center"> <?php do { ?> <tr> <td><form action="<?php echo $editFormAction; ?>" id="ServTypeSelection" name="ServTypeSelection" method="post" > <input type="checkbox" name = "$row_ServType['TypeName']" id="$row_ServType['TypeName']" value="$row_ServType['TypeName']"/> <input name="SubmitServList" type="hidden" id="SubmitServList" value="ListingForm" /> </form></td> <td><?php echo $row_ServType['TypeName']; ?></td> </tr> <?php } while ($row_ServType = mysql_fetch_assoc($ServType)); ?> </table> <p> </p> </div> <center><input name="ListingSave" type="submit" id="ListingSave" value="Save" /></center></td> </tr> -
I'm trying to use information from an associative array (which is stored in a table) to update a mysql table via the post method. The code below is what I'm using: if ((isset($_POST["SubmitProList"])) && (isset($_POST["SubmitServList"])) && ($_POST["SubmitProList"] && ($_POST["SubmitServList"]) == "ListingForm")) { $updateSQL = sprintf("UPDATE businessprofile SET ProductType=%s, ServiceType=%s WHERE UtilistId=" . "'" . $_SESSION['UtilistReg'] . "'", GetSQLValueString($_POST["$row_ProdType['TypeName']"], "text"), GetSQLValueString($_POST["$row_ServType['TypeName']"], "text")); When I submit the form I get the error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Apache\htdocs\listregister.php on line 103 When I remove the $_POST method, i.e. ... GetSQLValueString($row_ProdType['TypeName'], "text"), GetSQLValueString($row_ServType['TypeName'], "text")); The form does nothing - nothing updates, no error messages, absolutely nothing changes. Anyone have a solution or suggestion to my problem? Thanks.
-
How do you create a form using data stored in table?
Dan06 replied to Dan06's topic in PHP Coding Help
I've been able to create a form that displays checkboxs and labels from data stored in a table, but I can't seem to get this dynamic form to update data in the target table. Below is the code I've put together. Anyone with ideas or suggestions on how to fix the problem of updating the target table with the dynamic form information, please let me know. Thanks. mysql_select_db($database_dbConnection, $dbConnection); $query_ProdType = "SELECT TypeName FROM producttype"; $query_limit_ProdType = sprintf("%s LIMIT %d, %d", $query_ProdType, $startRow_ProdType, $maxRows_ProdType); $ProdType = mysql_query($query_limit_ProdType, $dbConnection) or die(mysql_error()); $row_ProdType = mysql_fetch_assoc($ProdType); mysql_select_db($database_dbConnection, $dbConnection); $query_ServType = "SELECT TypeName FROM servicetype"; $query_limit_ServType = sprintf("%s LIMIT %d, %d", $query_ServType, $startRow_ServType, $maxRows_ServType); $ServType = mysql_query($query_limit_ServType, $dbConnection) or die(mysql_error()); $row_ServType = mysql_fetch_assoc($ServType); if ((isset($_POST["ListingForm"])) && ($_POST["ListingForm"] == "ListingForm")) { $updateSQL = sprintf("UPDATE businessprofile SET ProductType=%s, ServiceType=%s WHERE Id=" . "'" . $_SESSION['Reg'] . "'", GetSQLValueString($row_ProdType['TypeName'], "text"), GetSQLValueString($row_ServType['TypeName'], "text")); mysql_select_db($database_dbConnection, $dbConnection); $Result1 = mysql_query($updateSQL, $dbConnection) or die(mysql_error()); $updateGoTo = "listingregister.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } ?><!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=utf-8" /> <title>Registration</title> <table width="100%" border="1" cellspacing="0" bordercolor="#000000"> <tr> <td><div id="ProdTbl"> <p><strong>Which Type of Products?</strong></p> <p> </p> <table border="1" align="center"> <?php do { ?> <tr> <td><form action="<?php echo $editFormAction; ?>" id="ProdTypeSelection" name="ProdTypeSelection" method="post"><input type="checkbox" name = "$row_ProdType['TypeName']" id="$row_ProdType['TypeName']" value="$row_ProdType['TypeName']"/> <input name="ListingForm" type="hidden" id="ListingForm" value="ListingForm" /> </form></td> <td><?php echo $row_ProdType['TypeName']; ?></td> </tr> <?php } while ($row_ProdType = mysql_fetch_assoc($ProdType)); ?> </table> <p> </p> </div> <div id="ServTbl"> <p><strong>What Type of Services?</strong></p> <p> </p> <table border="1" align="center"> <?php do { ?> <tr> <td><form action="<?php echo $editFormAction; ?>" id="ServTypeSelection" name="ServTypeSelection" method="post" > <input type="checkbox" name = "$row_ServType['TypeName']" id="$row_ServType['TypeName']" value="$row_ServType['TypeName']"/> <input name="ListingForm" type="hidden" id="ListingForm" value="ListingForm" /> </form></td> <td><?php echo $row_ServType['TypeName']; ?></td> </tr> <?php } while ($row_ServType = mysql_fetch_assoc($ServType)); ?> </table> <p> </p> </div> <center><input name="ListingSave" type="submit" id="ListingSave" value="Save" /></center></td> </tr> </table> </div> </div> <!-- end #footer --> <!-- end #container --> </div> </body> </html> -
I would like to create a form generated on information stored in a mysql table. What I would like to do is store text (which will be used as options in a form) in a mysql table and then have a pull this information (the options) and create a form made up of checkboxs. Once the user selects one or more checkboxs the information is inserted/updated in another table (the user profile table). Retrieving the options text and displaying them is straight forward enough, but how do you convert the text into a checkbox with a label and place it in a form? Anyone have any ideas or suggestions?
-
Thanks. The <?php ?> tags were the issue. I had placed the entire block of code within the <?php ?> tags, rather then just the ob_start(); and ob_get_clean(); functions. Storing the forms in the variables allowed me to use the if/then statements and div tags to create the conditional form. But is there a better or more efficient way of creating conditional forms based on previous form selections? If anyone knows or has any suggestions please share them; I'd be interested in reading them.
-
I tried using ob_start(); and ob_get_clean(); but when I do I get the following error: Parse error: syntax error, unexpected '<' in D:\Apache\htdocs\profileregister.php on line 47 Here is the code: ob_start(); <form action="<?php echo $editFormAction; ?>" method="post" name="busProForm" id="busProForm"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Company Name:</td> <td><input type="text" name="CompanyName" value="<?php echo htmlentities($row_profileRegister['CompanyName'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Telephone Number:</td> <td><input type="text" name="TelNumber" value="<?php echo htmlentities($row_profileRegister['TelNumber'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Street:</td> <td><input type="text" name="Street" value="<?php echo htmlentities($row_profileRegister['Street'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Street 2:</td> <td><input type="text" name="Street2" value="<?php echo htmlentities($row_profileRegister['Street2'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">City:</td> <td><input type="text" name="City" value="<?php echo htmlentities($row_profileRegister['City'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">State:</td> <td><input type="text" name="State" value="<?php echo htmlentities($row_profileRegister['State'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Zip:</td> <td><input type="text" name="Zip" value="<?php echo htmlentities($row_profileRegister['Zip'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Update record" /></td> </tr> </table> <input type="hidden" name="MM_update" value="busProForm" /> <input type="hidden" name="Id" value="<?php echo $row_profileRegister['Id']; ?>" /> </form> <p> </p> $busFormType = ob_get_clean(); <head>...</head>
-
I'm trying to create a conditional form. The idea is that there is one page with two forms and based on the user's previous page/form selections one of the new forms will be shown. I've figured out (in theory) that I can store the form in a variable, run an if/then statement, and then print to a selected div tag. The problem I'm having is storing the form in a variable. Following is the code for my form: <form action="<?php echo $editFormAction; ?>" method="post" name="indProForm" id="indProForm"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">City:</td> <td><input type="text" name="City" value="<?php echo htmlentities($row_profileRegister['City'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">State:</td> <td><input type="text" name="State" value="<?php echo htmlentities($row_profileRegister['State'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Zip:</td> <td><input type="text" name="Zip" value="<?php echo htmlentities($row_profileRegister['Zip'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Update record" /></td> </tr> </table> <input type="hidden" name="MM_update" value="indProForm" /> <input type="hidden" name="Id" value="<?php echo $row_profileRegister['Id']; ?>" /> </form> <p> </p> How can I store the above form in a variable? Help and insight are much appreciated.
-
Conditional Form - Using if statement and div tags
Dan06 replied to Dan06's topic in PHP Coding Help
I've used exactly that type of code and unfortunately, it's not working - both forms are still being shown. <?php if($_SESSION['JoinSelection'] == "Individual"){ echo "<div id=individualProfile>"; }?> Any ideas why both forms are still being shown? -
I've put two forms on one page, and I want to display one of them based on the user's previous page selection. My idea was to use an if statement and based on that print a particular div id. I know that in javascript I could use the .getElementById method to print a selected div id. But how would I print a particular div id in php? Below is the code I've put together so far: <?php if($_SESSION['JoinSession'] == "Business"){ echo "div id='businessprofile'"; }?> <div id = "businessprofile"> <form action="<?php echo $editFormAction; ?>" method="post" name="busProForm" id="busProForm"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Company Name:</td> <td><input type="text" name="CompanyName" value="<?php echo htmlentities($row_profileRegister['CompanyName'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Telephone Number:</td> <td><input type="text" name="TelNumber" value="<?php echo htmlentities($row_profileRegister['TelNumber'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Street:</td> <td><input type="text" name="Street" value="<?php echo htmlentities($row_profileRegister['Street'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Street 2:</td> <td><input type="text" name="Street2" value="<?php echo htmlentities($row_profileRegister['Street2'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">City:</td> <td><input type="text" name="City" value="<?php echo htmlentities($row_profileRegister['City'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">State:</td> <td><input type="text" name="State" value="<?php echo htmlentities($row_profileRegister['State'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Zip:</td> <td><input type="text" name="Zip" value="<?php echo htmlentities($row_profileRegister['Zip'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Update record" /></td> </tr> </table> <input type="hidden" name="MM_update" value="busProForm" /> <input type="hidden" name="Id" value="<?php echo $row_profileRegister['Id']; ?>" /> </form> </div> <p> </p>
-
PHP/MySQL error - cannot update table through form
Dan06 replied to Dan06's topic in PHP Coding Help
The extra comma was the problem! Ah, I completely missed that... Thanks for the help, I appreciate it; you saved me from going insane. -
PHP/MySQL error - cannot update table through form
Dan06 replied to Dan06's topic in PHP Coding Help
The error message is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE Id=' at line 1 As for single quotes, I've used this very type of code which uses double quotes, i.e. "INSERT INTO registration (Id, FirstName, LastName, Email, Password) VALUES (%s, %s, %s, %s, %s)", GetSQLValueString($_POST['Id'],"text"), GetSQLValueString($_POST['FirstName'], "text"), GetSQLValueString($_POST['LastName'], "text"), GetSQLValueString($_POST['Email'], "text"), GetSQLValueString($_POST['Password'], "text")); for inserting records and there were no problem with that code. Why do you think that is?