Jump to content

kamal213

Members
  • Posts

    198
  • Joined

  • Last visited

Posts posted by kamal213

  1. Hi guys,

     

    I have this SQL query which I use in my PHP search script

    $query_for_result=mysql_query("SELECT * FROM customer WHERE c_name like '%".$query."%' OR c_telephone like '%".$query."%' OR c_address like '%".$query."%'");

     

    It works fine, the only problem is now my database is bigger I would like to be able do SORT or ORDER BY id so that my search results are in order from asc to desc.

     

    Is this possible? if so can you help me.

     

    Thanks

  2. Hi guys,

     

    I exported my database table in excel format and when I open get the following error:

    <br />

    <b>Fatal error</b>:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 60 bytes) in <b>C:\xampp\phpMyAdmin\libraries\PHPExcel\PHPExcel\Worksheet.php</b> on line <b>920</b><br />[/qoute]

     

    Any ideas?

     

    One solution I came up with was to export as CSV for Excel but unfortunately all the entries are with commas so I like to convert the CSV file into XLS please I need you help guys thanks.

  3. Hi guys,

     

    I exported my database table in excel format and when I open get the following error: [qoute]<br />

    <b>Fatal error</b>:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 60 bytes) in <b>C:\xampp\phpMyAdmin\libraries\PHPExcel\PHPExcel\Worksheet.php</b> on line <b>920</b><br />[/qoute]

     

    Any ideas?

     

    One solution I came up with was to export as CSV for Excel but unfortunately all the entries are with commas so I like to convert the CSV file into XLS please I need you help guys thanks.

     

  4. Hi Guys,

     

    I have a simple PHP search facility (Below this post) for my customer system which uses a input form so users enter a customers name/telephone/address and it echos the result.

     

    Its great but I observed as my customer table got bigger the search got less accurate, what i mean is when you search for mr test is give ur mr test along with mr andy and ms danielle.

     

    Its ok but those any know how to make my search code better or can y'all help me with a better php search script.

     

    Thanks.

     

    <?php $query=$_GET['query'];
    			$query= str_replace("'","",$query);
    
    			// Change the fields below as per the requirements 
    			$db_host="localhost";
    			$db_username="root";
    			$db_password="";
    			$db_name=""; 
    			$db_tb_name="customer"; 
    			$db_tb_atr_name="c_name"; 
    			$query= str_replace("'","",$query);
    			//Now we are going to write a script that will do search task 
    		       // leave the below fields as it is except while loop, which will display results on screen 
    
    			mysql_connect("$db_host","$db_username","$db_password");
    		 	mysql_select_db("$db_name"); 
    
    			$query_for_result=mysql_query("SELECT * FROM customer WHERE c_name like '%".$query."%' OR c_telephone like '%".$query."%' OR c_address like '%".$query."%'");
    			while($row=mysql_fetch_assoc($query_for_result)) { 
    			 $c_id = $row['c_id'];
    			 $c_name = $row["c_name"];
    			 $c_address = $row["c_address"];
    			 $c_postcode = $row["c_postcode"];
    			 $c_city = $row["c_city"];
    			 $c_telephone = $row["c_telephone"];
    			 $c_email = $row["c_email"];
    			 $salesman = $row["salesman"];
    			 echo '<table width="100%" border="0">
                      <tr>
                        <td><a href="customers.php?id=' . $c_id . '"> ' . $c_name . '</a> -
                        ' . $c_address . ' - ' . $c_city . ' - ' . $c_telephone . '• <a href="customer_edit_index.php?pid=' . $c_id . '">edit</a><br /><br/></td>
                      </tr>
                    </table>';
    			}  
                                    mysql_close(); ?>
    

  5. Hi guys I have this date script below which displays like so: 16/09/2011.

     

    Its fine but I now like it to display like this: 16 September 2011

     

    Please I need help in twicking the code to do this Thanks!

     

    <?php
    //check to see if passing variable is set i.e. if true get day, month, year.
    if(isset($_GET['day'])){
    $day = $_GET['day'];
    } else{
    //Get today's date and put them in date, month, year
    $day = date("d");
    }
    if(isset($_GET['month'])){
    $month = $_GET['month'];
    } else{
    $month = date("m");
    }
    if(isset($_GET['year'])){
    $year = $_GET['year'];
    } else{
    $year = date("Y");
    }
    
    echo $day."/".$month."/".$year;
    
    ?>

  6. Thanks for getting back!

     

    The image dimension exactly.

     

    Basically after the file have been uploaded I display a link in the front-end were user can click to view the file, so the problems is when user click on the link (especially pdf's) its open and its about 230% zoom and they keep changing it to about 80-90%.

     

    I want to make it smaller automatically to about 80-90% save them the hassle of doing it manually everytime so i figure have to somehow resize the dimension so it looks smaller when users open the file.

  7. Hi Guys,

     

    I have this script below which inserts the file name and path into my datebase and uploads the file into the customers folders (which is creates dynamically).

     

    The is no error checking as I want it to be as flexible as possible but mostly(99.999%) the files I upload are JPEG and PDF's.

     

    I would like my script to be able to resize the files above automatically to be smaller.

     

    Please is this possible thanks!

     

    Here is script:

    <?php 
    //Will create a directory once a customer is clicked and will not if page is refreshed an so forth 
    		 if (file_exists('customerUploads/' . $check_id . ', ' . $c_name . '')) {
    
    		} else {
    		  mkdir('customerUploads/' . $check_id . ', ' . $c_name . '');
    		}
    ?>
    <?php 
    //This php block of code will takecare of inserting the upload variables into the db
    
    if(isset($_POST['submitbutton'])) {
    
    $target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';
    $target_path = str_replace("'","",$target_path);		
    $target_path = $target_path . basename( $_FILES['upload']['name']);
    $manager= mysql_real_escape_string($_POST['username']);
    $upload =  $_FILES['upload']['name'];
    $upload = str_replace("'","",$upload);
    $check_id = mysql_real_escape_string($_POST['id']);
    $submitbutton= mysql_real_escape_string($_POST['submitbutton']);
    
    
    if($submitbutton)
    {
    if($manager&&$upload)
    {
    if (file_exists($target_path))
    {
    echo $_FILES["upload"]["name"] . " already exists. ";
    }
    else
    {
    move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path);
    
    echo "Stored in: " . 'customerUploads/' . $check_id . ', ' . $c_name . '/' . $_FILES["upload"]["name"];
    
    $insert=mysql_query("INSERT INTO img_up (username,upload,id,target_path,img_date) VALUES ('$manager','$upload','$check_id','$target_path', now()) ");
    
    		// Where the file is going to be placed 
    		$target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';
    
    		/* Add the original filename to our target path.  
    		Result is "uploads/filename.extension" */
    		$target_path = $target_path . basename( $_FILES['upload']['name']); 
    
    		$target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';
    
    		$target_path = $target_path . basename( $_FILES['upload']['name']); 
    
    		if (file_exists($target_path))
    		{
    		echo $_FILES["upload"]["name"] . " already exists. ";
    		}
    		else
    		{
    		move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path);
    		echo "Stored in: " . 'customerUploads/' . $check_id . ', ' . $c_name . '/' . $_FILES["upload"]["name"];
    		}
    
    
    }
    }
    else
    {
    echo "There was an error uploading the file, please try again!";
    }
    }
     header("location: mainupload_complete.php?id=$check_id"); 
    }
    ?>

  8. I have included it just as shown below but it doesnt seem to work am obviously doin something wrong.

     

    <?php 
    //This php block of code will takecare of inserting the upload variables into the db
    
    if(isset($_POST['submitbutton'])) {
    $target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';		
    $target_path = $target_path . basename( $_FILES['upload']['name']);
    $manager= mysql_real_escape_string($_POST['username']);
    $upload =  $_FILES['upload']['name'];
    $upload = str_replace("'","",$upload);
    $check_id = mysql_real_escape_string($_POST['id']);
    $submitbutton= mysql_real_escape_string($_POST['submitbutton']);
    
    
    if($submitbutton)
    {
    if($manager&&$upload)
    {
    if (file_exists($target_path))
    {
    echo $_FILES["upload"]["name"] . " already exists. ";
    }
    else
    {
    move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path);
    echo "Stored in: " . 'customerUploads/' . $check_id . ', ' . $c_name . '/' . $_FILES["upload"]["name"];
    
    $insert=mysql_query("INSERT INTO img_up (username,upload,id,target_path,img_date) VALUES ('$manager','$upload','$check_id','$target_path', now()) ");
    
    		// Where the file is going to be placed 
    		$target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';
    
    		/* Add the original filename to our target path.  
    		Result is "uploads/filename.extension" */
    		$target_path = $target_path . basename( $_FILES['upload']['name']); 
    
    		$target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';
    
    		$target_path = $target_path . basename( $_FILES['upload']['name']); 
    
    		if (file_exists($target_path))
    		{
    		echo $_FILES["upload"]["name"] . " already exists. ";
    		}
    		else
    		{
    		move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path);
    		echo "Stored in: " . 'customerUploads/' . $check_id . ', ' . $c_name . '/' . $_FILES["upload"]["name"];
    		}
    
    
    }
    }
    else
    {
    echo "There was an error uploading the file, please try again!";
    }
    }
     header("location: mainupload_complete.php?id=$check_id"); 
    }
    ?>[/code[]

  9. Hi Guys

     

    I have this PHP Upload Scripts below which uploads file of customers into the customers folder and at the same time inserts the file path into the database.

     

    The problems is for name like O'hare or O'neil its uploads into the customers folder but does not insert the file path into the database - probably because of the " ' " apostrophe

     

    From the code below is there anyway I can deal with this issue?  Thanks alot

     

    <?php 
    //This php block of code will takecare of inserting the upload variables into the db
    
    if(isset($_POST['submitbutton'])) {
    $target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';		
    $target_path = $target_path . basename( $_FILES['upload']['name']);
    $manager= mysql_real_escape_string($_POST['username']);
    $upload =  $_FILES['upload']['name'];
    $check_id = mysql_real_escape_string($_POST['id']);
    $submitbutton= mysql_real_escape_string($_POST['submitbutton']);
    
    
    
    if($submitbutton)
    {
    if($manager&&$upload)
    {
    if (file_exists($target_path))
    {
    echo $_FILES["upload"]["name"] . " already exists. ";
    }
    else
    {
    move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path);
    echo "Stored in: " . 'customerUploads/' . $check_id . ', ' . $c_name . '/' . $_FILES["upload"]["name"];
    
    $insert=mysql_query("INSERT INTO img_up (username,upload,id,target_path,img_date) VALUES ('$manager','$upload','$check_id','$target_path', now()) ");
    
    		// Where the file is going to be placed 
    		$target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';
    
    		/* Add the original filename to our target path.  
    		Result is "uploads/filename.extension" */
    		$target_path = $target_path . basename( $_FILES['upload']['name']); 
    
    		$target_path = 'customerUploads/' . $check_id . ', ' . $c_name . '/';
    
    		$target_path = $target_path . basename( $_FILES['upload']['name']); 
    
    		if (file_exists($target_path))
    		{
    		echo $_FILES["upload"]["name"] . " already exists. ";
    		}
    		else
    		{
    		move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path);
    		echo "Stored in: " . 'customerUploads/' . $check_id . ', ' . $c_name . '/' . $_FILES["upload"]["name"];
    		}
    
    
    }
    }
    else
    {
    echo "There was an error uploading the file, please try again!";
    }
    }
     header("location: mainupload_complete.php?id=$check_id"); 
    }
    ?>
    

×
×
  • 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.