Jump to content

barney0o0

Members
  • Content Count

    103
  • Joined

  • Last visited

Community Reputation

0 Neutral

About barney0o0

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. Sorry, i dont understand..i think you need to spell it out more literally to me Start repeat C1 <li> <ul> Start repeat C2 <li></li> End repeat C2 </ul> <li> End repeat C1 would you have a mo to tweak what i sent before...my head hurts
  2. Oops spoke too soon I need a tweak on how the record its echo'd The structure of the menu within the repeat would be: <li class="has-dropdown"> <a href="#">'.$c1.'</a> <ul> <li><a href="#">'.$c2.'</a></li> // repeat all C2 records <li><a href="#">'.$c2.'</a></li> // etc etc </ul> </li> // closed li 'has-dropdown', repeat all loop depending in C1 no. of records However the closing ul li is repeating with the no. of records from C2, rather than that of C1...what i have so far is: <?php $sql ="SELECT n1.cat1id , n1.c1_tit_it , n2.c2_tit_it FROM n_cat1 n1 JOIN n_cat2 n2 ON n1.cat1id = n2.cat1link ORDER BY c1_tit_it, c2_tit_it"; $res = $pdo->query($sql); $current = ''; foreach ($res as $row) { $c1 = str_replace(" ", "-", $row['c1_tit_it']); $c2 = str_replace(" ", "-", $row['c2_tit_it']); if ($row['c1_tit_it'] != $current) { echo '<li class="has-dropdown"> <a href="#">'.$c1.'</a> <ul>'; $current = $row['c1_tit_it']; } echo '<li><a href="#">'.$c2.'</a></li>'; ?> </ul> </li><?php } ?>
  3. Thanks Barand..it works like a dream (i didn't think it would )...nice approach that i'd definitely use in the future Many thanks again
  4. Hi Barand, i don't believe a join would work for what i need...unless im misinterpreting your suggestion The output structure would be something like this: $m['c1_tit_it']; (with cat1id of 1) $s['c2_tit_it']; (with sublistid of 1) $s['c2_tit_it']; (with sublistid of 1) $s['c2_tit_it']; (with sublistid of 1) $s['c2_tit_it']; (with sublistid of 1) $m['c1_tit_it']; (with cat1id of 2) $s['c2_tit_it']; (with sublistid of 2) $s['c2_tit_it']; (with sublistid of 2) $m['c1_tit_it']; (with cat1id of 3) $s['c2_tit_it']; (with sublistid of 3) $s['c2_tit_it']; (with sublistid of 3) $s['c2_tit_it']; (with sublistid of 3) etc etc I get your point about select*...its a 3 column table and im being lazy Re. prepared statements - yes, i always do..its just for this example thanks B
  5. Hello...another post in as many days I wish to show all records in a query. 'Within' this loop i need to echo out data from another query that is dependent on the the first query..........so <?php $mm = $pdo->query("SELECT n_cat1.cat1id, n_cat1.c1_tit_it FROM n_cat1 ORDER BY c1_tit_it ASC"); $mm->execute(); while ( $m = $mm->fetchl(PDO::FETCH_ASSOC)) { $sublistid = $m['cat1id']; ?> <html> <title><?php echo $m['c1_tit_it']; ?></title> <subtitle><?php echo $s['c2_tit_it']; ?></subtitle> </html> <?php } ?> For the second query (that would need to populate the <subtitle> (could be 2 - 10 records)) i would have this: $ss = $pdo->query("SELECT * FROM n_cat2 WHERE cat1link ='$sublistid' ORDER BY c2_tit_it ASC"); $ss->execute(); while ( $s = $ss->fetch(PDO::FETCH_ASSOC)) { How would i do this?....before in mysql it was fine to loop within loop, however PDO is a little different and my knowledge is limited To put it in context, the 'n_cat1' is the main menu, whereas the 'n_cat2' is the submenu/s under each main menu, Thanks in advance...hopefully i can leave you all in peace for a while after this
  6. After a quick look, it doesnt incorporate to click/drag to select part of an image you want to resize.....which the one i use does
  7. OK, got it sorted ...thanks requinix...i was working at it too thinking i couldn't reuse some of the strings due to conflicts...heres the working script with both large/small images and watermark on the large image <?php $valid_exts = array('jpeg', 'jpg', 'png', 'gif'); $max_file_size = 20343 * 30124; #200kb $nw = 1600; # image with # height $nh = 627; $nw2 = 800; # image with # height $nh2 = 313; ?> <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ( isset($_FILES['image']) ) { if (! $_FILES['image']['error'] && $_FILES['image']['size'] < $max_file_size) { $ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION)); if (in_array($ext, $valid_exts)) { $path = '../mobili/' . uniqid() . '.' . $ext; $path2 = '../mobili2/' . uniqid() . '.' . $ext; $size = getimagesize($_FILES['image']['tmp_name']); $x = (int) $_POST['x']; $y = (int) $_POST['y']; $w = (int) $_POST['w'] ? $_POST['w'] : $size[0]; $h = (int) $_POST['h'] ? $_POST['h'] : $size[1]; $data = file_get_contents($_FILES['image']['tmp_name']); $vImg = imagecreatefromstring($data); $dstImg = imagecreatetruecolor($nw, $nh); imagecopyresampled($dstImg, $vImg, 0, 0, $x, $y, $nw, $nh, $w, $h); $stamp = imagecreatefrompng('watermark.png'); $marge_right = 30; $marge_bottom = 25; $sx = imagesx($stamp); $sy = imagesy($stamp); imagecopy($dstImg, $stamp, imagesx($dstImg) - $sx - $marge_right, imagesy($dstImg) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp)); imagejpeg($dstImg, $path); imagedestroy($dstImg); $dstImg = imagecreatetruecolor($nw2, $nh2); imagecopyresampled($dstImg, $vImg, 0, 0, $x, $y, $nw2, $nh2, $w, $h); imagejpeg($dstImg, $path2); imagedestroy($dstImg); } else { echo 'unknown problem!'; } } else { echo 'file is too small or large'; } } else { echo 'file not set'; } } else { echo 'bad request!'; } ?>
  8. Would i simply go through the first bit of processing > destroy the image, then do the same again but with different size variables?...if that is the case, do i need to change the strings $dstImg to say $distImg2 to save conflict or am i misread the flow of the code..thanks for your help
  9. HI Chaps, i need someone to hold my hand with this...i have a working script to upload a image (below)...what id like it to do is also create a small image of the cropped image...ive been messing around by simply duplicating the original values, but i just cant get it to work...im not very knowledgeable On the initial page (to browse for the file), i have hidden inputs <input type="hidden" id="x" name="x" /> <input type="hidden" id="y" name="y" /> <input type="hidden" id="w" name="w" /> <input type="hidden" id="h" name="h" /> The its passed onto another page for processing. The $nw/$nh values produce the large image. I would like to add another two values that would create a smaller image (at the same ratio) <?php $valid_exts = array('jpeg', 'jpg', 'png', 'gif'); $max_file_size = 20343 * 30124; #200kb $nw = 1600; # image with # height $nh = 627; ?> <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ( isset($_FILES['image']) ) { if (! $_FILES['image']['error'] && $_FILES['image']['size'] < $max_file_size) { $ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION)); if (in_array($ext, $valid_exts)) { $path = '../mobili/' . uniqid() . '.' . $ext; $size = getimagesize($_FILES['image']['tmp_name']); $x = (int) $_POST['x']; $y = (int) $_POST['y']; $w = (int) $_POST['w'] ? $_POST['w'] : $size[0]; $h = (int) $_POST['h'] ? $_POST['h'] : $size[1]; $data = file_get_contents($_FILES['image']['tmp_name']); $vImg = imagecreatefromstring($data); $dstImg = imagecreatetruecolor($nw, $nh); imagecopyresampled($dstImg, $vImg, 0, 0, $x, $y, $nw, $nh, $w, $h); imagejpeg($dstImg, $path); imagedestroy($dstImg); } else { echo 'unknown problem!'; } } else { echo 'file is too small or large'; } } else { echo 'file not set'; } } else { echo 'bad request!'; } ?> The $path value is added to the database. I hope someone can help, ive spent an afternoon trying many things (badly!)...thanks in advance
  10. Ok, they are the same. cart.php has a link to delete rows from the session values with the url cart.php?xyz with the necessary values ( as in my initial post) to cross check and fire the delete.When I test using cart.php ( as apposed to /cart) it works fine. I don't know what is the correct method is to send to /cart ( which is directed to cart.php (self)) and fire the code to delete the session row ( in the original post)..
  11. Those values are created with the link. The script cross checks the values against the session values. The session script, if OK, then removes the row. As mentioned, the .php file works fine...I don't understand how I can reload the page with the del=1 condition with a seo friendly URL as apposed to the functioning .php file
  12. The only url parameter is the $lang, all the other data is pulled from the session.
  13. The full url is website.com/en/cart The content of the cart.php page is pulled down from both the session 'user' and 'cart' Its a little B2B site, which content is user protected, i know its not ideal, but this should've been a quick fixed thats melting my brain. The above script works fine when using the .php file In the htaccess rewrite file theres a simple 'RewriteRule ^([a-zA-Z_]+)/cart$ cart.php?lang=$1 [L,NC]
  14. HI, its a been a long afternoon....ive inherited partial site to update. Shopping cart works fine, however as ive updated the structure to SEO friendly urls one part isnt working I have a delete button, and script to update the session: <a href="cart.php?rid=x&del=1&pos=y" >delete </a> if($_GET['del']==1 && isset($_GET['rid']) && $_GET['rid']!='' && $_GET['rid']!=0) { $r=$_GET['rid']; $pos=$_GET['pos']; $_SESSION['qty']=$_SESSION['qty']-$_SESSION['cart'][$pos]['qty']; unset($_SESSION['cart'][$pos]); } when using the url cart.php?... all works fine, however, now with seo friendly link (the page is website.com/cart) the page refreshes however doesn't update the session. How do i reconstruct the delete url to reflect the changes on structure so that it works? Thanks in advance
  15. barney0o0

    CONCAT

    Ah, thanks...i didnt realise i could CONCAT 'after' the WHERE clause, hence thinking about aliases...many 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.