Hi James,
I think your second listing should actually be coded:-
$listing = [
'one' => $x,
'two' => $y,
'three' => $z
];
Hi James,
I think your second listing should actually be coded:-
$listing = [
'one' => $x,
'two' => $y,
'three' => $z
];
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>';
}
}
Just noticed the inner $key should be $key2
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>';
}
}
Hi diafol,
I think that is a personal preference. I myself prefer to use the alternative PHP syntax and simply output PHP variables inline.
<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.
Hi,
Sorry for the delay in replying. Can you describe in a non-technical way what it is that you are wanting to achieve?
This type of id?
<img id="457" src="image.png">
What is part ? is it a string of html or a numeric ?
I've created a small piece of code based on yours, but without the frills, for you to review.
Hi,
.val() is for form values. you need to use .text()
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
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.
We agreed "filename", so your call should be
localhost/test/fileprogram/ajax/check-file.php?filename=image25.jpg
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);
?>
line 73 is missing a semi-colon
Can you post some of the table, including the select.
<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>
It would help if the CSS page were available.
What is it's purpose in refreshing every 10 seconds?
Do you record the amount of times it's reloaded?
oops, should have asked did you want 2,3,4 or 2,2,3,3,4 ?
(prompted by pritaeas's code).
2,3,4 or 2,2,3,4 ?
Sorry. I should have said "First, without the file being present, and then again with the file being present".
Sorry.
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.
Sorry it's taking a while to get there. Can you confirm this folder?
C:\xampp\htdocs\test\fileprogram\assets\files
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.
Let's pick one and stick with it:-
?
do you have localhost/test/fileprogram/assets/files/image25.jpg ?
Now place an image25.jpg into your /assets/files folder and rerun.
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;
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');
}
Is this "your" website or just a website you happened to come across?
Where is your undownloaded html file?
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.
Does it work properly when you download it?
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.
Is your code running from localhost or do you have a copy on an externally hosted platform?
Can you post the HTML that you want JavaScript to work with?
Are you saying that none of your pages are displaying $_SESSION['username'] ?
There's no need for two forms. A single form will suffice.
The form handler can redirect based on form information received.
No. (now waiting to be corrected:)
Do you "own/control" both sites?
Sorry, I'm still not understanding. Can you take me through what you want to happen step-by-step. No code.
Cut lines 65-69 out. Save them into a temp file, it may be that they are used in other page types.
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
That's what the bottom link is for ;-)