Jump to content

alexmark

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Everything posted by alexmark

  1. Hi All I am trying to set a light box up on a caresel which I have working with fixed images. I would like to call this information from a 2 db like this. db table listing has tables id,make(is id from make table), model (is id from model table) and featured. db listimages has tables id, imagepath, imagethumbpath and listing id. I would like to select only vehicles that are selected as featured from the listings table and some how echo them all out with a link to the page that displays more information about the vehicle from the "herf" How do i go about adding the code to pull this info and get it to select all the information? This is the code I have for teh light box and as I stated it works fine with static images. <div id="gap"></div> <table width="1000" border="0" cellspacing="0" cellpadding="0" align="center"> <TR> <TD width="1000"><table width="1000" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="blocktl" height="29" width="29"></td> <td bgcolor="#000000" class="bodyfont"><h1>Featured Cars</h1></td> <td class="blocktr" height="29" width="29"> <tr> <td bgcolor="#000000"></td> <td bgcolor="#000000" valign="top" class="bodyfont" align="center" style="padding-top:10px;"> <!--Make sure page contains valid doctype at the very top!--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="/js/stepcarousel.js"></script> <style type="text/css"> .stepcarousel{ position: relative; /*leave this value alone*/ border: 0px solid black; overflow: scroll; /*leave this value alone*/ width: 825px; /*Width of Carousel Viewer itself*/ height: 215px; /*Height should enough to fit largest content's height*/ margin-left: 0px; } .stepcarousel .belt{ position: absolute; /*leave this value alone*/ left: 0; top: 0; } .stepcarousel .panel{ float: left; /*leave this value alone*/ overflow: hidden; /*clip content that go outside dimensions of holding panel DIV*/ margin: 10px; /*margin around each panel*/ width: 230px; /*Width of each panel holding each content. If removed, widths should be individually defined on each content DIV then. */ } </style> <script type="text/javascript"> stepcarousel.setup({ galleryid: 'mygallery', //id of carousel DIV beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs panelclass: 'panel', //class of panel DIVs each holding content autostep: {enable:true, moveby:1, pause:3000}, panelbehavior: {speed:500, wraparound:true, wrapbehavior:'slide', persist:true}, defaultbuttons: {enable: true, moveby: 1, leftnav: ['/images/arrowleft.png', -15, 40], rightnav: ['/images/arrowright.png', 15, 40]}, statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels contenttype: ['inline'] //content setting ['inline'] or ['ajax', 'path_to_external_file'] }) </script> <div id="mygallery" class="stepcarousel" > <div class="belt"> <div class="panel"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle" align="center" height="180" class="bodyfont"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" height="160" align="center"> <a href="1997-Mercedes-Benz-E320-index.php" > <img src='images/merc1.jpg' width="150" height="100" alt="1997 Mercedes-Benz E320" border='0' style="border:5px;border-color:#ffffff;border-style:solid;"></a> </td> </tr> <tr> <td valign="top" class="bodyfont" align="center"> <p> <a href="1997-Mercedes-Benz-E320-index.php" title="1997 Mercedes-Benz E320">1997 Mercedes-Benz E320</a></p> </td></tr></table> </td></tr></table> </div> <div class="panel"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle" align="center" height="180" class="bodyfont"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" height="160" align="center"> <a href="car_Ford-Mondeo_12__index.php" > <img src='images/Eclips.jpg' width="150" height="100" alt="2002 Mitsubishi Eclipse GS" border='0' style="border:5px;border-color:#ffffff;border-style:solid;"></a> </td> </tr> <tr> <td valign="top" class="bodyfont" align="center"> <p> <a href="2002 Mitsubishi Eclipse GS index.php" title="2002 Mitsubishi Eclipse GS">2002 Mitsubishi Eclipse GS</a></p> </td></tr></table> </td></tr></table> </div> <div class="panel"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle" align="center" height="180" class="bodyfont"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" height="160" align="center"> <a href="car_Mercedes-A140_11__index.php" > <img src='images/Ranger.jpg' width="150" height="100" alt="1999 Ford Ranger XLT" border='0' style="border:5px;border-color:#ffffff;border-style:solid;"></a> </td> </tr> <tr> <td valign="top" class="bodyfont" align="center"> <p> <a href="1999 Ford Ranger XLT__index.php" title="1999 Ford Ranger XLT">1999 Ford Ranger XLT</a></p> </td></tr></table> </td></tr></table> </div> <div class="panel"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle" align="center" height="180" class="bodyfont"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" height="160" align="center"> <a href="car_Mercedes-E200k_6__index.php" > <img src='images/Wind.jpg' width="150" height="100" alt="2000 Ford Windstar LX" border='0' style="border:5px;border-color:#ffffff;border-style:solid;"></a> </td> </tr> <tr> <td valign="top" class="bodyfont" align="center"> <p> <a href="2000 Ford Windstar LX_index.php" title="2000 Ford Windstar LX">2000 Ford Windstar LX</a></p> </td></tr></table> </td></tr></table> </div> <div class="panel"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="middle" align="center" height="180" class="bodyfont"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" height="160" align="center"> <a href="car_Mercedes-E320_8__index.php" > <img src='images/honda.jpg' width="150" height="100" alt="1996 Honda Passport EX" border='0' style="border:5px;border-color:#ffffff;border-style:solid;"></a> </td> </tr> <tr> <td valign="top" class="bodyfont" align="center"> <p> <a href="1996 Honda Passport EX_index.php" title="1996 Honda Passport EX">1996 Honda Passport EX</a></p> </td></tr></table> </td></tr></table> </div> </div> </div>
  2. Thank you so much for the help and lesson. I had never really thought about the separation before but as you explained it it does make complete sense. So as I understand from what you have said you always call the information as it were out side and then display the results within the <p> class etc. Which would make all the css work correctly as it does now because I was having problems with that also. You are a star and once again thank you so very much.
  3. Hi all I am trying to echo a google map url from a db. The problem is when I echo it it adds teh websites url back on to the front of the map url. eg. In the db is stored http://maps.google.com/maps? which is correct. when I echo it out I get http://american-auto-exchange.com/%3Cp%3Ehttp://maps.google.com/maps? Can some one please tell me where I am going wrong with the code below please. Thank you in advance for giving up your time to help newbies like me. <h1>Location Map</h1> <p class="indent"> <a href="<?php $result = mysql_query("SELECT * FROM site_settings") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo "<p>".$row['mapurl']."</p>"; } ?>" target="_blank" title="Click here for a location map">Click here for a location map</a></p>
  4. There are several useful methods in JavaScript?s Date object (e.g. Date.getTimezoneOffset(), Date.toLocaleString()) You would then have to save teh information retreaved to the db.
  5. Ok so here is what i have tried and it will not work. As I said before I am new to this and need pointing in teh right direction. <tr> <td align="right" label for='formmodel'>Model: </td> <td> <select name="formmodel" id="formmodel"> <?php $query = "SELECT model.model,year.Id,manufacturer.Id, model.manufacturer_id, model.year". "FROM model,year,manufacturer". "INNER JOIN year ON model.year_id = year.Id INNER JOIN manufacturer ON model.manufacturer_id = manufacturer.id WHERE manufacturer.id = model.manufacturer_id"; $result = mysql_query($query) or die(mysql_error()); while($data = mysql_fetch_array($result)) ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['model'] ?></option> <?php } ?>
  6. Hi all I am new to php and I need to write an inner join to get a form to do what I would like. The problem is I am not sure how to write it. I have 3 tables as follows; manufacturer 2 columns id (which is unique) and manufacturer year 2 columns id (which is unique) and year model 4 columns id (which is unique) year (which corresponds to year id table) manufacturer_id (which corresponds to manufactures id table) and model. I am pulling info by the following code. <tr> <td align="right" label for='formyear'>Year: </td> <td><select name="formyear"> <?php $sql="SELECT id,year FROM year"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['year'] ?></option> <?php } ?> </select></td> </tr> <tr> <td align="right" label for='formmake'>Make: </td> <td><select name="formmake" id="formmake" onchange="return populateModel(this.value);"> <?php $sql="SELECT id,manufacturer FROM manufacturer"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['manufacturer'] ?></option> <?php } ?> </select> </td> </tr> <tr> <td align="right" label for='formmodel'>Model: </td> <td><select name="formmodel" id="formmodel"> <?php $sql="SELECT id,manufacturer_id,model FROM model WHERE year='1'"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['model'] ?></option> <?php } ?> </select> What I would like to happen is that some one selects a year and then a make and then a model. I have been told this can be done via inner joins. How do I write them to work so I can still pull info for theselect list as above? Any help would be trully gratfull as I am at a complete loss here.
  7. Hi There are several realy good tutorials on uploading images. I would check out http://codewall.blogspot.com/2011/03/upload-image-in-folder-in-php-step-by.html The prob with your form is that if it worked anyone could upload a diffrent file other than an image which leaves you open to problems with attacks from out side users. You need to make sure you can varify that the file been uploaded is indeed an image.
  8. Sorry I posted teh code backwards <tr> <td align="right" label for='formyear'>Year: </td> <td><select name="formyear"> <?php $sql="SELECT id,year FROM year"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['year'] ?></option> <?php } ?> </select></td> </tr> <tr> <td align="right" label for='formmake'>Make: </td> <td><select name="formmake" id="formmake" onchange="return populateModel(this.value);"> <?php $sql="SELECT id,manufacturer FROM manufacturer"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['manufacturer'] ?></option> <?php } ?> </select> </td> </tr> <tr> <td align="right" label for='formmodel'>Model: </td> <td> <select name="formmodel" id="formmodel"> <?php $sql="SELECT id,model FROM model WHERE year='1'"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['model'] ?></option> <?php } ?> </select>
  9. Hi all I am working on a project and I can not seem to get this right no mater what I do. I have 3 tables in db, year, manufacturer_id and models I would like to display makes and models based on requests made by user. I.e., if a user selects Make as Ford and then Year as 1942 the Model should return a list of all models produced in that year. However it does not work can some one tell me where I am going wrong please. My data bases tables are set up as follows. manufacturer 2 columns id (which is unique) and manufacturer year 2 columns id (which is unique) and year model 4 columns id (which is unique) year (which corresponds to year id table) manufacturer_id (which corresponds to manufactures id table) and model. The code I am using is as follows. <tr> <td align="right" label for='formmake'>Make: </td> <td><select name="formmake" id="formmake" onchange="return populateModel(this.value);"> <?php $sql="SELECT id,manufacturer FROM manufacturer"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['manufacturer'] ?></option> <?php } ?> </select> </td> </tr> <tr> <td align="right" label for='formyear'>Year: </td> <td><select name="formyear"> <?php $sql="SELECT id,year FROM year"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['year'] ?></option> <?php } ?> </select></td> </tr> <tr> <td align="right" label for='formmodel'>Model: </td> <td> <select name="formmodel" id="formmodel"> <?php $sql="SELECT id,model FROM model WHERE year='1'"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['model'] ?></option> <?php } ?> </select> <!--<input name="formmodel" type="text" value="<?php echo $varmodel;?>" size="60" maxlength="100" />--> </td> I seem to be makeing a mess of this. I would like to thank everyone who looks at this for there help.
  10. I missed a comma! lol wow that was crazy
  11. Hi all Ok I have a simple problem! lol as if tehre was such a thing. When I run teh form below it will not bring the make and year and model from the db. I have looked and tried just about everything apart from teh correct solution. If anyone could throw a light on this I would be so happy. <?php if ( $_SESSION['logged_in'] ): ?> (1) <?php endif; ?> <?php if($_POST['formSubmit'] == "Submit") { $errorMessage = ""; //echo "<PRE>";print_r($_POST['features']); if(empty($_POST['formmake'])) { $errorMessage .= "<li>You forgot to Select a Make!</li>"; } if(empty($_POST['formmodel'])) { $errorMessage .= "<li>You forgot to select a Model!</li>"; } if(empty($_POST['formvehicle_type'])) { $errorMessage .= "<li>You forgot to enter a Body Type!</li>"; } if(empty($_POST['formdoors'])) { $errorMessage .= "<li>You forgot to enter Doors!</li>"; } if(empty($_POST['formcolor'])) { $errorMessage .= "<li>You forgot to enter Color!</li>"; } if(empty($_POST['formmileage'])) { $errorMessage .= "<li>You forgot to enter Mileage!</li>"; } if(empty($_POST['formyear'])) { $errorMessage .= "<li>You forgot to enter Year!</li>"; } if(empty($_POST['formlisting_condition'])) { $errorMessage .= "<li>You forgot to enter Condition!</li>"; } if(empty($_POST['formengine'])) { $errorMessage .= "<li>You forgot to enter Engine!</li>"; } if(empty($_POST['formtrans'])) { $errorMessage .= "<li>You forgot to enter a Transmission Type!</li>"; } if(empty($_POST['formdrive_train'])) { $errorMessage .= "<li>You forgot to enter a Drive Train!</li>"; } if(empty($_POST['formmpg'])) { $errorMessage .= "<li>You forgot to enter the Miles Per Gallon!</li>"; } if(empty($_POST['formfuel_type'])) { $errorMessage .= "<li>You forgot to select a Fule Type!</li>"; } if(empty($_POST['formprice'])) { $errorMessage .= "<li>You forgot to enter a Price!</li>"; } if(empty($_POST['formadddesc'])) { $errorMessage .= "<li>You forgot to enter a Description!</li>"; } if(empty($_POST['features'])) { $errorMessage .= "<li>You forgot to select any Features!</li>"; } if(empty($_POST['formvin'])) { $errorMessage .= "<li>You forgot to enter a Vin Number!</li>"; } if(empty($_POST['formstock'])) { $errorMessage .= "<li>You forgot to enter a Stock Number!</li>"; } $varmake = $_POST['formmake']; $varmodel = $_POST['formmodel']; $varvehicle_type = $_POST['formvehicle_type']; $vardoors = $_POST['formdoors']; $varcolor = $_POST['formcolor']; $varmileage = $_POST['formmileage']; $varyear = $_POST['formyear']; $varlisting_condition = $_POST['formlisting_condition']; $varengine = $_POST['formengine']; $vartrans = $_POST['formtrans']; $vardrive_train = $_POST['formdrive_train']; $varmpg = $_POST['formmpg']; $varfuel_type = $_POST['formfuel_type']; $varprice = $_POST['formprice']; $varadddesc = $_POST['formadddesc']; $varfeatures = $_POST['features']; $varvin = $_POST['formvin']; $varstock = $_POST['formstock']; $hitcount = 0; $sold = 0; $added_on = date('Y-m-d H:i:s'); if(empty($errorMessage)) { include 'config.php'; $sql = "INSERT INTO listing (make, model, vehicle_type, doors,color, mileage, year, listing_condition, engine, trans, drive_train, mpg, fuel_type, price, adddesc, features, vin, stock, hitcount, sold, added_on, carofweek, featured) VALUES (". PrepSQL($varmake) . ", " . PrepSQL($varmodel) . ", " . PrepSQL($varvehicle_type) . ", " . PrepSQL($vardoors) . ", " . PrepSQL($varcolor) . ", " . PrepSQL($varmileage) . ", " . PrepSQL($varyear) . ", " . PrepSQL($varlisting_condition) . ", " . PrepSQL($varengine) . ", " . PrepSQL($vartrans) . ", " . PrepSQL($vardrive_train) . ", " . PrepSQL($varmpg) . ", " . PrepSQL($varfuel_type) . ", " . PrepSQL($varprice) . ", " . PrepSQL($varadddesc) . ", " . PrepSQL(serialize($varfeatures)) . ", " . PrepSQL($varvin) . ", " . PrepSQL($varstock) . ", " . PrepSQL($varcarofweek) . ", " . PrepSQL($varfeatured) . ", " . PrepSQL($hitcount) . ", " . PrepSQL($sold) . ", " . PrepSQL($added_on) . ")"; if(mysql_query($sql)){ $listingId = mysql_insert_id(); include '../../includes/imageresizer.class.php'; include '../../includes/upload_class.php'; $imagePath = '/admin/uploaded_photos/'; $thumbPath = '/admin/thumbnails/'; for($i==0; $i<10; $i++){ if(!empty($_FILES['formImage'.$i]['tmp_name'])){ if(!is_dir($imagePath.'/')){ mkdir($imagePath.'/', 0777); } // Generate Thumbnails if(!is_dir($thumbPath.'/')){ mkdir($thumbPath.'/', 0777); } $UF_obj = new Upload(); $UF_obj -> File = $_FILES['formImage'.$i]; $UF_obj -> SavePath = $imagePath.'/'; // PLACE where you want to save images. $UF_obj -> ThumbPath = $thumbPath.'/'; //if not specify will not create thumbnil $UF_obj -> NewName = $_FILES['formImage'.$i]['name']; //width and height of large image which will save in "pictures/" folder $UF_obj -> NewWidth = 800; $UF_obj -> NewHeight = 600; ////width and height of thumb image which will save in "pictures/thumb/" folder $UF_obj -> TWidth = 100; $UF_obj -> THeight = 100; /* * if you want to name image something other then upload image name then use bellow formate * for example you upload two images then * * $UF_obj -> NewName = array('NewName1.jpg', 'NewName2.jpg'); */ $UF_obj -> NameCase = 'lower'; //default no change. upper for upper case $UF_obj -> OverWrite = true; //default = true. replace existing image //UploadFile() function upload and resize image. //function return error message if any. //error variable is in array form. so you can get more then one error/warning messages. // or you can also access error message by class object varialbe like $UF_obj -> Error $Error = $UF_obj -> UploadFile(); // INSERT images to DB if(count($Error)<=0){ $imageInsert = "INSERT INTO listimages (imagepath, imagethumbpath, mainimage, listingid)Values ('".$imagePath."/".$_FILES['formImage'.$i]['name']."','".$thumbPath."/".$_FILES['formImage'.$i]['name']."','0','".$listingId."')"; mysql_query($imageInsert); }else{ if(is_array($Error)){ foreach($Error as $key=>$val) { echo $val . '<br>'; } } } } } echo("<ul style='color:green;'>Your Listing is Successfully Listed!</ul>\n"); } } } // function: PrepSQL() // use stripslashes and mysql_real_escape_string PHP functions // to sanitize a string for use in an SQL query // // also puts single quotes around the string // function PrepSQL($value) { // Stripslashes if(get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote $value = "'" . mysql_real_escape_string($value) . "'"; return($value); } ?> <script src="../../js/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="../../js/jquery-validation/jquery.validate.js"></script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Add Vehicle</title> <link href="/csssheet.css" rel="stylesheet" type="text/css"> </head> <body> <center><div style="width:785px"> <table td class="background1" valign="top" width="785px" colspan="1" border=0 cellpadding=0 cellspacing=0 align="center"> <tr> <td width="100%"><center><br><a href= "../admin.php" class="creamlink11">Log Out</a></center></td> </tr> <td></td> </table> <?php include("../menu/admin_menu.php") ?> </td> </tr> <tr> <td bgcolor="#F6F6F6" height='1'></td> </tr> <tr> <td > <table width="785" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="785" bgcolor="#232B34" class="bodyfontred"> <table border=0 width='100%' cellspacing=0 cellpadding=0> <tr> <td valign="top" align=center> </td> </tr> <tr> <td align=center> <center> <img src="/images/linebreak.jpg" width="350" height="1"> </center> <?php if(!empty($errorMessage)) { echo("<p>There was an error with your form:</p>\n"); echo("<ul>" . $errorMessage . "</ul>\n"); } ?> <script type="text/javascript"> $().ready(function() { // validate signup form on keyup and submit $("#listing-form").validate({ rules: { formmake: "required", formmodel: "required", formvehicle_type: "required", formdoors: "required", formcolor: "required", formmileage: "required", formyear: "required", formlisting_condition: "required", formengine: "required", formtrans: "required", formdrive_train: "required", formmpg: "required", formfuel_type: "required", formprice: "required", formadddesc: "required", features: "required", formvin: "required", formstock: "required" }, messages: { formmake: "You forgot to Select a Make!", formmodel: "You forgot to Enter a Model!", formvehicle_type: "You forgot to Enter a Body Type!", formdoors: "You forgot to Enter Doors!", formcolor: "You forgot to Enter Color!", formmileage: "You forgot to Enter Mileage!", formyear: "You forgot to Select Year!", formlisting_condition: "You forgot to Select Condition!", formengine: "You forgot to Enter Engine!", formtrans: "You forgot to Select Transmission Type!", formdrive_train: "You forgot to Select a Drive Train!", formmpg: "You forgot to Enter a Mileage Per Gallon!", formfuel_type: "You forgot to Select a Fuel Type!", formprice: "You forgot to Enter a Price!", formadddesc: "You forgot to Enter a Description!", features: "You forgot to Select a Features!", formvin: "You forgot to Enter a Vin Number!", formstock: "You forgot to Enter a Stock Number!" } }); }); </script> <form id="listing-form" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data"> <table align="center"> <tr> <td class="bodyfontwhite" width="199" align="right" label for='formad_title'> </td> <td width="556"> </td> </tr> <tr> <td align="right" label for='formad_title'><div align="left"><strong>Vehicle Details:</strong></div></td> <td> </td> </tr> <tr> <td align="right" label for='formad_title'> </td> <td> </td> </tr> <tr> <td align="right" label for='formvin'>Vin Number: </td> <td><input name="formvin" type="text" value="<?php echo $varvin;?>" size="20" maxlength="100" /></td> </tr> <tr> <td align="right" label for='formstock'>Stock Number: </td> <td><input name="formstock" type="text" value="<?php echo $varstock;?>" size="20" maxlength="100" /></td> </tr> <tr> <td align="right" label for='formmake'>Make: </td> <td><select name="formmake" id="formmake" onchange="return populateModel(this.value);"> <?php $sql="SELECT id,manufacturer FROM manufacturer"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['manufacturer'] ?></option> <?php } ?> </select> </td> </tr> <tr> <td align="right" label for='formyear'>Year: </td> <td><select name="formyear"> <?php $sql="SELECT id,year FROM year"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['year'] ?></option> <?php } ?> </select></td> </tr> <tr> <td align="right" label for='formmodel'>Model: </td> <td> <select name="formmodel" id="formmodel"> <?php $sql="SELECT id,model FROM model WHERE year_id='1'"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['model'] ?></option> <?php } ?> </select> <!--<input name="formmodel" type="text" value="<?php echo $varmodel;?>" size="60" maxlength="100" />--> </td> </tr> <tr> <td align="right" label for='formvehicle_type'>Body Style: </label></td> <td> <select name="formvehicle_type"> <?php $sql="SELECT id,vehicle_type FROM vehicle_type"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['vehicle_type'] ?></option> <?php } ?> </select> </td> </tr> <tr> <td align="right" label for='formdoors'>Number of Doors: </td> <td><select name="formdoors"> <option value="0">Select Option</option> <option value="1"<?php if($vardoors=="1") echo(" selected=\"selected\"");?>>2 Door</option> <option value="2"<?php if($vardoors=="2") echo(" selected=\"selected\"");?>>4 Door</option> <option value="3"<?php if($vardoors=="3") echo(" selected=\"selected\"");?>>3 Door Hatchback</option> <option value="4"<?php if($vardoors=="4") echo(" selected=\"selected\"");?>>5 Door Hatchback</option> <option value="5"<?php if($vardoors=="5") echo(" selected=\"selected\"");?>>Other</option> </select></td> </tr> <tr> <td align="right" label for='formcolor'>Color: </td> <td><input name="formcolor" type="text" value="<?php echo $varcolor;?>" size="25" maxlength="60" /></td> </tr> <tr> <td align="right" label for='formmileage'>Mileage: </td> <td><input name="formmileage" type="text" value="<?php echo $varmileage;?>" size="25" maxlength="20" /></td> </tr> <tr> <td align="right" label for='formlisting_condition'>Condition: </td> <td><select name="formlisting_condition"> <option value="0">Select Option</option> <option value="1"<?php if($varlisting_condition=="1") echo(" selected=\"selected\"");?>>New</option> <option value="2"<?php if($varlisting_condition=="2") echo(" selected=\"selected\"");?>>Used</option> <option value="3"<?php if($varlisting_condition=="3") echo(" selected=\"selected\"");?>>Used with Warranty</option> <option value="4"<?php if($varlisting_condition=="4") echo(" selected=\"selected\"");?>>As is</option> <option value="5"<?php if($varlisting_condition=="5") echo(" selected=\"selected\"");?>>Other</option> </select></td> </tr> <tr> <td align="right" label for='formengine'>Engine: </td> <td><input name="formengine" type="text" value="<?php echo $varengine;?>" size="60" maxlength="100" /></td> </tr> <tr> <td align="right" label for='formtrans'>Transmission: </td> <td><select name="formtrans"> <option value="0">Select Option</option> <option value="1"<?php if($vartrans=="1") echo(" selected=\"selected\"");?>>Manual</option> <option value="2"<?php if($vartrans=="2") echo(" selected=\"selected\"");?>>Automatic</option> </select></td> </tr> <tr> <td align="right" label for='formdrive_train'>Drive Train: </td> <td><select name="formdrive_train"> <?php $sql="SELECT id,drive_train FROM drive_train"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['drive_train'] ?></option> <?php } ?> </select></td> </tr> <tr> <td align="right" label for='formmpg'>Miles Per Gallon: </td> <td><input name="formmpg" type="text" value="<?php echo $varmpg;?>" size="20" maxlength="100" /></td> </tr> <tr> <td align="right" label for='formfuel_type'>Fuel Type: </td> <td><select name="formfuel_type"> <option value="0">Select Option</option> <option value="1"<?php if($varfuel_type=="1") echo(" selected=\"selected\"");?>>Gasoline</option> <option value="2"<?php if($varfuel_type=="2") echo(" selected=\"selected\"");?>>Diesel</option> <option value="3"<?php if($varfuel_type=="3") echo(" selected=\"selected\"");?>>Hybrid</option> <option value="4"<?php if($varfuel_type=="4") echo(" selected=\"selected\"");?>>FleX-Fuel</option> <option value="5"<?php if($varfuel_type=="5") echo(" selected=\"selected\"");?>>Electric</option> </select></td> </tr> <tr> <td align="right" label for='formprice'>Price: </td> <td><input name="formprice" type="text" value="<?php echo $varprice;?>" size="20" maxlength="100" /></td> </tr> <tr> <td align="right" label for='formadddesc'>Description: </td> <td><textarea name="formadddesc" rows="10" cols="80" ><?php echo $varadddesc;?> </textarea></td> </tr> <tr> <td align="right" label for='formcarofweek'>Car of The Week: </td> <td><input type="checkbox" name="carofweek" value="1" <?php if($_POST['carofweek'][0] == '1') {echo 'checked="checked"';} ?> /></td> </tr> <tr> <td align="right" label for='formfeatured'>Featured Car: </td> <td><input type="checkbox" name="featured" value="1" <?php if($_POST['featured'][0] == '1') {echo 'checked="checked"';} ?> /></td> </tr> <tr> <td colspan="2" align="right"> </td> </tr> <tr> <td align="right"><div align="left"><strong>Features:</strong></div></td> <td align="right"> </td> </tr> <tr> <td colspan="2" align="right"> </td> </tr> <tr> <td colspan="2" align="right"><table width="100%" border="0"> <tr> <td><input type="checkbox" name="features[]" value="1" id="features_108" <?php if($_POST['features'][0] == '1') { echo 'checked="checked"'; }?> /> Air Bag Front Drive</td> <td><input type="checkbox" name="features[]" value="2" id="features_109" <?php if($_POST['features'][1] == '2') { echo 'checked="checked"'; }?> /> Air Bag Front Passenger</td> <td><input type="checkbox" name="features[]" value="3" id="features_110" <?php if($_POST['features'][2] == '3') { echo 'checked="checked"'; }?> /> THESE ARE MORE FEATURES REMOVED <td><input type="checkbox" name="features[]" value="107" id="features_107" <?php if($_POST['features'][106] == '107') { echo 'checked="checked"'; }?> /> Tachometer</td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table></td> </tr> <tr> <td align="right"><div align="left"><strong>Upload Images:</strong></div></td> <td> </td> </tr> <tr> <td align="right" label for='formImage1'> </td> <td> </td> </tr> <tr> <td align="right" label for='formImage1'>Add Image 1: </td> <td><input name="formImage1" type="file" id="formImage1" value="<?=$varImage1;?>"/></td> </tr> <tr> <td align="right" label for='formImage2'>Add Image 2: </td> <td><input name="formImage2" type="file" id="formImage2" value="<?=$varImage2;?>"/></td> </tr> <tr> <td align="right" label for='formImage3'>Add Image 3: </td> <td><input name="formImage3" type="file" id="formImage3" value="<?=$varImage3;?>"/></td> </tr> <tr> <td align="right" label for='formImage4'>Add Image 4: </td> <td><input name="formImage4" type="file" id="formImage4" value="<?=$varImage4;?>"/></td> </tr> <tr> <td align="right" label for='formImage5'>Add Image 5: </td> <td><input name="formImage5" type="file" id="formImage5" value="<?=$varImage5;?>"/></td> </tr> <tr> <td align="right" label for='formImage6'>Add Image 6: </td> <td><input name="formImage6" type="file" id="formImage6" value="<?=$varImage6;?>"/></td> </tr> <tr> <td align="right" label for='formImage7'>Add Image 7: </td> <td><input name="formImage7" type="file" id="formImage7" value="<?=$varImage7;?>"/></td> </tr> <tr> <td align="right" label for='formImage8'>Add Image 8: </td> <td><input name="formImage8" type="file" id="formImage8" value="<?=$varImage8;?>"/></td> </tr> <tr> <td align="right" label for='formImage[]'>Add Image 9: </td> <td><input name="formImage9" type="file" id="formImage9" value="<?=$varImage9;?>"/></td> </tr> <tr> <td align="right" label for='formImage10'>Add Image 10: </td> <td><input name="formImage10" type="file" id="formImage10" value="<?=$varImage10;?>"/></td> </tr> </table> <center><input type="submit" name="formSubmit" value="Submit"/></center> </form> <tr><td class=bodyfontwhite> <center><b><a name='help'></a>H E L P</b></center><br> <p align=justify>Work down the form and enter all information as it is listed. Select the Features of the vehicle by clicking in the check boxes. Once you have finished simply click the submit button. <br></br><br></br> If you wish the vehicle to be car of the week simply click the check box for car of the week. <br></br><br></br> ** REMEMBER** YOU CAN ONLY HAVE ONE CAR OF THE WEEK.** <br></br> </p> </td></tr></table> </td> </tr> </table> </td> </tr> <tr> <center><td width="785" align="center" bgcolor="#000000" class="bodyfont" height="40"><a href="http://www.improvedinternetmarketing.com/" title="Improved Internet Marketing">Web Design</a> by Improved Internet Marketing</TD></center> </tr> </table> </div></center> </body> </html>
  12. Whoops. Sorry I miss understood you. No I have not got that in the code. I have the following to upload teh urls to the data base. if(empty($Error)){ $imageInsert = "INSERT INTO socialimages (imagepath, imagethumbpath, mainimage, socialid,)Values ('".$imagePath."/".$_FILES['formImage'.$i]['name']."','".$thumbPath."/".$_FILES['formImage'.$i]['name']."','0','".$socialid."')"; mysql_query($imageInsert); }else{ if(is_array($Error)){ foreach($Error as $key=>$val)
  13. Yes at the point where you select the file to upload. <tr> <td align="right"><div align="left"><strong>Upload Image:</strong></div></td> <td> </td> </tr> <tr> <td align="right" label for='formImage1'> </td> <td> </td> </tr> <tr> <td align="right" label for='formImage1'>Add Image: </td> <td><input name="formImage1" type="file" id="formImage1" value="<?=$varImage1;?>"/></td> </tr>
  14. Hi all Ok I have a form copy attached. the form works untill it reached the picture posting part. For some reason it will not post the image urls to teh db but it uploads teh images as it should to the correct folders. Any sujestions welcome. I have tried everything I can think of over the last 2 days and still no futher infront. <?php if ( $_SESSION['logged_in'] ): ?> (1) <?php endif; ?> <?php if(isset($_POST['formSubmit'])) { $errorMessage = ""; if(empty($_POST['formsocial'])) { $errorMessage .= "<li>You forgot to enter a Social Media Platform!</li>"; } if(empty($_POST['formurl'])) { $errorMessage .= "<li>You forgot to enter a URL!</li>"; } $varsocial = $_POST['formsocial']; $varurl = $_POST['formurl']; if(empty($errorMessage)) { include 'dbc.php'; $sql = "INSERT INTO social (id, social, url) VALUES (". PrepSQL($id) . ", " . PrepSQL($varsocial) . ", " . PrepSQL($varurl) . ") " ; if(mysql_query($sql)){ $socialId = mysql_insert_id(); include 'imageresizer.class.php'; include 'upload_class.php'; $imagePath = 'socialloads/'.$social; $thumbPath = 'socialthumbnails/'.$social; for($i==0; $i<10; $i++){ if(!empty($_FILES['formImage'.$i]['tmp_name'])){ if(!is_dir($imagePath.'/')){ mkdir($imagePath.'/', 0777); } // Generate Thumbnails if(!is_dir($thumbPath.'/')){ mkdir($thumbPath.'/', 0777); } $UF_obj = new Upload(); $UF_obj -> File = $_FILES['formImage'.$i]; $UF_obj -> SavePath = $imagePath.'/'; // PLACE where you want to save images. $UF_obj -> ThumbPath = $thumbPath.'/'; //if not specify will not create thumbnil $UF_obj -> NewName = $_FILES['formImage'.$i]['name']; //width and height of large image which will save in "pictures/" folder $UF_obj -> NewWidth = 150; $UF_obj -> NewHeight = 150; ////width and height of thumb image which will save in "pictures/thumb/" folder $UF_obj -> TWidth = 30; $UF_obj -> THeight = 30; /* * if you want to name image something other then upload image name then use bellow formate * for example you upload two images then * * $UF_obj -> NewName = array('NewName1.jpg', 'NewName2.jpg'); */ $UF_obj -> NameCase = 'lower'; //default no change. upper for upper case $UF_obj -> OverWrite = true; //default = true. replace existing image //UploadFile() function upload and resize image. //function return error message if any. //error variable is in array form. so you can get more then one error/warning messages. // or you can also access error message by class object varialbe like $UF_obj -> Error $Error = $UF_obj -> UploadFile(); // INSERT images to DB if(empty($Error)){ $imageInsert = "INSERT INTO socialimages (imagepath, imagethumbpath, mainimage, socialid,)Values ('".$imagePath."/".$_FILES['formImage'.$i]['name']."','".$thumbPath."/".$_FILES['formImage'.$i]['name']."','0','".$socialid."','1')"; mysql_query($imageInsert); }else{ if(is_array($Error)){ foreach($Error as $key=>$val) { echo $val . '<br>'; } } } } } echo("<ul style='color:green;'>Your Listing is Successfully Listed!</ul>\n"); } } } // function: PrepSQL() // use stripslashes and mysql_real_escape_string PHP functions // to sanitize a string for use in an SQL query // // also puts single quotes around the string // function PrepSQL($value) { // Stripslashes if(get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote $value = "'" . mysql_real_escape_string($value) . "'"; return($value); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Add social Media</title> <link href="/csssheet.css" rel="stylesheet" type="text/css"> </head> <body> <center><div style="width:785px"> <table td class="background1" valign="top" width="785px" colspan="1" border=0 cellpadding=0 cellspacing=0 align="center"> <tr> <td width="100%"><center><br><a href= "../admin.php" class="creamlink11">Log Out</a></center></td> </tr> <td></td> </table> <?php include("../menu/admin_menu.php") ?> </td> </tr> <tr> <td bgcolor="#F6F6F6" height='1'></td> </tr> <tr> <td > <table width="785" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="785" bgcolor="#232B34" class="bodyfontred"> <table border=0 width='100%' cellspacing=0 cellpadding=0> <tr> <td valign="top" align=center> </td> </tr> <tr> <td align=center> <center> <img src="/images/linebreak.jpg" width="350" height="1"> </center> <?php if(!empty($errorMessage)) { echo("<p>There was an error with your form:</p>\n"); echo("<ul>" . $errorMessage . "</ul>\n"); } ?> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data"> <table> <tr> <td class="bodyfontwhite" align="right"> <label for='formsocial'>Social Media Name</label></td> <td><input type="text" name="formsocial" size="40" maxlength="100" value="<?=$varsocial;?>"/></td> <td><label for='formurl'>URL</label></td> <td><input type="text" name="formurl" size="40" maxlength="250" value="<?=$varurl;?>"/></td> </tr> <tr> <td align="right" label for='formImage1'>Add Image: </td> <td><input name="formImage1" type="file" id="formImage1" value="<?=$varImage1;?>"/></td> </tr> <tr> </tr> </table> <center><input type="submit" name="formSubmit" value="Submit"/></center> </form> <tr><td class=bodyfontwhite> <center><b><a name='help'></a>H E L P</b></center><br> <p align=justify>To Add a Social Net Work type the text you wish to display. Add the URL address Then click the Submit button. </p> </td></tr></table> </td> </tr> </table> </td> </tr> <tr> <center><td width="785" align="center" bgcolor="#000000" class="bodyfont" height="40"><a href="http://www.improvedinternetmarketing.com/" title="Improved Internet Marketing">Web Design</a> by Improved Internet Marketing</TD></center> </tr> </table> </div></center> </body> </html>
  15. Thank you for your help. I was able to sort teh problem out and now have it working.
  16. Thank you for pointing me in the right direction. But how do I use this statment to echo result back to the same page as the form?
  17. lordshoa you are the star! I have another question though now that it submits correctely. How do i echo out a statment saying that it has entered the info correctely in the db? Would the following work? mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; } else { echo "ERROR"; } } }
  18. Hi all I have a form please see code and it will not send to db. each time I try it it sends back the error message that no information has been entered in form. <?php if ( $_SESSION['logged_in'] ): ?> (1) <?php endif; ?> <?php if(isset($_POST['formSubmit'])) { $errorMessage = ""; if(empty($_POST['social'])) { $errorMessage .= "<li>You forgot to enter a Social Media Platform!</li>"; } if(empty($_POST['url'])) { $errorMessage .= "<li>You forgot to enter a URL!</li>"; } $varsocial = $_POST['formsocial']; $varurl = $_POST['formurl']; if(empty($errorMessage)) { include '/dbc.php'; $sql = "INSERT INTO social (id, social, url) VALUES (". PrepSQL($id) . ", " . PrepSQL($varsocial) . ", " . PrepSQL($varurl) . ") " ; mysql_query($sql); header("Location: thankyou.html"); exit(); } } // function: PrepSQL() // use stripslashes and mysql_real_escape_string PHP functions // to sanitize a string for use in an SQL query // // also puts single quotes around the string // function PrepSQL($value) { // Stripslashes if(get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote $value = "'" . mysql_real_escape_string($value) . "'"; return($value); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Add social Media</title> <link href="/csssheet.css" rel="stylesheet" type="text/css"> </head> <body> <center><div style="width:785px"> <table td class="background1" valign="top" width="785px" colspan="1" border=0 cellpadding=0 cellspacing=0 align="center"> <tr> <td width="100%"><center><br><a href= "../admin.php" class="creamlink11">Log Out</a></center></td> </tr> <td></td> </table> <?php include("../menu/admin_menu.php") ?> </td> </tr> <tr> <td bgcolor="#F6F6F6" height='1'></td> </tr> <tr> <td > <table width="785" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="785" bgcolor="#232B34" class="bodyfontred"> <table border=0 width='100%' cellspacing=0 cellpadding=0> <tr> <td valign="top" align=center> </td> </tr> <tr> <td align=center> <center> <img src="/images/linebreak.jpg" width="350" height="1"> </center> <?php if(!empty($errorMessage)) { echo("<p>There was an error with your form:</p>\n"); echo("<ul>" . $errorMessage . "</ul>\n"); } ?> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data"> <table> <tr> <td class="bodyfontwhite" align="right"> <label for='formsocial'>Social Media Name</label></td> <td><input type="text" name="formsocial" size="40" maxlength="100" value="<?=$varsocial;?>"/></td> <td><label for='formurl'>URL</label></td> <td><input type="text" name="formurl" size="40" maxlength="250" value="<?=$varurl;?>"/></td> </tr> <tr> </tr> </table> <center><input type="submit" name="formSubmit" value="Submit"/></center> </form> <tr><td class=bodyfontwhite> <center><b><a name='help'></a>H E L P</b></center><br> <p align=justify>To Add a Social Net Work type the text you wish to display. Add the URL address Then click the Submit button. </p> </td></tr></table> </td> </tr> </table> </td> </tr> <tr> <center><td width="785" align="center" bgcolor="#000000" class="bodyfont" height="40"><a href="http://www.improvedinternetmarketing.com/" title="Improved Internet Marketing">Web Design</a> by Improved Internet Marketing</TD></center> </tr> </table> </div></center> </body> </html>
  19. What code would you like?
  20. Hi all I have a MySQL data base that is saving information from a form. One the form a user can add a business name which is text and a logo if they have one. Now on my web page I want to beabe to display the picture if present if not I would like it to display the business name. How do I do this please. I know how to conect to DB etc just having problems getting my head around this problem.
×
×
  • 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.