Jump to content

jade24

Members
  • Posts

    5
  • Joined

  • Last visited

jade24's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've figured it out. I change the $RandomNumber to $ImageName. It works. Thanks for the help.
  2. I am new to php and I've downloaded a free source code for image gallery. It has admin account and you can upload image on it. Now when I upload image it generates random image title like numbers '4849404'. I want it to assign a specific title per image or just simply fetch the file name of the uploaded image and assign it as the title. How can I do that? here is the code.... $RandomNumber = rand(0, 9999999999); // We need same random name for both files. // some information about image we need later. $ImageName = strtolower($_FILES['ImageFile']['name']); $ImageSize = $_FILES['ImageFile']['size']; $TempSrc = $_FILES['ImageFile']['tmp_name']; $ImageType = $_FILES['ImageFile']['type']; $process = true; //Validate file + create image from uploaded file. switch(strtolower($ImageType)) { case 'image/png': $CreatedImage = imagecreatefrompng($_FILES['ImageFile']['tmp_name']); break; case 'image/gif': $CreatedImage = imagecreatefromgif($_FILES['ImageFile']['tmp_name']); break; case 'image/jpeg': $CreatedImage = imagecreatefromjpeg($_FILES['ImageFile']['tmp_name']); break; default: die('Unsupported File!'); //output error } //get Image Size list($CurWidth,$CurHeight)=getimagesize($TempSrc); //get file extension, this will be added after random name $ImageExt = substr($ImageName, strrpos($ImageName, '.')); $ImageExt = str_replace('.','',$ImageExt); $BigImageMaxWidth = $CurWidth; $BigImageMaxHeight = $CurHeight; //Set the Destination Image path with Random Name $thumb_DestRandImageName = $Thumb.$RandomNumber.'.'.$ImageExt; //Thumb name $DestRandImageName = $DestinationDirectory.$RandomNumber.'.'.$ImageExt; //Name for Big Image //Resize image to our Specified Size by calling our resizeImage function. if(resizeImage($CurWidth,$CurHeight,$BigImageMaxWidth,$BigImageMaxHeight,$DestRandImageName,$CreatedImage)) { //Create Thumbnail for the Image resizeImage($CurWidth,$CurHeight,$ThumbMaxWidth,$ThumbMaxHeight,$thumb_DestRandImageName,$CreatedImage); //respond with our images echo '<table width="100%" border="0" cellpadding="4" cellspacing="0"> <tr><td align="center"><img src="gallery/'.$RandomNumber.'.'.$ImageExt.'" alt="Resized Image"></td></tr></table>'; }else{ die('Resize Error'); //output error }
  3. I've figured it out. The query should be: $query = "SELECT * FROM shoe WHERE itemcode LIKE '%".$_POST['search']."%'" or die (mysql_error());
  4. I tried your suggestion. But the result displays only the last row or the last inputted data. And also, I still have this error: Notice: Undefined variable: itemcode in C:\xampp\htdocs\sample3\search.php on line 18
  5. I am working on the search function of my project. And I cant debug this error on my search page: Notice: Undefined variable: itemcode in C:\xampp\htdocs\sample3\search.php on line 18 Notice: Undefined variable: query in C:\xampp\htdocs\sample3\search.php on line 18 ----This is the content of my search page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[url="http://www.w3.org/TR/html4/strict.dtd%22>"]http://www.w3.org/TR...l4/strict.dtd">[/url] <html> <?php // Search Variables include('view.php'); //Create Query $query ["SELECT * FROM shoe WHERE itemcode LIKE '%".$itemcode."%' "] or die(mysql_error()); //$mysql_query = "SELECT * FROM shoe WHERE itemcode='%$itemcode%'" or die (mysql_error()); $result = mysql_query($query) or die (mysql_error()); $num=mysql_numrows($result); mysql_close($dbConn); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $itemcode=mysql_result($result,$i,"itemcode"); $itemdesc=mysql_result($result,$i,"itemdesc"); $color=mysql_result($result,$i,"color"); $size=mysql_result($result,$i,"size"); $price=mysql_result($result,$i,"price"); $qty=mysql_result($result,$i,"qty"); $i++; } ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <input type="hidden" name="itemcode" value="<?php echo $itemcode; ?>"/> <table border="1"> <tr> <td colspan="2"><b><font color='Red'>Inventory Records </font></b></td> </tr> <tr> <td width="150"><b><font color='#663300'>ITEM CODE<em>*</em></font></b></td> <td><label> <?php echo "$itemcode"; ?> </label></td> </tr> <td width="150"><b><font color='#663300'>ITEM DESCRIPTION<em>*</em></font></b></td> <td><label> <?php echo "$itemdesc"; ?> </label></td> </tr> <tr> <td width="150"><b><font color='#663300'>COLOR<em>*</em></font></b></td> <td><label> <?php echo "$color"; ?> </label></td> </tr> <tr> <td width="150"><b><font color='#663300'>SIZE<em>*</em></font></b></td> <td> <?php echo "$size"; ?> </td> </tr> <tr> <td width="150"><b><font color='#663300'>PRICE<em>*</em></font></b></td> <td> <?php echo "$price"; ?> </td> </tr> <tr> <td width="150"><b><font color='#663300'>QUANTITY<em>*</em></font></b></td> <td> <?php echo "$qty"; ?> </td> </tr> </table> </form> </body> </html>
×
×
  • 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.