paulkd 59 Newbie Poster

Hi James,

I think your second listing should actually be coded:-

$listing = [
    'one' => $x,
    'two' => $y,
    'three' => $z
];
paulkd 59 Newbie Poster

Hi,

Try not to use for loops to iterate an array. I'm not sure what you are trying to achieve, but i've constructed similar data and looped through it. Hope it helps.

$array = array(
    '798D25C0DEABD' => array('quantity' => 1, 'price' => 20.5),
    '40B2B0FA3D222' => array('quantity' => 1, 'price' => 14.75)
);

//PHP 5.4
$array = [
    '798D25C0DEABD' => ['quantity' => 1, 'price' => 20.5],
    '40B2B0FA3D222' => ['quantity' => 1, 'price' => 14.75]
];

//print_r($array);

foreach($array as $key1 => $array2){
    echo $key1.'<br>';
    foreach($array2 as $key2 => $value){
        echo '---- '.$key2.' = '.$value.'<br>';
    }
}
paulkd 59 Newbie Poster

Just noticed the inner $key should be $key2

paulkd 59 Newbie Poster

Hi James,

$response[] = will create (if it doesn't exist) or append the right-hand value to the $response array. So if $html->data->identifier is a simple string, e.g. 'Price', then a new array would be ['Price'] or array(0=>'Price')

$order->get_items() appears to be a nested object not an array. I've created a copy and iterated through it below.

        $obj = (object) array(365 => (object) array('name'=>'steel wool 3', 'qty' => 1) );
        //print_r($obj);
        foreach($obj as $key => $obj2) {
            foreach($obj2 as $key => $value) {
                echo $value.'<br>';
            }
        }
negitron commented: u cant code m8 +0
cereal commented: +1 +13
paulkd 59 Newbie Poster

Hi diafol,

I think that is a personal preference. I myself prefer to use the alternative PHP syntax and simply output PHP variables inline.

paulkd 59 Newbie Poster
<style>.selected {background: yellow}</style>
<?php 

$menu[] = array('menu_id' => 1, 'menu_text'  => 'Home');
$menu[] = array('menu_id' => 2, 'menu_text'  => 'Service');
$menu[] = array('menu_id' => 3, 'menu_text'  => 'About Us');
$menu[] = array('menu_id' => 4, 'menu_text'  => 'Contact Us');

$selected = (isset($_GET['side']) and !preg_match('/\D/',$_GET['side'])) ? $_GET['side'] : 0;

$i = 0;
echo '<ul>';
while ($i < count($menu)) {
  $row_menu = $menu[$i];
  echo $selected == $row_menu['menu_id'] ? '<li class="selected">' : '<li>';
  echo '<a href="index.php?side='.$row_menu['menu_id'].'">'.$row_menu['menu_text'].'</a>';
  echo '</li>';
  $i++;
}
echo '</ul>';

I've emulated your db with an array.
As above comments, use CSS for styling.
As I'm a fan of minimalist php code, if your project allows Javascript, I would probably look at using Javscript to apply the style.
I spend far too much time thinking what to call my variables, but I think you should use "active" rather than "selected" as "selected" is almost a reserved word in HTML.

paulkd 59 Newbie Poster

Hi,

Sorry for the delay in replying. Can you describe in a non-technical way what it is that you are wanting to achieve?

paulkd 59 Newbie Poster

This type of id?

<img id="457" src="image.png">
paulkd 59 Newbie Poster

What is part ? is it a string of html or a numeric ?

paulkd 59 Newbie Poster

I've created a small piece of code based on yours, but without the frills, for you to review.

http://jsfiddle.net/z04bpvky/1/

paulkd 59 Newbie Poster

Hi,

.val() is for form values. you need to use .text()

paulkd 59 Newbie Poster

Hi kanoy83.

This is very odd indeed.
We are seeing the correct results.
But your error message references a physical path that your web address is not using - ...test\fileprogram\ajax and ...test/filecms_v0_9/ajax

paulkd 59 Newbie Poster

404 error pages on your website?

paulkd 59 Newbie Poster

Following minitauros's cloning idea I came up with this...

var fValue = 'test';
var $tableBody = $("#yourTableId tbody");
var $clone = $tableBody.clone();
$clone.find("select").remove();
$clone.find("td:nth-child(2)").not(":contains("+fValue+")").parent().remove();
$tableBody.parent().html($clone);

It replaces your table. I've added some further selection data for my tests.

paulkd 59 Newbie Poster

We agreed "filename", so your call should be

localhost/test/fileprogram/ajax/check-file.php?filename=image25.jpg
paulkd 59 Newbie Poster

Hi,

I would hope that you have some PHP knowledge. If so, here is some very basic code to save your uploaded file to the server. You will need to substitute your own $dest value.

post-cv-action.php

<?php 

$filename = $_FILES['attachment']['name'];
$source = $_FILES['attachment']['tmp_name'];
$dest = $_SERVER['DOCUMENT_ROOT'].'/test/';
move_uploaded_file($source,$dest.$filename);

?>
paulkd 59 Newbie Poster

line 73 is missing a semi-colon

paulkd 59 Newbie Poster

Can you post some of the table, including the select.

paulkd 59 Newbie Poster
<img src="" id="pics">
<script>
var m=new Date();
var imageArray = [
    "Holiday/HolidayDesktops/Newyear.jpg",
    "Holiday/HolidayDesktops/Vday.jpg",
    "Holiday/HolidayDesktops/St.Patday.jpg",
    "Holiday/HolidayDesktops/Easter.jpg",
    "Holiday/HolidayDesktops/MemorialDay.jpg",
    "Holiday/HolidayDesktops/NatFlagDay.jpg",
    "Holiday/HolidayDesktops/July4.jpg",
    "Holiday/HolidayDesktops/WomensEqualityDay.jpg",
    "Holiday/HolidayDesktops/LaborDay.jpg",
    "Holiday/HolidayDesktops/Halloween.jpg",
    "Holiday/HolidayDesktops/Thanksgiving.jpg",
    "Holiday/HolidayDesktops/Christmas.jpg",
];
document.getElementById("pics").src=imageArray[m.getMonth()];
</script>
paulkd 59 Newbie Poster

It would help if the CSS page were available.

paulkd 59 Newbie Poster

What is it's purpose in refreshing every 10 seconds?
Do you record the amount of times it's reloaded?

paulkd 59 Newbie Poster

oops, should have asked did you want 2,3,4 or 2,2,3,3,4 ?
(prompted by pritaeas's code).

paulkd 59 Newbie Poster

2,3,4 or 2,2,3,4 ?

paulkd 59 Newbie Poster

Sorry. I should have said "First, without the file being present, and then again with the file being present".

Sorry.

paulkd 59 Newbie Poster

It's untested code, but your ajax file C:\xampp\htdocs\test\fileprogram\ajax\checkfile.php should now be this:-

<?php 
    echo file_exists($_SERVER['DOCUMENT_ROOT'].'/test/fileprogram/assets/files/'.$_GET['filename']) ? json_encode(array(1)) : json_encode(array(0));
?>

and called like this:-

localhost/test/fileprogram/ajax/check-file.php?filename=image25.jpg

first without the file being present, and then again, with the filename being present.

paulkd 59 Newbie Poster

Sorry it's taking a while to get there. Can you confirm this folder?

C:\xampp\htdocs\test\fileprogram\assets\files

paulkd 59 Newbie Poster

I want to get the ajax filechecker working first.

Change localhost/test/fileprogram/ajax/checkfile.php to

<?php echo  $_SERVER['DOCUMENT_ROOT'];  ?>

Run and paste the results here please.

paulkd 59 Newbie Poster

Let's pick one and stick with it:-

  1. filename or
  2. filepage

?

paulkd 59 Newbie Poster

do you have localhost/test/fileprogram/assets/files/image25.jpg ?

paulkd 59 Newbie Poster

Now place an image25.jpg into your /assets/files folder and rerun.

paulkd 59 Newbie Poster

overwrite line 16 (above) with this:-

$id = 1000;

$key = array_search($id, $cart['data']['product_id']);
if($key!==FALSE) {
    unset($cart['data']['product_id'][$key]);
    unset($cart['data']['quantity'][$key]);
}
print_r($cart);
die;
paulkd 59 Newbie Poster

Using your original code and looking at header in the php.net documentation I've constructed this:-

if(file_exists($filename)) {
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.$filename.'"');
    readfile($filename);
} else {
    die('not ok');
}
paulkd 59 Newbie Poster

You change the code in this file (and the others) from issuing a header which is forcing a download.

paulkd 59 Newbie Poster

You just need to read a little more.

Here's one article from a google search. I've picked mysqli rather than mysql as mysql is so last year :-)

