Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. You might want to consider loading your database as two tables, one with the data from the Catalog section and the other with the Installed equipment data. You can then JOIN on reference to get the data you want From From <Catalog> <Installed> +---------------+ +-------------+ | EquipmentSpec | | Equipment | +---------------+ +-------------+ | Reference PK |----+ | Id | | Type | +------| Reference | +---------------+ | Height | +-------------+
  2. Can you post the output from this echo '<pre>',print_r($result, true),'</pre>';
  3. Running my same code on your XML in #14 gives TWO MAT_6890 | Node | 27 | 140 MAT_50 | Single | 28 | 180
  4. I used the XML you gave in reply #8 in which your expected results were given as Mine gave MAT_4 | Duplexeur | 26 | 160 MAT_6890 | Node | 27 | 140 MAT_50 | Single | 28 | 180 If my maths is right, that's THREE
  5. My code, which searched for a matching reference in the installed section, finds 3 matches, not 2 foreach ($xml->xpath("//Catalog/EquipmentSpec") as $n => $equipmentspec) { $ref = (string)$equipmentspec->Reference; $type = (string)$equipmentspec->Type; $installed = $xml->xpath("//Installed/Equipment[Reference='$ref']"); if ($installed) { foreach ($installed as $inst) { $id = (string)$inst->Id; $heightObj = $inst->xpath("Characteristic[CharacteristicName='Height']"); $height = (string)$heightObj[0]->CharacteristicValue; echo "$ref | $type | $id | $height<br>"; // insertion to db here } } } Output MAT_4 | Duplexeur | 26 | 160 MAT_6890 | Node | 27 | 140 MAT_50 | Single | 28 | 180
  6. 1. Don't leave a space between function name and the "(". ie IF() and not IF () ). 2. The WHERE clause should be WHERE category = 'Image' OR category = 'Video', edit Alternative : WHERE category IN ('Image', 'Video')
  7. $d is and object. -> is the notation to call an object's methods or variables. See http://php.net/manual/en/language.oop5.php
  8. Can you show us some sample contents of the keywords fields from those two tables?
  9. if ( ($rollNumber >= 1 && $rollNumber <= 6702) || ($rollNumber >= 7101 && $rollNumber <= 7152) || ($rollNumber >= 20001 && $rollNumber <= 103090 ) ) $class = 9; else $class = 10; Take it from there.
  10. The easiest way is use a loop, which is just the same code whether you have 2 or 200 options. The source for the loop can be a query or an array. For this example I'll use an array. <?php $qry=mysql_query("SELECT * FROM reg_table where id=$id "); $res=mysql_fetch_array($qry); $radio = $res['gender']; $genders = array ( 'male' => 'Male', 'female' => 'Female' ); $genderOptions = ''; foreach ($genders as $val => $text) { $chk = $val==$radio ? "checked='checked'" : ''; $genderOptions .= "<input type='radio' name='gender' value='$val' $chk />$text<br>"; } echo "Gender<br>$genderOptions"; ?>
  11. or you can do as I did in this other topic http://forums.phpfreaks.com/topic/281136-half-a-timezone/
  12. If the the record already contains the new values then no update occurs (as it is not required). In this case, affected rows will be zero.
  13. If you want a JS solution don't post in PHP forum. Moving to JS forum.
  14. Thanks guys.
  15. I always thought timezones had differences of whole hours. Can anyone explain the output below? <?php $d = new DateTime(); $d->setTimezone(new DateTimeZone('Europe/London')); echo "<pre>London\t\t" . $d->format ('H:i:s') . '<br>'; $d->setTimezone(new DateTimeZone('Asia/Hong_Kong')); echo "Hong Kong\t" . $d->format ('H:i:s') . '<br>'; $d->setTimezone(new DateTimeZone('Asia/Calcutta')); echo "Calcutta\t" . $d->format ('H:i:s') . '</pre>'; ?> output London 19:45:35 Hong Kong 02:45:35 Calcutta 00:15:35 (15 minutes ???)
  16. My apologies for assuming MySQL was being used when answering a question in the MySQL Help forum
  17. Have you looked at SQL Server's BULK LOAD command for loading CSV data?
  18. perhaps $str = "<MediaFiles> <MediaFile> <![CDATA[VIDEO1]]> </MediaFile> <MediaFile> <![CDATA[VIDEO2]]> </MediaFile> <MediaFile> <![CDATA[VIDEO3]]> </MediaFile> <MediaFile> <![CDATA[VIDEO4]]> </MediaFile> <MediaFile> <![CDATA[VIDEO5]]> </MediaFile> </MediaFiles>"; $xml = simplexml_load_string($str); foreach ($xml->MediaFile as $video) { $mf[] = trim((string)$video); } echo $mf[array_rand($mf)];
  19. Add ORDER BY place_total DESC LIMIT 1
  20. Use the values of the combos to determine which image then use image tag src attribute to specify that image
  21. do not put column names inside quotes, it treats it as a string literal if you do
  22. or echo $dt->getTimestamp(); // 3
  23. Font size 1! Do you work for an insurance company?
  24. $timestamp = strtotime($date);
  25. I have no idea what class you you are using when you mention $this->db->where, but I would find another one with reliable code.
×
×
  • 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.