Jump to content

kamal213

Members
  • Posts

    198
  • Joined

  • Last visited

Posts posted by kamal213

  1. I havent been here long enough to know all the rules you have listed Muddy_Funster..you obviously have that why you do.

     

    I did what I did because I wanted the perspective of someone good with PHP and someone good with SQL..i simple copied n paste to save time obviously the mistake - Again I wasnt aware of the rules.. I know now.

     

    The code below checks to see if there is a duplicate sales record for a customer when inserting into the table and if there is it redirect to an error page. I want to know if you can do the same for when you are updating a table.

     

    	// See if that customers sale has already been recorded
    $sql = mysql_query("SELECT * FROM salesrecord WHERE customer ='$customer' AND value='$value ");
    $customerMatch = mysql_num_rows($sql); // count the output amount
        if ($customerMatch > 0) {
    	while($row = mysql_fetch_array($sql)){
    	$customer = $row["customer"]
    		 header("location: sale_error.php?id=$c_id");
    	exit();
    }
    }

  2. Hi guys,

     

    I was wondering if there is a way or if its possible to check the database if the field has already been updated..just like you would if data has already been inserted into the field.

     

    Please let me know if you need more info

     

    Thanks

  3. Hi Guys,

     

    Ok this is might be a strange and new request.

     

    I have a php page with a link on the side menu which when you click you can add a customer into my database.

     

    I would another link (to book an appointment) to appear on this page when the customer has been added or the link should be disabled before the customer is added and enabled when the customer is added. Is this possible?

    Please help

     

    Thanks alot

  4. Thanks QuickOldCar,

     

    I take it the numbers in the array would for example be the items in my database table?

     

    if yes can the code make the items from 0-19 unclickable and item 20 clickable? as this would exactly what am looking for and would solve the problem.

     

    Thanks

  5. Hi guys,

     

    Can you tell me if it is possible. Let say you had a table which stores names and address (with a primary key and auto-increment) , and a PHP script which display every thing on you SQL Table dynamically.

     

    Is it possible to write a PHP code such that if a name and address is added it display and its clickable "i.e. <a href="">$name,$address</a>", and if a new name and address is added its also clickable BUT the older/previous added become unclickable.

     

    I would really appreciate your inputs

     

    Thanks guys!

  6. Hi guys,

     

    I have a customer management script were only logged user can view and perform tasks such as add customers and book appointments.

     

    Currently only certain users can do certain thing e.g. some users can add customers and book appointments and other can only add customers or only book appointments.

    What I did was create two table in mysql 'customer users' and 'appointment users', so users who can do all activities are have their username and password in both table, those who can do only one activity have log details save on only their approtiate tables i.e  'customer users' or 'appointment users'.

     

    The problem is I have to go to the datebase all the time if I want to decide which user does what, I was wondering if you knew a way I can do it on my system, maybe like creating a control panel and changing the user settings from there instead.

     

    Look forward to your help and advise, Thanks alot.

  7. Hi guys,

     

    I have a script which displays a list of customers on my database, I now have about 100 customers.

     

    It gets quite tiring scrolling up and down all the time, so I would like to possibly display 20 customers per page and use a previous/next button to go to each page.

     

    Please guys I would appreciate all you help, Thanks alot.

  8. Hi guys,

     

    I have a form which is meant to post to my database as well send me an email.

     

    It posts to the database very fine but it returns the following error:

    Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\site\reportingfaults.php on line 58

     

    An not sure what to do, I am 2month new to PHP. I would appreciate your help in solving the problem.

     

    Thanks.

     

    Here is the code and form:

     

    <?php 
    // Parse the form data
    if(isset($_POST['fault'])) {
    
        $fault = mysql_real_escape_string($_POST['fault']);
    
    $sql = mysql_query("INSERT INTO csj_fault(fault, username, fault_date) 
            VALUES('$fault','$manager', now())") or die (mysql_error());
    
        //!!!!!!!!!!!!!!!!!!!!!!!!!    Email me    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
        $to = "mailto:kamal.musah@yahoo.com";
    $from = "$manager";
        $subject = "$manager reported a system fault";
        //Begin HTML Email Message
        $message = "$fault";
    
    $headers  = "From: $from\r\n";
        $headers .= "Content-type: text\r\n";
    
        mail($to, $subject, $message, $headers);
    
    
       exit();
    
     header("location: index.php"); 
         exit();
    }
    ?>

     

    Form

                    <form action="reportingfaults.php" method="post" enctype="multipart/form-data">
                     <table width="90%" border="0" cellspacing="0" cellpadding="6">
                          <tr>
                            <td align="right">Fault Description</td>
                            <td><label>
                          
                             <textarea name="fault" id="fault" cols="42" rows="5"></textarea>
                            </label></td>
                          </tr>
                          
                                <tr>
                            <td> </td>
                            <td><label>
                              <input type="submit" name="button" id="button" value="Send" />
                            </label></td>
                          </tr>
                          </table>

  9. It works fine now.

     

    Actually what I did was use your idea of defining $week in the initial $sql.

     

    so basically this is how it look:

    <?php 
    				// Connect to the MySQL database  
    				include "leadscript/connect_to_mysql.php"; 
    if(isset($_GET['week'])){
    $week = $_GET['week'];
    } 
    else{			
    //Get today's date and put them in date, month, year
    $day = date("j");
    $day = $day;
    }
    if(isset($_GET['month'])){
    $month = $_GET['month'];
    } else{
    $month = date("n");
    $month = "0".$month;
    }
    if(isset($_GET['year'])){
    $year = $_GET['year'];
    } else{
    $year = date("Y");
    }
    if(isset($_GET['week'])){
    $week = $_GET['week'];
    } else{
    $week = date("W");
    }
    //Run a select query to count the amount of leads - Khalid
    $sql = mysql_query("SELECT COUNT( * ) AS Leads, c_employee AS name, week_added AS week FROM customer WHERE c_employee='Khalid' AND week_added='".$week."'");
    $customerCount = mysql_num_rows($sql); // count the output amount
    if ($customerCount > 0) {
    	while($row = mysql_fetch_array($sql)){ 
    			 $leads = $row["Leads"];
    			 $name = $row["name"];
    			 $week = $row["week"];
    			 echo '<a href="canvasserweekleads.php?pid=' . $name . '&cid=' . $week . '">' . $leads . '</a>';
    	}
    }
    ?>

     

    Not the cleanest of coding but it works now.

     

    Thanks for getting back to me, if not for that idea dont know what I would have done.

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