Jump to content

nelquintin

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Everything posted by nelquintin

  1. I can get files to upload to folder and add a new row for each in to a mysql db using the code below, how do I get all the filles in one row with multiple uploads //Check if the form was submitted. if(isset($_POST['uploadButton'])) { //Specify folder path where the file is going. $path = 'uploads/'; //Upload file one by one. foreach($_FILES['file']['name'] as $key => $val) { if($val != '') { $file_name = $_FILES['file']['name'][$key]; //Get file name. $file_tmp = $_FILES['file']['tmp_name'][$key]; //Get temporary file name. $file = $path . $file_name; mysql_query("INSERT INTO images (img1) VALUES('$file');") or trigger_error('Unable to INsert: ' . mysql_error()); //Move uploaded file if(move_uploaded_file($file_tmp, $file)) { echo 'File was succesfully uploaded to: ' . $file . '<br />'; } else { //Display error message if there was a problem uploading file. echo 'Error uploading file "' . $key . '."<br />'; } echo $target_path; } } } ?>
  2. sorry to be stupid if i put it in double quotes i get a parse error how do i escape?
  3. How can i display a array in a form? in the example below if i print "$path1"; it show the path. how do i insert this path in to the form? print '<form method="post" action="test2.php"> <input type="text" name="$path1"/><br/><br/> <input type="text" name="$path2"/><br/><br/> <input type="text" name="$path3"/><br/><br/> <input type="submit" name="submit"/> </form> '; print "$path1";
  4. ive tried this now? any ideas please <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="test.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td><strong>Property Upload </strong></td> </tr> <tr> <td> Price: <input name="price" type="text" id="price"></td> </tr> <tr> <td>Description: <input name="description" type="text" id="description"></td> </tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td align="center"><input type="submit" name="submit" value="sumbit" /></td> </tr> </table> </td> </form> </tr> </table> <?php // Get the PHP file containing the DbConnector class require_once('../includes/DbConnector.php'); require_once('../includes/Validator.php'); // Create an instance of DbConnector $connector = new DbConnector(); // Check whether a form has been submitted. If so, carry on if ($_POST){ // Validate the entries $validator = new Validator(); $validator->validateTextOnly($_POST['price'],'Price'); $validator->validateTextOnly($_POST['description'],'Description'); //set where you want to store files //in this example we keep file in folder upload //$_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path1= "images/".$_FILES['ufile']['name'][0]; $path2= "images/".$_FILES['ufile']['name'][1]; $path3= "images/".$_FILES['ufile']['name'][2]; //copy file to where you want to store file copy($_FILES['ufile']['tmp_name'][0], $path1); copy($_FILES['ufile']['tmp_name'][1], $path2); copy($_FILES['ufile']['tmp_name'][2], $path3); // Check whether the validator found any problems if ( $validator->foundErrors() ){ echo 'There was a problem with: <br>'.$validator->listErrors('<br>'); // Show the errors, with a line between each }else{ // Create an SQL query (MySQL version) // The 'addslashes' command is used 5 lines below for added security // Remember to use 'stripslashes' later to remove them (they are inserted in front of any // special characters //"SELECT * FROM `properties` WHERE `id` = '1'" $insertQuery = "INSERT INTO `properties` (`price`, `description`, `path1`, `path2`, `path3`) VALUES ('{$_POST['price']}' , '{$_POST['description']}' , '{$_POST['path1']}' , '{$_POST['path2']}' , '{$_POST['path3']}' ,)"; // Save the form data into the database if ($result = $connector->query($insertQuery)){ // It worked, give confirmation echo '<center><b>Property added to the database</b></center><br>'; }else{ // It hasn't worked so stop. Better error handling code would be good here! exit('<center>Sorry, there was an error saving to the database</center>'); } } } ?> </body> </html>
  5. I have a upload script that save images in an image folder. What I would like to do is pass the path in to another php page and then insert the image path into the database so as to link text and images together. below is the code... <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td><strong>Images Upload </strong></td> </tr> <tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Select file <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td align="center"><input type="submit" name="submit" value="sumbit" /></td> </tr> </table> </td> </form> </tr> </table> <?php //set where you want to store files //in this example we keep file in folder upload //$_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path1= "images/".$_FILES['ufile']['name'][0]; $path2= "images/".$_FILES['ufile']['name'][1]; $path3= "images/".$_FILES['ufile']['name'][2]; //copy file to where you want to store file copy($_FILES['ufile']['tmp_name'][0], $path1); copy($_FILES['ufile']['tmp_name'][1], $path2); copy($_FILES['ufile']['tmp_name'][2], $path3); //$_FILES['ufile']['name'] = file name //$_FILES['ufile']['size'] = file size //$_FILES['ufile']['type'] = type of file echo "File Name :".$_FILES['ufile']['name'][0]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][0]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][0]."<BR/>"; echo "<img src=\"$path1\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$_FILES['ufile']['name'][1]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][1]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][1]."<BR/>"; echo "<img src=\"$path2\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$_FILES['ufile']['name'][2]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][2]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][2]."<BR/>"; echo "<img src=\"$path3\" width=\"150\" height=\"150\">"; /////////////////////////////////////////////////////// // Use this code to display the error or success. $filesize1=$_FILES['ufile']['size'][0]; $filesize2=$_FILES['ufile']['size'][1]; $filesize3=$_FILES['ufile']['size'][2]; if($filesize1 && $filesize2 && $filesize3 != 0) { echo "Uploaded"; } else { echo "ERROR....."; } ////////////////////////////////////////////// // What files that have a problem? (if found) if($filesize1==0) { echo "There're something error in your first file"; echo "<BR />"; } if($filesize2==0) { echo "There're something error in your second file"; echo "<BR />"; } if($filesize3==0) { echo "There're something error in your third file"; echo "<BR />"; } ?> <html> <head> <title>Add an Property</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <?php // Get the PHP file containing the DbConnector class require_once('../includes/DbConnector.php'); require_once('../includes/Validator.php'); // Create an instance of DbConnector $connector = new DbConnector(); // Check whether a form has been submitted. If so, carry on if ($_POST){ // Validate the entries $validator = new Validator(); $validator->validateTextOnly($_POST['price'],'Price'); $validator->validateTextOnly($_POST['description'],'Description'); // Check whether the validator found any problems if ( $validator->foundErrors() ){ echo 'There was a problem with: <br>'.$validator->listErrors('<br>'); // Show the errors, with a line between each }else{ // Create an SQL query (MySQL version) // The 'addslashes' command is used 5 lines below for added security // Remember to use 'stripslashes' later to remove them (they are inserted in front of any // special characters //"SELECT * FROM `properties` WHERE `id` = '1'" $insertQuery = "INSERT INTO `properties` (`price`, `description`, `imagepath`) VALUES ('{$_POST['price']}' , '{$_POST['description']}' , '{$_POST['imagepath']}')"; // Save the form data into the database if ($result = $connector->query($insertQuery)){ // It worked, give confirmation echo '<center><b>Property added to the database</b></center><br>'; }else{ // It hasn't worked so stop. Better error handling code would be good here! exit('<center>Sorry, there was an error saving to the database</center>'); } } } ?> <body> <form name="form1" method="post" action="newproperty.php"> <p> Price: <input name="price" type="text" id="price"> </p> <p> Description: <input name="description" type="text" id="description"> </p> <a href="upload.php">Add pictures</a> </p> <p align="center"> <input type="submit" name="Submit" value="Submit"> </p> </form> </body> </html>
  6. here is all the code including mysql_query and yes i can echo the varibles. <?php require_once('includes/config.php'); ?> <?php include('includes/sc-includes.php'); $pagetitle = Property; $update = 0; if (isset($_GET['property_id'])) { $update = 1; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } // if ($update==1) { mysql_select_db($database_contacts, $contacts); $query_property = "SELECT * FROM property WHERE property_id = ".$_GET['property_id'].""; $contacts = mysql_query($query_property, $contacts) or die(mysql_error()); $row_property = mysql_fetch_assoc($contacts); $totalRows_property = mysql_num_rows($contacts); } // //UPLOAD PICTURE $picture = $_POST['image_location']; $time = substr(time(),0,5); if($HTTP_POST_FILES['image'] && $HTTP_POST_FILES['image']['size'] > 0){ $ori_name = $_FILES['image']['name']; $ori_name = $time.$ori_name; $tmp_name = $_FILES['image']['tmp_name']; $src = imagecreatefromjpeg($tmp_name); list($width,$height)=getimagesize($tmp_name); $newwidth=95; $newheight=($height/$width)*95; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = "images/". $ori_name; imagejpeg($tmp,$filename,100); $picture = $ori_name; imagedestroy($src); imagedestroy($tmp); } //END UPLOAD PICTURE if ($update==0) { if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO property(property_image, property_type, property_price, property_area, property_ref, property_header, property_option, property_info, property_status) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($picture, "text"), GetSQLValueString(trim($_POST['property_type']), "text"), GetSQLValueString(trim($_POST['property_price']), "text"), GetSQLValueString(trim($_POST['property_area']), "text"), GetSQLValueString(trim($_POST['property_ref']), "text"), GetSQLValueString(trim($_POST['property_header']), "text"), GetSQLValueString(trim($_POST['property_option']), "text"), GetSQLValueString(trim($_POST['property_info']), "text"), GetSQLValueString($_POST['property_status'], "text")); mysql_select_db($database_contacts, $contacts); $Result1 = mysql_query($insertSQL, $contacts) or die(mysql_error()); set_msg('Property Added'); $cid = mysql_insert_id(); $redirect = "property-details.php?id=$cid"; header(sprintf('Location: %s', $redirect)); die; } } if ($update==1) { if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE property SET property_type=%s, property_price=%s, property_area=%s, property_ref=%s, property_header=%s, property_option=%s, property_info=%s, property_status=%s WHERE property_id= %s", GetSQLValueString($picture, "text"), GetSQLValueString(trim($_POST['property_type']), "text"), GetSQLValueString(trim($_POST['property_price']), "text"), GetSQLValueString(trim($_POST['property_area']), "text"), GetSQLValueString(trim($_POST['property_ref']), "text"), GetSQLValueString(trim($_POST['property_header']), "text"), GetSQLValueString(trim($_POST['property_option']), "text"), GetSQLValueString(trim($_POST['property_info']), "text"), GetSQLValueString(trim($_POST['property_status']), "text"), GetSQLValueString(trim($_POST['property_id']), "int")); $contacts = mysql_connect($hostname_contacts, $username_contacts, $password_contacts) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database_contacts, $contacts)or trigger_error(mysql_error(),E_USER_ERROR); $Result1 = mysql_query($updateSQL, $contacts) or die(mysql_error()); set_msg('Property Updated'); $cid = $_GET['property_id']; $redirect = "properties.php?id=$cid"; header(sprintf('Location: %s', $redirect)); die; } } ?> <!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><?php if ($update==0) { echo "Add Property"; } ?><?php echo $row_property['property_ref']; ?> <?php echo $row_address['property_address']; ?></title> <script src="includes/lib/prototype.js" type="text/javascript"></script> <script src="includes/src/effects.js" type="text/javascript"></script> <script src="includes/validation.js" type="text/javascript"></script> <script src="includes/src/scriptaculous.js" type="text/javascript"></script> <script language="javascript"> function toggleLayer(whichLayer) { if (document.getElementById) { // this is the way the standards work var style2 = document.getElementById(whichLayer).style; style2.display = style2.display? "":"block"; } else if (document.all) { // this is the way old msie versions work var style2 = document.all[whichLayer].style; style2.display = style2.display? "":"block"; } else if (document.layers) { // this is the way nn4 works var style2 = document.layers[whichLayer].style; style2.display = style2.display? "":"block"; } } </script> <link href="includes/style.css" rel="stylesheet" type="text/css" /> <link href="includes/simplecustomer.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include('includes/header.php'); ?> <div class="container"> <div class="leftcolumn"> <h2><?php if ($update==1) { echo Update; } else { echo Add; } ?> Property </h2> <p> </p> <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Image<br /> <input name="image" type="file" id="image" /><?php if ($row_property['property_image']) { ?> <br /> <img src="images/<?php echo $row_property['property_image']; ?>" width="95" /> <?php } ?> </td> </tr> <td>Price<br /> <input name="property_price" type="text" id="property_price" value="<?php echo $row_property['property_price']; ?>" size="35" /></td> </tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="39%">Property option<br /> <select name="property_option" id="property_option" value="<?php echo $row_property['property_option']; ?>" size="1" /> <option selected="selected">Select</option> <option value="Sale">For Sale</option> <option value="Rent">To Let</option> </select> <td width="34%">Type of property<br /> <select name="property_type" id="property_type" value="<?php echo $row_property['property_type']; ?>" size="1" /> <option selected="selected">Select</option> <option value="Residential">Residential</option> <option value="Commercial">Commercial</option> <option value="Land">Land</option> </select> </tr> </table></td> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="39%">Area<br /> <select name="property_area" id="property_area" value="<?php echo $row_property['property_area']; ?>" size="1" /> <option selected="selected">Select</option> <option value="Brackenfell">Brackenfell</option> <option value="Blouberg surround">Blouberg surround</option> <option value="Cape Town CBD">Cape Town CBD</option> <option value="Durbanville">Durbanville</option> <option value="Goodwood">Goodwood</option> <option value="Killarney Gardens">Killarney Gardens</option> <option value="Maitland">Maitland</option> <option value="Montague Gardens">Montague Gardens</option> <option value="Ndabeni">Ndabeni</option> <option value="Paarden Eiland">Paarden Eiland</option> <option value="Paarl">Paarl</option> <option value="Racing Park">Racing Park</option> <option value="Sommerset West">Sommerset West</option> <option value="Stellenbosch">Stellenbosch</option> <option value="Tygerberg">Tygerberg</option> </select> <td width="34%">Reference<br /> <input name="property_ref" type="text" id="property_ref" value="<?php echo $row_property['property_ref']?>" size="10" /></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100%">Header<br /> <input name="property_header" type="text" id="property_header" value="<?php echo $row_property['property_header'];?>" size="50" /></td> </tr> </table></td> </tr> <tr> <td>Additional Infomation<br /> <textarea name="property_info" cols="60" rows="3" id="property_info"><?php echo $row_property['property_info'];?></textarea></td> </tr> <tr> <td>Status<br /> <select name="property_status" id="property_status" value="<?php echo $row_property['property_status']; ?>" size="1" /> <option selected="selected">Select</option> <option value="Online">Online</option> <option value="Offline">Offline</option> </select> </tr> </table> <p> </p></td> </tr> <tr> <td colspan="2"><p> <input type="submit" name="Submit2" value="<?php if ($update==1) { echo Update; } else { echo Add; } ?> property" /> <input type="hidden" name="MM_insert" value="form1" /> <input name="property_id" type="hidden" id="property_id" value="<?php echo $row_property['property_id']; ?>" /> <input name="image_location" type="hidden" id="image_location" value="<?php echo $row_property['property_image']; ?>" /> </p></td> </tr> </table> <p> </p> <input type="hidden" name="MM_update" value="form1"> </form> </div> <?php include('includes/right-column.php'); ?> <br clear="all" /> </div> <?php include('includes/footer.php'); ?> </body> </html>
  7. this wont update and there no error messages. please help. if ($update==1) { if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE property SET property_type=%s, property_price=%s, property_area=%s, property_ref=%s, property_header=%s, property_option=%s, property_info=%s, property_status=%s WHERE property_id= %s", GetSQLValueString($picture, "text"), GetSQLValueString(trim($_POST['property_type']), "text"), GetSQLValueString(trim($_POST['property_price']), "text"), GetSQLValueString(trim($_POST['property_area']), "text"), GetSQLValueString(trim($_POST['property_ref']), "text"), GetSQLValueString(trim($_POST['property_header']), "text"), GetSQLValueString(trim($_POST['property_option']), "text"), GetSQLValueString(trim($_POST['property_info']), "text"), GetSQLValueString(trim($_POST['property_status']), "text"), GetSQLValueString(trim($_POST['property_id']), "int")); $contacts = mysql_connect($hostname_contacts, $username_contacts, $password_contacts) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database_contacts, $contacts)or trigger_error(mysql_error(),E_USER_ERROR); set_msg('Property Updated'); $cid = $_GET['property_id']; $redirect = "properties.php?id=$cid"; header(sprintf('Location: %s', $redirect)); die; } }
  8. // some code $link= $query = "SELECT * FROM `customers` WHERE `price_min` <= '" . $_POST['price'] . "' AND `price_max` >= '" . $_POST['price'] . "'"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); echo "<table>\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n"; } echo "</table>\n"; mysql_free_result($result); mysql_close($link); ?> sql dump: /*!40000 ALTER TABLE `customers` DISABLE KEYS */; INSERT INTO `contacts` (`username`,`price_max`,`price_min`) VALUES ('quintin','100','10'); /*!40000 ALTER TABLE `customers` ENABLE KEYS */; this returns nothing why??
  9. thanks ive tried $query = "SELECT * FROM customers WHERE price_min < '".$_POST['price']."' AND price_max > '".$_POST['price']."'"; this returns nothing
  10. ive tried this $query = "SELECT * FROM customers WHERE '".$_POST['minprice']."' AND '".$_POST['maxprice']."' LIKE '".$_POST['price']."' "; nothing
  11. that code is perfect when i am matching customer to the product. what i would like to do is match the product to the client. so for example if a book cost $20 i want to pull all the customer that have $20 in their price range.
  12. i use this line to match customer with product $query = "SELECT * FROM product WHERE price BETWEEN '".$_POST['minprice']."' AND '".$_POST['maxprice']."'"; $result = mysql_query($query); how can i match the product with customer? Bearing in mind the customer has a min range and a max range and product a set price.
  13. why wont this update the database? <? include("include/session.php"); ?> <? $propertyid=$_GET['propertyid']; $query=" SELECT * FROM propertys WHERE propertyid='$propertyid'"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $picture=mysql_result($result,$i,"picture"); $price=mysql_result($result,$i,"price"); .... $username=mysql_result($result,$i,"username"); ?> <form action="propertys_change_record.php" method="post"> <input type="hidden" name="ud_propertyid" value="<? echo "$propertyid" ?>"><br> Image:<br> <input type="File" name="ud_picture" size="<? print "$picture"?>"><br> Price:<br> <input type="text" name="ud_price" value="<? print "$price"?>"><br> ....... Username:<br> <input type="text" name="ud_username" value="<? print "$username"?>"></br> <br><input type="Submit" value="Update"> </form> <? ++$i; } ?> and... <? include("include/session.php"); ?> <?php $ud_propertyid=$_POST['ud_propertyid']; $ud_picture=$_POST['ud_picture']; ... $ud_username=$_POST['ud_username']; mysql_query(" UPDATE propertys SET picture='$ud_picture' ,price='$ud_price' ,ref='$ud_ref' ,type='$ud_type' ,erf='$ud_erf' ,description='$ud_description' ,bed='$ud_bed' ,bath='$ud_bath' ,gar='$ud_gar' ,username='$ud_username' WHERE propertyid='$ud_propertyid'"); echo "Record Updated"; ?> <br> <a href="main.php">Back to main page</a> </body> </html> <? ++$i; ?>
  14. still only one result.have a look!!! <? include "config.php"; $db = mysql_connect($host,$login,$password); mysql_select_db($base,$db); if (!verifyuser() ) { header( "Location: login.php" ); } else { ?> <head> <title>Diary</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body bgcolor="#FFFFFF" topmargin="5" leftmargin="5" marginheight="5" marginwidth="5" ><center> <? if (isset($_POST["event_desc"])) { $event_desc = $_POST['event_desc']; } if (isset($_POST["submit"]) && (!isset($_POST["event_desc"]) or empty($event_desc) )) { ?> <script language="Javascript" type="text/javascript"> <!-- window.open('empty.html', '_myevent', 'HEIGHT=100,resizable=yes,WIDTH=400'); //--> </script> <? } if ( isset($_POST["submit"]) && !empty($event_desc)) { $eventyear = $_POST['eventyear']; $eventmonth = $_POST['eventmonth']; $eventdate = $_POST['eventdate']; $id = $_POST['id']; $day_in_a_mth = date('t', mktime(0, 0, 0, $eventmonth, 1, $eventyear)) ; if ($day_in_a_mth >= $eventdate ) { $fulldate = $eventyear."-".$eventmonth."-".$eventdate; $event_desc = $_POST['event_desc']; $id = $_POST['id']; $sql = "INSERT INTO event SET date='$fulldate', event_desc='$event_desc', id='$id'"; $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); message( "ADD EVENT", "DATA ENTERED"); } else { message( "ERROR", "DATE ENTERED NOT VALID"); } } else { $query = "SELECT * FROM propertys WHERE price BETWEEN '".$_GET['minprice']."' AND '".$_GET['maxprice']."'ORDER BY price DESC"; $result = mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $address=mysql_result($result,$i,"address"); $price=mysql_result($result,$i,"price"); $ref=mysql_result($result,$i,"ref"); ++$i; } } ?> <form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post" name="post"> <table width="90%" class="tdborder" cellSpacing=1 cellPadding=6 border=0> <tr> <td class="header" bgcolor="#6699ff"><center>Appointments</center></td></tr> <tr> <td> <table width="100%" class=tableborder cellSpacing=1 cellPadding=0 border=0> <tr> <td><div class="genfont"><b>Date</b></div> <div><select name="eventyear"> <option value="2007">2007 <option value="2008">2008 <option value="2009">2009 <option value="2010">2010 <option value="2011">2011 <option value="2012">2012 <option value="2013">2013 </select> <select name="eventmonth"> <option value="01">Jan <option value="02">Feb <option value="03">Mar <option value="04">Apr <option value="05">May <option value="06">Jun <option value="07">Jul <option value="08">Aug <option value="09">Sep <option value="10">Oct <option value="11">Nov <option value="12">Dec </select> <select name="eventdate"> <option value="1">1 <option value="2">2 <option value="3">3 <option value="4">4 <option value="5">5 <option value="6">6 <option value="7">7 <option value="8">8 <option value="9">9 <option value="10">10 <option value="11">11 <option value="12">12 <option value="13">13 <option value="14">14 <option value="15">15 <option value="16">16 <option value="17">17 <option value="18">18 <option value="19">19 <option value="20">20 <option value="21">21 <option value="22">22 <option value="23">23 <option value="24">24 <option value="25">25 <option value="26">26 <option value="27">27 <option value="28">28 <option value="29">29 <option value="30">30 <option value="31">31 </select> <input type="hidden" name="id" value="<?php echo $_GET['id']; ?>"> </td> </tr> </table> </td> <tr> <td><div class="genfont">Enter event :</div> <textarea name="event_desc" rows="4" cols="15" wrap="virtual" style="width:550px; font-size:12px" tabindex="3"> R<? echo "$price #$ref $address \n";?> </textarea> </td> </tr> <tr> <td><div align="center"> <input type="submit" value="Submit" name="submit" /> </form> <? } ?>
  15. if i do what liam did it will display outside the box if i insert echo "$price #$ref $address \n\r"; between the tags it only shows the first result
  16. liam it works fine if it not between the <textarea> </textarea> but i need to insert it there. i have closed the textare tag?
  17. How can you display more than one result in a text area? The way i have my code now displays just the first result in the text area. <? include "config.php"; $db = mysql_connect($host,$login,$password); mysql_select_db($base,$db); if (!verifyuser() ) { header( "Location: login.php" ); } else { ?> <head> <title>Diary</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body bgcolor="#FFFFFF" topmargin="5" leftmargin="5" marginheight="5" marginwidth="5" ><center> <? if (isset($_POST["event_desc"])) { $event_desc = $_POST['event_desc']; } if (isset($_POST["submit"]) && (!isset($_POST["event_desc"]) or empty($event_desc) )) { ?> <script language="Javascript" type="text/javascript"> <!-- window.open('empty.html', '_myevent', 'HEIGHT=100,resizable=yes,WIDTH=400'); //--> </script> <? } if ( isset($_POST["submit"]) && !empty($event_desc)) { $eventyear = $_POST['eventyear']; $eventmonth = $_POST['eventmonth']; $eventdate = $_POST['eventdate']; $id = $_POST['id']; $day_in_a_mth = date('t', mktime(0, 0, 0, $eventmonth, 1, $eventyear)) ; if ($day_in_a_mth >= $eventdate ) { $fulldate = $eventyear."-".$eventmonth."-".$eventdate; $event_desc = $_POST['event_desc']; $id = $_POST['id']; $sql = "INSERT INTO event SET date='$fulldate', event_desc='$event_desc', id='$id'"; $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); message( "ADD EVENT", "DATA ENTERED"); } else { message( "ERROR", "DATE ENTERED NOT VALID"); } } else { $query = "SELECT * FROM propertys WHERE price BETWEEN '".$_GET['minprice']."' AND '".$_GET['maxprice']."'ORDER BY price DESC"; $result = mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $address=mysql_result($result,$i,"address"); $price=mysql_result($result,$i,"price"); $ref=mysql_result($result,$i,"ref"); ?> <? ++$i; } } ?> <form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post" name="post"> <table width="90%" class="tdborder" cellSpacing=1 cellPadding=6 border=0> <tr> <td class="header" bgcolor="#6699ff"><center>Appointments</center></td></tr> <tr> <td> <table width="100%" class=tableborder cellSpacing=1 cellPadding=0 border=0> <tr> <td><div class="genfont"><b>Date</b></div> <div><select name="eventyear"> .... </select> <input type="hidden" name="id" value="<?php echo $_GET['id']; ?>"> </td> </tr> </table> </td> <tr> <td><div class="genfont">Enter event :</div> <textarea name="event_desc" rows="4" cols="15" wrap="virtual" style="width:550px; font-size:12px" tabindex="3"> R<? print "$price"?> #<? print "$ref"?> <? print "$address"?> </textarea> </td> </tr> <tr> <td><div align="center"> <input type="submit" value="Submit" name="submit" /> <? } ?> </form>
  18. please help i have encoded the "id" from another script and want to insert it in the id column in another table.here my code. <? if (isset($_POST["event_desc"])) { $event_desc = $_POST['event_desc']; } if (isset($_POST["submit"]) && (!isset($_POST["event_desc"]) or empty($event_desc) )) { ?> <script language="Javascript" type="text/javascript"> <!-- window.open('empty.html', '_myevent', 'HEIGHT=100,resizable=yes,WIDTH=400'); //--> </script> <? } if ( isset($_POST["submit"]) && !empty($event_desc)) { $eventyear = $_POST['eventyear']; $eventmonth = $_POST['eventmonth']; $eventdate = $_POST['eventdate']; $id = $_GET['id']; $day_in_a_mth = date('t', mktime(0, 0, 0, $eventmonth, 1, $eventyear)) ; if ($day_in_a_mth >= $eventdate ) { $fulldate = $eventyear."-".$eventmonth."-".$eventdate; $event_desc = $_POST['event_desc']; $id = $_GET['id']; $sql = "INSERT INTO event SET date='$fulldate', event_desc='$event_desc', id='$id'"; $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); message( "ADD EVENT", "DATA ENTERED"); } else { message( "ERROR", "DATE ENTERED NOT VALID"); } } else { ?> <? $id=$_GET['id']; $query="SELECT * FROM client WHERE id='$id'"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $name=mysql_result($result,$i,"name"); $surname=mysql_result($result,$i,"surname"); $username=mysql_result($result,$i,"username"); ?>
  19. im trying to send a email with html as well as php.sending the email is the easy part.the problem is with the message part.if i put this code in the textarea it display the html tags in the email.yet the php is fine. # <form action="mail.php" method="POST" enctype="multipart/form-data"> To: <input type="text" name="to" value="<?echo $email?>" /><br /> From: <input type="text" name="from" value="" /><br /> Subject: <input type="text" name="subject" value="Property Enquiry" /></p> <br> Should you wish to view any of these properties please dont hesitate to call us.Please click on the link to find out more about the property.<br> R<?php echo $price = $row["price"];?><br> Reference #<?php echo $ref = $row["ref"];?><br> <?php echo $description = $row["description"];?><br> Bedrooms: <?php echo $bed = $row["bed"];?><br> Bathrooms: <?php echo $bath = $row["bath"];?><br> Garages: <?php echo $gar = $row["gar"];?><br> <a href="http://localhost/vap/moredetails.php?ref=<?php echo urlencode($ref); ?>" "More Details"> Click here for more details</a> <p>File Attachment: <input type="file" name="fileatt" /></p> <p><input type="submit" value="Send" /></p> </form> #if i call it $message and put in to php qoutes then the php dont work and it doesnt send the message bit.
  20. used $result = mysql_query("SELECT name, surname, birthday, mobile, office, home, email, maxprice, minprice, bed, gar " . "FROM client WHERE username = '$user'") or die("SELECT Error: ".mysql_error()); solved.
  21. i have tried $result = mysql_query("SELECT `username` FROM `client` WHERE `username` = $user") or die("SELECT Error: ".mysql_error()); this brings SELECT Error: Unknown column 'quintin' in 'where clause'
  22. that returns no result so i tried $result = mysql_query("SELECT * FROM `client` WHERE `username` = '".$_GET['$session->username']."'") or die("SELECT Error: ".mysql_error()); is this the wrong way to pass the username?
×
×
  • 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.