paulkd 59 Newbie Poster

This page clearly states "download links". So it would seem that to download is the required result.

paulkd 59 Newbie Poster

Is this "your" website or just a website you happened to come across?

paulkd 59 Newbie Poster

Where is your undownloaded html file?

paulkd 59 Newbie Poster

Instead of this route, you could allow the user to enter two recipients separated by either a comma or semi-colon - similar to how many email clients work.

paulkd 59 Newbie Poster

Does it work properly when you download it?

paulkd 59 Newbie Poster

Will your code always be running localhost or will you copy to a hosted server? if yes, you should try a couple of small test files and see if the problem is only on your local dev environment.

paulkd 59 Newbie Poster

Is your code running from localhost or do you have a copy on an externally hosted platform?

paulkd 59 Newbie Poster

Can you post the HTML that you want JavaScript to work with?

paulkd 59 Newbie Poster

Are you saying that none of your pages are displaying $_SESSION['username'] ?

paulkd 59 Newbie Poster

There's no need for two forms. A single form will suffice.
The form handler can redirect based on form information received.

paulkd 59 Newbie Poster

I saw this blog article yesterday on a similar topic.

paulkd 59 Newbie Poster

No. (now waiting to be corrected:)

Do you "own/control" both sites?

paulkd 59 Newbie Poster

Sorry, I'm still not understanding. Can you take me through what you want to happen step-by-step. No code.

paulkd 59 Newbie Poster

Cut lines 65-69 out. Save them into a temp file, it may be that they are used in other page types.

paulkd 59 Newbie Poster

I just tried you previous link and that has too many http:// in it so can you change

echo JHtml::link('http://' .$value[0]['url'].'?tag=romautjudrai-20', "<img src='".JURI::root()."images/library/amazon.png'>", $options ) ;

to

echo JHtml::link($value[0]['url'].'?tag=romautjudrai-20', "<img src='".JURI::root()."images/library/amazon.png'>", $options ) ;

and see what happens when you click the link

paulkd 59 Newbie Poster

That's what the bottom link is for ;-)