Jump to content

tech0925

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by tech0925

  1. I figured it out. I will use the switch statement instead
  2. The below mysqli query will always pull one result. However, after looking at my code I feel there must be a better way to simplify the status dropdown html section. As you can see I have a bunch of if statements and an array. Can anyone help me to make this simplier? $query = mysqli_query($mysqli, "SELECT * From referrals WHERE id = '".$edit."';"); while($row = mysqli_fetch_array($query)) { $editstatus = $row['status']; } if($editstatus == "N") { $estatus = "N/A"; } if($editstatus == "I") { $estatus = "Installation Comp"; } if($editstatus == "SI") { $estatus = "Site Inspection"; } if($editstatus == "S") { $estatus = "Sold"; } if($editstatus == "C") { $estatus = "Cancelled"; } if($editstatus == "P") { $estatus = "Press/Follow-Up"; } if($editstatus == "W") { $estatus = "Being Installed"; } $bstatus[] = "N/A"; $bstatus[] = "Installation Comp"; $bstatus[] = "Site Inspection"; $bstatus[] = "Sold"; $bstatus[] = "Cancelled"; $bstatus[] = "Press/Follow-Up"; $bstatus[] = "Being Installed"; ?> <div class="status"><label for="edit_status">Edit Status</label> <select id="edit_status" name="edit_status"> <?php foreach($bstatus as $cstatus) { if($cstatus == "N/A") { $dstatus = "N"; } if($cstatus == "Installation Comp") { $dstatus = "I"; } if($cstatus == "SI") { $dstatus = "Site Inspection"; } if($cstatus == "Sold") { $dstatus = "S"; } if($cstatus == "Cancelled") { $dstatus = "C"; } if($cstatus == "Press/Follow-Up") { $dstatus = "P"; } if($cstatus == "Being Installed") { $dstatus = "W"; } ?> <option <?php if($cstatus == $estatus) { echo "selected=\"selected\""; } ?> value="<?php echo $dstatus; ?>"><?php echo $cstatus ?></option> <?php } ?> </select> </div> As I mentioned, after looking at this code I know there has to be a better way to do this. Any help would be greatly apprecited
  3. You guys rock! One final question.. Here is my loop $thisAddress[$i] = mysql_result($result, $i, 'address'); $thisCity[$i] = MYSQL_RESULT($result,$i,"city"); $thisState[$i] = MYSQL_RESULT($result,$i,"state"); $thisZip[$i] = MYSQL_RESULT($result,$i,"zip"); Then how can I make the variable $addressList to contain this arrays? Then use that in the script? $addressList = "$thisAddress[], $thisCity[], $thisState[] $thisZip[]"; Is that right? Also, I need to make this variable outside the loop right? Thanks again for the help!!!!!!!!!!
  4. Thank you kicken! After doing that how can I use the array in the script?
  5. What about doing something like this? $i = 1; $thisAddress?><php echo $1; ?> <?php = MYSQL_RESULT($result,$i,"address"); $i++; Would that even work? I am just trying to figure out how to insert the 20 addresses on each page into that google map script. Any thoughts?
  6. Hello everyone I am trying to figure out how in the world I can increase the actuall variables name by 1 on each loop. Any help would be much appreciated. Let me show an example of what I want and then explain why I was trying to do this. Ok my database query will perform 20 loops retrieving some info and placing them into variables. Lets say I have the following variable. $thisAddress = MYSQL_RESULT($result,$i,"address"); So this will repeat 20 times and it will actually contain an address. What I need to do is make the variable unique for each address. For example: $thisAddress1 $thisAddress2 and so on Here is why. I am using google maps to display 20 address markers for each page. Here is what my google maps script looks like: <script type="text/javascript"> if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setUIToDefault(); // Create a base icon for all of our markers that specifies the // shadow, icon dimensions, etc. var baseIcon = new GIcon(G_DEFAULT_ICON); baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png"; baseIcon.iconSize = new GSize(20, 34); baseIcon.shadowSize = new GSize(37, 34); baseIcon.iconAnchor = new GPoint(9, 34); baseIcon.infoWindowAnchor = new GPoint(9, 2); // Creates a marker whose info window displays the letter corresponding // to the given index. function createMarker(point, index) { // Create a lettered icon for this point using our icon class var letter = String.fromCharCode("A".charCodeAt(0) + index); var letteredIcon = new GIcon(baseIcon); letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png"; // Set up our GMarkerOptions object markerOptions = { icon:letteredIcon }; var marker = new GMarker(point, markerOptions); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(addresses[index]); }); return marker; } // ====== Create a Client Geocoder ====== var geo = new GClientGeocoder(); // ====== Array for decoding the failure codes ====== var reasons=[]; reasons[G_GEO_SUCCESS] = "Success"; reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value."; reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address: No corresponding geographic location could be found for the specified address."; reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address: The geocode for the given address cannot be returned due to legal or contractual reasons."; reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given"; reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded."; reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed."; reasons[403] = "Error 403: Probably an incorrect error caused by a bug in the handling of invalid JSON."; var j=0; // ====== Geocoding ====== function getAddress(search, next) { geo.getLocations(search, function (result) { // If that was successful if (result.Status.code == G_GEO_SUCCESS) { // Lets assume that the first marker is the one we want var p = result.Placemark[0].Point.coordinates; var lat=p[1]; var lng=p[0]; if(j == 0) { map.setCenter(new GLatLng(lat, lng), 15); } var latlng = new GLatLng(lat, lng); map.addOverlay(createMarker(latlng, j)); } j++; next(); } ); } // ======= An array of locations that we want to Geocode ======== addresses = [ "<?php echo $thisAddress1; ?>", "<?php echo $thisAddress2; ?>", "<?php echo $thisAddress3; ?>", "<?php echo $thisAddress4; ?>", "<?php echo $thisAddress5; ?>", "<?php echo $thisAddress6; ?>", "<?php echo $thisAddress7; ?>", "<?php echo $thisAddress8; ?>", "<?php echo $thisAddress9; ?>", "<?php echo $thisAddress10; ?>", "<?php echo $thisAddress11; ?>", "<?php echo $thisAddress12; ?>", "<?php echo $thisAddress13; ?>", "<?php echo $thisAddress14; ?>", "<?php echo $thisAddress15; ?>", "<?php echo $thisAddress16; ?>", "<?php echo $thisAddress17; ?>", "<?php echo $thisAddress18; ?>", "<?php echo $thisAddress19; ?>", "<?php echo $thisAddress20; ?>", ]; // ======= Global variable to remind us what to do next var nextAddress = 0; // ======= Function to call the next Geocode operation when the reply comes back function theNext() { if (nextAddress < addresses.length) { getAddress(addresses[nextAddress],theNext); nextAddress++; } } // ======= Call that function for the first time ======= theNext(); } // display a warning if the browser was not compatible else { alert("Sorry, the Google Maps API is not compatible with this browser"); } </script> Is this the best way to do this or does anyone have a better idea? Thanks!!!
  7. I run an article directory. I was wondering how I could check an article that is currently pending review against published articles in our database. What I am looking to do is to place the content of the body in the pending article into a variable. That much is easy and I know how to do that. Then I would like to use that variable to compare against other content in our database and have it output a percentage of how close it is to any other article already published in our database. Any direction our guidance with this would be so greatly appreciated. Thanks!
  8. Just wanted to say hey! I am web designer with xhtml/css expertise. I am inspiring to learn php and have a good grasp of the basics but definitely still learning some of the rougher stuff like arrays. Look forward to reading your everyone's posts...
  9. Hello everyone! I am new here and this is my first post. I have been a member at another forum which they tend to make fun of newbies instead of helping them learn. That is why I am here Below is my script that allows me to upload 6 images at once and this works nicely. However, I am trying to change the variable $newname to increment in each pass so that I can build some if statements for my sql query. I would like the variable to start from $newname1 and should end up with 6 of them with the last being $newname6. That way I can have 6 unique picture variables that I can either update or insert into my table. Any help here would be great! $upload_image_limit = 6; // How many images you want to upload at once? define('MAX_SIZE', '100'); define('UPLOAD_DIRECTORY', '../memberYard'); // Define a list of extensions we want to allow. $allowable = array('.gif', '.jpg', '.jpeg', '.png'); $errors = array(); if (isset($_POST['Submit'])) { if (!empty($_FILES)) { foreach ($_FILES as $file) { // No need for a separate function to get a file's extension $extension = substr($file['name'], strpos($file['name'], ".")); $size = filesize($file['tmp_name']); // Check if the file's extension is in the permissable list if (!in_array(strtolower($extension), $allowable)) { $errors[] = "File {$file['name']} is of an unknown type."; continue; } // Check that the file size is OK if ($size > MAX_SIZE * 1024) { $errors[] = "File {$file['name']} is too big."; continue; } // Generate a random name for the file and move it $newname = substr(md5(microtime()), 0, 12) . $extension; $copied = move_uploaded_file($file['tmp_name'], UPLOAD_DIRECTORY . DIRECTORY_SEPARATOR . $newname); if ($copied === FALSE) { $errors[] = "File {$file['name']} could not be uploaded."; } } } } ?> <div id="mainWrapper"> <div id="main"> <div class="top_bg"></div> <div class="description_pane"> <h2>Upload More Photos</h2> <?php if (!empty($errors)) { echo "<ul>"; foreach ($errors as $error) { echo "<li>{$error}</li>"; } echo "</ul>"; } ############################### HTML FORM while($i++ < $upload_image_limit){ $form_img .= '<label>Image '.$i.': </label> <input type="file" name="image'.$i.'"><br /><br />'; } $htmo .= ' <form method="post" action="" enctype="multipart/form-data"> '.$form_img.' <br /> <input type="submit" value="Upload Images" name="Submit" style="margin-left: 50px;" /> </form> '; echo $htmo; ?> <br /> </div> </div><!--end main --> <div class="main_bottom"></div> </div><!--end mainWrapper --> <? include '../templates/footer.php'; ?>
×
×
  • 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.