Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 56
  1. #31
    Regular Coder
    Join Date
    Aug 2013
    Posts
    141
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Ok going by what you said this is what I have now, although it still isn't working is there anything that I have done wrong or missed
    Thanks Again

    Code:
    <?php
    function query()
    {
    	error_reporting(E_ALL);
    	$connect = mysql_connect("dbinfo", "dbinfo", "dbinfo");
    	//select database
    	mysql_select_db("dbinfo", $connect);
    
    	$criteria = $_POST['sCriteria'];
    
    	$sql="	SELECT DISTINCT Customers.CUST_ID, Customers.CUST_Forename, Customers.CUST_Surname, Customers.CUST_Email,
    			Customers.CUST_Mobile, Customers.CUST_HomeNum, Customers.CUST_AddressL1, Customers.CUST_AddressL2,
    			Customers.CUST_AddressL3, Customers.CUST_Postcode, Jobs.J_RefNum, Manufacturers.MANU_ID,
    			Manufacturers.MANU_Name,
    			Jobs.J_Model, OperatingSystems.OS_ID, OperatingSystems.OS_Name, 
    			Jobs.J_ReceivedBy, Jobs.J_DateRec, Jobs.J_FaultDesc, Jobs.J_PassWinAdmin,
    			Jobs.J_DataRecYN, Jobs.J_PowerSuppYN, JobStatus.JS_Status, 
    			
    			FROM Customers, Jobs, JobStatus, OperatingSystems, Manufacturers
    			WHERE (Jobs.J_RefNum = '$criteria' AND Jobs.J_RefNum = Customers.CUST_ID)
    			AND (OperatingSystems.OS_ID = Jobs.J_RefNum) AND (Manufacturers.MANU_ID = Jobs.J_RefNum)
    		 ";	
    	
    	$result=mysql_query($sql);
    	$result2=mysql_fetch_array($result);
    	return $results2;
    }
    
    if (isset($_POST['sCriteria'])) {
        query();
    	}
    ?>
    Code:
    <form method="POST" action="">
    Search Criteria: <input type="text" name="sCriteria" id="Scriteria"/>
    <br/>
    <br/>
    <input type="button" name="query" value="Run Query" onmouseup="zxcAlertPopUp.Open('drop4',true);"/>
    </form>
    <form>
    <div id="drop4">
    <div style="float:left;"><p>Customer Details</p>
    Customer ID: <input type="int" name="custID2" id="Custid2" value="<?php echo $results2; ?>"  disabled/>
    <br/>
    <br/>

  2. #32
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by daniel0816 View Post
    Code:
    if (isset($_POST['sCriteria'])) {
        query();
    	}
    Quote Originally Posted by Fou-Lu View Post
    There is *no* relationship between $results in the function query() and outside of it. None whatsoever. This is called scope. The results of query() must be captured if you want to use them.
    Query() is not captured.

    These two blocks of code are in the same script correct?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  3. #33
    Regular Coder
    Join Date
    Aug 2013
    Posts
    141
    Thanks
    22
    Thanked 0 Times in 0 Posts
    yea the if statement with the isset is below the closing bracket of the query function

  4. #34
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    No I mean that form. That form has to be in this script in order to have access to the $results (once you capture them of course). If they are in two separate scripts, you cannot retrieve that.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  5. #35
    Regular Coder
    Join Date
    Aug 2013
    Posts
    141
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Yea the form is also on the same page.

  6. #36
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Then correct your assignment and it should work fine.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  7. #37
    Regular Coder
    Join Date
    Aug 2013
    Posts
    141
    Thanks
    22
    Thanked 0 Times in 0 Posts
    You mean the value for the customer id text box?

  8. #38
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    No, I mean that the query() has to be assigned to whatever variable you want to use which is $results2. In particular, you have again modified it so $results2 is a non-array variable, so you not only have to assign the array result from the query() call, you also need to extract the proper item from the list into the $results2 variable.
    PHP Code:
    $qry query();
    $results2 $qry[0]; 
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  9. #39
    Regular Coder
    Join Date
    Aug 2013
    Posts
    141
    Thanks
    22
    Thanked 0 Times in 0 Posts
    This is what I have now but unfortunately still no joy:

    Code:
    if (isset($_POST['sCriteria'])) {
        $qry = query();
    	$results2 = $qry[0];
    	}
    Code:
    Customer ID: <input type="int" name="custID2" id="Custid2" value="<?php echo $results2; ?>"  disabled/>
    <br/>
    <br/>

  10. #40
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Than you have either no post to query against or you return no results.
    Remove that error reporting from the function and add the top add:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    If you see no errors regarding index sCriteria, than the problem is either your query is failing or you have no results. Other errors will indicate sql errors. If there are no errors, than there are simply no matches.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  11. #41
    Regular Coder
    Join Date
    Aug 2013
    Posts
    141
    Thanks
    22
    Thanked 0 Times in 0 Posts
    I get the following error:

    <br /><b>Notice</b>: Undefined variable: results2 in <b>/homepages/18/d228326958/htdocs/suppmytek/custDetails.php</b> on line <b>188</b><br />

    which is here:
    Customer ID: <input type="int" name="custID2" id="Custid2" value="<?php echo $results2; ?>" disabled/>
    <br/>
    <br/>

  12. #42
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Which, given how you constructed your isset checks:
    PHP Code:
    if (isset($_POST['sCriteria'])) { 
    $_POST['sCriteria'] is not set. This script has not been posted to.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  13. #43
    Regular Coder
    Join Date
    Aug 2013
    Posts
    141
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Sorry but how do I go about setting it?

    Thanks Again

  14. #44
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You submit your form.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  15. #45
    Regular Coder
    Join Date
    Aug 2013
    Posts
    141
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Is it possible to open an alert pop up box through a submit button, at the moment it tries to open the box, it half appears then goes away again. I need the type to be submit in order to submit sCriteria.
    Thanks Again

    Code:
    <form method="POST" action="">
    Search Criteria: <input type="text" name="sCriteria" id="Scriteria"/>
    <br/>
    <br/>
    <input type="submit" name="query" value="Run Query" onclick="zxcAlertPopUp.Open('drop4',true);"/>
    </form>
    <div id="drop4">
    <div style="float:left;"><p>Customer Details</p>
    <?php
    if (isset($_POST['sCriteria'])) {
        $qry = query();
    	$results2 = $qry[0];
    	}
    ?>
    <form>
    Customer ID: <input type="int" name="custID2" id="Custid2" value="<?php echo $results2; ?>"  disabled/>
    <br/>
    <br/>


 
Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •