Jump to content

tech0925

Members
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

tech0925's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks everyone!!
  2. I figured it out. I will use the switch statement instead
  3. 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
  4. 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!!!!!!!!!!
  5. Thank you kicken! After doing that how can I use the array in the script?
  6. 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?
  7. 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!!!
  8. 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!
×
×
  • 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.