djdellux Posted November 21, 2008 Share Posted November 21, 2008 I have never used this option and i need to implement it into my new code to make sure that all categories are updated from the database.. any suggestions Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/ Share on other sites More sharing options...
MasterACE14 Posted November 21, 2008 Share Posted November 21, 2008 google maybe? Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695312 Share on other sites More sharing options...
djdellux Posted November 21, 2008 Author Share Posted November 21, 2008 Btw to explain... I am in need of the way to write it in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695313 Share on other sites More sharing options...
djdellux Posted November 21, 2008 Author Share Posted November 21, 2008 L0l very funny I use google but I also utilize this site Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695316 Share on other sites More sharing options...
djdellux Posted November 21, 2008 Author Share Posted November 21, 2008 any suggestions guyz i hve been scaning blackel and to no avail i get lil snipits of code but nothing to tell me anythig vital... Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695344 Share on other sites More sharing options...
Mark Baker Posted November 21, 2008 Share Posted November 21, 2008 SELECT DISTINCT has absolutely nothing to do with PHP, and everything to do with a SQL database. I suggest you ask in a database forum. I have never used this option and i need to implement it into my new code to make sure that all categories are updated from the database.. any suggestions I'd also ask you what you're trying to do, because nothing in your description suggests a need for using SELECT DISTINCT. For one, you're talking about updating. Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695347 Share on other sites More sharing options...
djdellux Posted November 21, 2008 Author Share Posted November 21, 2008 sry mark.. let me be more descriptive for ya...i have 3 feilds that consist of employee tags. i need a way to continusly have my php code topopulate the feilds from the sqlite db. if a new employee is hired there code will not be in the search field. i need that to update when the prgm is opened.. is this a lil better if you need any more info plz ask and here is the existing code for ya <html> <head> <title>Loggin DB</title> </head> <body> <h1 align=left>Please enter search feilds:</h1> <body bgcolor="#82CAFA"> <form method="get" action="loggin1.php"> Page: <select name="Page"> <option value="approve.php" >Approve</option> <option value="custquery" >CustQuery</option> <option value="slpnlogin">SlpnLogin</option> </select> User Code: <select name="UserCode"> <option >T3</option> <option >J9</option> <option>BL</option> <option >SC</option> <option >MN</option> <option >CA</option> <option>MW</option> <option >TJ</option> <option >E2</option> <option >D6</option> <option >SS</option> <option >R9</option> <option >GL</option> <option >MP</option> <option >RW</option> </select> Start Date: <input type="text" name="time"> End Date: <input type="text" name="time1"> <p><input name="submitted" type="submit" value="send"/></p></form> <?php $db = $_SERVER['DOCUMENT_ROOT']."/../data/log.db"; //connect to sql $handle = sqlite_open($db); $query = "SELECT DISTINCT * FROM log WHERE"; if(isset($_GET['submitted']) && $_GET["submitted"] == "send")// line check { if ($_GET["Page"] !="") { $query.=" page=\"" .$_GET["Page"]."\""; } if ($_GET["UserCode"] !="") { $query.=" and userCode=\"" .$_GET["UserCode"]."\""; } if(isset($_GET["time"])) { $stime = strtotime($_GET["time"]); $query.=" and time >='" .$stime."'"; } if(isset($_GET["time1"])) { $etime = strtotime($_GET["time1"]); $query.=" and time <='" .$etime."'"; } } echo $query;// show the result of the search $result = sqlite_query($handle, $query); $row = sqlite_fetch_array( $result ); echo "<style type='text/css'> table { border-width: 1px; border-spacing:0px ; border-style: double; border-color: black; border-collapse: separate; background-color: #82CAFA; } table th { border-width: 1px; padding: 0px; border-style: solid; border-color: black; background-color: #82CAFA; } table td { border-width: 1px; padding: 3px; border-style: solid; border-color: black; background-color: #82CAFA; } </style> <table class='db'; cellspacing=\"0px\">"; while($row = sqlite_fetch_array($result)){ echo " <tr>\n"; echo " <td> $row[id]</td><td> $row </td> <td> $row[desc] </td><td> $row[userCode] </td><td> $row[codeType] </td><td>". date( "Y-m-d", $row['time'])."</td><td> $row[ipaddr]</td>\n"; echo " </tr>\n"; } echo "</table>"; ?> </html> Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695361 Share on other sites More sharing options...
Mark Baker Posted November 21, 2008 Share Posted November 21, 2008 Well SELECT DISTINCT UserCode FROM log Should return a list of all the user codes that have any entry in the log table. <select name="UserCode"> <?php $usercodeQuery = "SELECT DISTINCT usercode FROM log"; $usercodeResult = sqlite_query($handle, $usercodeQuery); while($usercodeRow = sqlite_fetch_array($usercodeResult)){ echo '<option >'.$usercodeRow['usercode'].'</option>'; } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695373 Share on other sites More sharing options...
djdellux Posted November 21, 2008 Author Share Posted November 21, 2008 Mark I inserted the code at the top because i want the dropdown list to populate before anything else and i recieved some errors Notice: Undefined variable: handle1 in c:\program files\Apache\htdocs\loggin1.php on line 3 Warning: sqlite_query() expects parameter 1 to be resource, string given in c:\program files\Apache\htdocs\loggin1.php on line 3 Warning: sqlite_fetch_array() expects parameter 1 to be resource, null given in c:\program files\Apache\htdocs\loggin1.php on line 4 ... dont know what to make of it... Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695404 Share on other sites More sharing options...
djdellux Posted November 21, 2008 Author Share Posted November 21, 2008 I solved the error issues but now i need to insert the result into the dropdown feild which is in html... how would i go about this?? Quote Link to comment https://forums.phpfreaks.com/topic/133648-solved-select-distinct/#findComment-695415 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.