Jump to content

Search the Community

Showing results for tags 'classes'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 3 results

  1. Hello, to my experience the following does not work (tryit-editor w3School), but it does with a "while" loop instead. Are "for" loops not allowed within classes? <p id="demo">result</p> class Test{ counter(){ var result=0; for(i=0;i<10;i++){ result++; } return result; } counter2(){ var result=0; while(result<10){ result++; } return result; } } var obj=new Test(); document.getElementById("demo").innerHTML=obj.counter(); //document.getElementById("demo").innerHTML=obj.counter2();
  2. Hello W3 People!. i have downloaded a picture upload class from here: verot.net.and working perfectly for my kind of coding in the schools. but i have never tried to make a (UPDATE) page of this kind of stuff where its deleting a picture and then uploading a new one dynamicly... and it does uploads the images correctly 100% and resizing them, and stuff like that... but it wont delete the older pictures, and update the Database Tables/Rows with the new image URL (witch are just the name of the the picture... im defining the path the diffrent places myself...) ideas?... here is my code [A LITTLE LONG...]: <?phpsession_start();ob_start();require_once("../db_conn.php");require_once("../login_checker_noroot.php");require_once("pic_mobel_uploader/class/class.upload.php");echo "<a href='index.php'>Tilbage Til Forsiden</a>"; if(!empty($_GET['m_id'])){$mid = $_GET['m_id'];$query = "SELECTdesigner.designer_navn,serie.serie_navn,produkter.design_aar,produkter.pris,produkter.vare_nr,produkter.information,produkter.produkt_navnFROMprodukter INNER JOIN serie ON produkter.FK_serie = serie.id INNER JOIN designer ON produkter.FK_designer = designer.d_id WHERE produkter.id = $mid";$result = mysql_query($query)or die(mysql_error());while($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $p_navn = $row['produkt_navn']; $serie = $row['serie_navn']; $designer = $row['designer_navn']; $v_nr = $row['vare_nr']; $aar = $row['design_aar']; $pris = $row['pris']; $tekst = $row['information'];}//While Statement Ends... if(isset($_POST['Submit'])){$p_navnn = mysql_real_escape_string($_POST['p_navn']);$seriee = mysql_real_escape_string($_POST['serie']);$designerr = mysql_real_escape_string($_POST['designer']);$v_nrr = mysql_real_escape_string($_POST['v_nr']);$aarr = mysql_real_escape_string($_POST['aar']);$priss = mysql_real_escape_string($_POST['pris']);$tekstt = mysql_real_escape_string($_POST['tekst']);/*===================================*//*===================================*//*===================================*/if($_FILES['image'] >= 1)//bigger then one...{$pID = $_GET['m_id'];$queryImg = "SELECT * FROM image_url WHERE FK_produkt_id = " . $pID;$resultImg = mysql_query($queryImg)or die(mysql_error());while($rowImg = mysql_fetch_array($resultImg)){unlink('../../images/home_news_form/'.$rowImg['img_url']);unlink('../../images/mobel_details_big/'.$rowImg['img_url']);unlink('../../images/mobel_details_thumps_small/'.$rowImg['img_url']);unlink('../../images/mobel_liste_form/'.$rowImg['img_url']);}// as it is multiple uploads, we will parse the $_FILES array to reorganize it into $files$files = array();foreach ($_FILES['image'] as $k => $l){foreach ($l as $i => $v){ if(!array_key_exists($i, $files)) $files[$i] = array(); $files[$i][$k] = $v;}}// now we can loop through $files, and feed each element to the classforeach ($files as $file){if(!empty($_FILES['image']))//allways form name...{// we instanciate the class for each element of $file$handle = new Upload($file);//$file for the new (array images upload) to work...//$handle = new Upload($_FILES['image']); //OLD ONE... if ($handle->uploaded){ $handle->image_resize = true; $handle->image_ratio = true; $handle->image_x = 110; //Width in Pixels... $handle->image_y = 80; //Height in Pixels... $handle->Process('../../images/home_news_form/');}if ($handle->uploaded){ $handle->image_resize = true; $handle->image_ratio = true; $handle->image_x = 300; //Width in Pixels... $handle->image_y = 225; //Height in Pixels... $handle->Process('../../images/mobel_details_big/');}if ($handle->uploaded){ $handle->image_resize = true; $handle->image_ratio = true; $handle->image_x = 50; //Width in Pixels... $handle->image_y = 50; //Height in Pixels... $handle->Process('../../images/mobel_details_thumps_small/');}if ($handle->uploaded){ $handle->image_resize = true; $handle->image_ratio = true; $handle->image_x = 120; //Width in Pixels... $handle->image_y = 90; //Height in Pixels... $handle->Process('../../images/mobel_liste_form/');$image = $handle->file_dst_name;$produktID = $_GET['m_id']; mysql_query("UPDATE image_url SET img_url='$image', FK_produkt_id='$produktID' WHERE FK_produkt_id = ".$pID)or die(mysql_error());}}//end empty (FILES) statement...}//end foreach statement...}//if (FILES['image']) ends.../*===================================*//*===================================*//*===================================*/$query = "UPDATE produkter SET produkt_navn = '$p_navnn', FK_serie = '$seriee', FK_designer = '$designerr', vare_nr = '$v_nrr', design_aar = '$aarr', pris = '$priss', information = '$tekstt' WHERE id = $mid";mysql_query($query)or die(mysql_error());header("location:index.php");}//submit ends...}//IF !empty Statement Ends...else{ $p_navn = "NO ID SELECTED!..."; $serie = "NO ID SELECTED!..."; $designer = "NO ID SELECTED!..."; $v_nr = "NO ID SELECTED!..."; $aar = "NO ID SELECTED!..."; $pris = "NO ID SELECTED!..."; $tekst = "NO ID SELECTED!...";}?> <fieldset><legend>Redigering Af Vare</legend><form method="post" action="" enctype="multipart/form-data"><table border="1" align="center"><tr><td>Produkt Navn</td><td><input type="text" name="p_navn" value="<?php echo $p_navn; ?>" /></td></tr><tr><td>Serie</td><td><select name="serie"><option value="0">Vælg Serie</option><?php $m_query = "SELECT * FROM serie"; $m_result = mysql_query ($m_query)or die(mysql_error()); while ($m_row = mysql_fetch_array ($m_result)) { echo "<option value='" .$m_row['id']."'>" .$m_row['serie_navn']."</option>"; }?></select></td></tr><tr><td>Designer</td><td><select name="designer"><option value="0">Vælg Designer</option><?php$d_query = "SELECT * FROM designer";$d_result = mysql_query ($d_query)or die(mysql_error());while ($d_row = mysql_fetch_array ($d_result)){ echo "<option value='" .$d_row['d_id']."'>" .$d_row['designer_navn']."</option>";}?></select></td></tr><tr><td>Vare Nummer</td><td><input type="text" name="v_nr" value="<?php echo $v_nr; ?>" /></td></tr><tr><td>Aar</td><td><input type="text" name="aar" value="<?php echo $aar; ?>" /></td></tr><tr><td>Pris</td><td><input type="text" name="pris" value="<?php echo $pris; ?>" /></td></tr><?php$produkt_id = $_GET['m_id'];$query2 = "SELECT * FROM image_url WHERE FK_produkt_id = $produkt_id";$result2 = mysql_query($query2)or die(mysql_error());while($row2 = mysql_fetch_array($result2)){?><tr><td><?php echo "<img src='../../images/mobel_liste_form/".$row2['img_url']."'>"; ?></td><td><input type="file" name="image[]" id="image" /></td></tr><?php}?><tr><td>Teksten Her</td><td><textarea type="text" name="tekst" rows="10" cols="40" /><?php echo $tekst; ?></textarea></td></tr><tr><td> </td><td><input type="submit" name="Submit" value="Rediger Nu!" /></td></tr></table></form></fieldset> Hoping answers soon!... thanks (rootKID)... PS: any questions i need to answer, just ask... and ill try... [AND SORRY, BUT THE MOST OF THE CODING STYLE IS MADE IN DANISH, BUT I AM FROM DENMARK AFTERALL... I HAVE ALSO TRIED TO COMMENT OUT SOME (MOST OF IT) THE STUFF IN ENGLISH, HOPE IT HELPS...)
  3. I've kind taught myself PHP whilst looking online for examples. I use classes, I just wonder if I'm setting up my classes the right way. Do you have to explicity give a class access to another class in the way I've done below?: $db = new dbConnectionMSSQL();$systemLog = new systemLog();$clubTickets = new clubTickets();$Customers = new Customers();$Events = new Events();$TicketOrders = new TicketOrders();$PlacesOfInterest = new PlacesOfInterest();$Tonight = new Tonight(); $clubTickets->db = $db;$clubTickets->Customers = $Customers;$clubTickets->Events = $Events;$clubTickets->PlacesOfInterest = $PlacesOfInterest;$clubTickets->TicketOrders = $TicketOrders;$clubTickets->Tonight = $Tonight; That's what I've been doing up until now. Is there a more efficient way to do it? Every time I create a new class, I need to copy the bold coce above for that class. Or is that just life in PHP?
×
×
  • Create New...