PHP - Why Query Fails To Pull All Data From Data Base ?
Hi, I want to pull data from db, where sometimes all rows and sometimes rows matching given "username". Here is my code:
//Grab Username of who's Browsing History needs to be searched. if (isset($_GET['followee_username']) && !empty($_GET['followee_username'])) { $followee_username = $_GET['followee_username']; if($followee_username != "followee_all" OR "Followee_All") { $query = "SELECT * FROM browsing_histories WHERE username = \"$followee_username\""; $query_type = "followee_username"; $followed_word = "$followee_username"; $follower_username = "$user"; echo "$followee_username"; } else { $query = "SELECT * FROM browsing_histories"; $query_type = "followee_all"; $followed_word = "followee_all"; $follower_username = "$user"; echo "all"; } }
When I specify a "username" in the query via the url: browsing_histories_v1.php?followee_username=requinix&page_number=1 I see result as I should. So far so good.
Now, when I specify "all" as username then I see no results. Why ? All records from the tbl should be pulled! browsing_histories_v1.php?followee_username=all&page_number=1 This query shouldv'e worked:
$query = "SELECT * FROM browsing_histories";
Similar TutorialsI have a some value that are being generated from a database then thrown into <li><href> to create a list that user can click and fetch data through ajax right now its in a form select/menu and works fine however I need to convert to a list and use and onKeyDown event Code: [Select] <form> <select name="users" size="<?php echo $num_rows;?>" onchange="showUser(this.value)" > <?php do { ?> <option value="<?php echo $row_Recordset1['item_id']?>"><?php echo $row_Recordset1['item_id'].' '. $row_Recordset1['item_name']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </select> </form> I need to correct this Code: [Select] <ol> <?php do { ?> <li onKeyDown="showUser(this.value)"><a href="getmenu.php?item_id="<?php echo $row_Recordset1['item_id']?>"> <?php echo $row_Recordset1['item_name']?></a></li> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </ol> I have two tables. Table Name:Users Fields: User_name user_email user_level pwd 2.Reference Fields: refid username origin destination user_name in the users table and the username field in reference fields are common fields. There is user order form.whenever an user places an order, refid field in reference table will be updated.So the user will be provided with an refid Steps: 1.User needs to log in with a valid user id and pwd 2.Once logged in, there will be search, where the user will input the refid which has been provided to him during the time of order placement. 3.Now User is able to view all the details for any refid 3.Up to this we have completed. Query: Now we need to retrieve the details based on the user logged in. For eg: user 'USER A' has been provided with the referenceid '1234' during the time of order placement user 'USER B' has been provided with the referenceid '2468' during the time of order placement When the userA login and enter the refid as '2468' he should not get any details.He should get details only for the reference ids which is assigned to him. <?php session_start(); if (!$_SESSION["user_name"]) { // User not logged in, redirect to login page Header("Location: login.php"); } $con = mysql_connect('localhost','root',''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); $user_name = $_POST['user_name']; $refid = $_POST['refid']; $query = "SELECT * from reference,users WHERE reference.username=users.user_name AND reference.refid='$refid' AND "; $result = mysql_query($query) or trigger_error('MySQL encountered a problem<br />Error: ' . mysql_error() . '<br />Query: ' . $query); while($row = mysql_fetch_array($result)) { echo $row['refid']; echo $row['origin']; echo $row['dest']; echo $row['date']; echo $row['exdate']; echo $row['username']; } echo "<p><a href=\"logout.php\">Click here to logout!</a></p>"; ?> <html> <form method="post" action="final.php"> Ref Id:<input type="text" name="refid"> <input type="submit" value="submit" name="submit"> </html> Hi I am trying to select and order data/numbers from a colum in a mysql data base however i run the code and it returns no value just a blank page no errors or any thing so i think the code is working right but then it returns no result? Please help thanks Here is the code: <?php $host= "XXXXXX"; $mysql_user = "XXXXXX"; $mysql_password = "XXXXXX"; $mysql_database = "XXXXXXX"; $connection = mysql_connect("$host","$mysql_user","$mysql_password") or die ("Unable to connect to MySQL server."); mysql_select_db($mysql_database) or die ("Unable to select requested database."); $row = mysql_fetch_assoc( mysql_query( "SELECT XP FROM Game ORDER BY number DESC LIMIT 1" ) ); $number = mysql_result(mysql_query("SELECT XP FROM Game ORDER BY number DESC LIMIT 1"), 0); echo "The the highest XP is $number"; ?> Am new here - looks like a great foru! I would sincerely appreciate any help anyone can give me. I have been trying to solve my problem for hours and I am not having any luck, so I thought I would post and see if anyone can help. I am very stuck and am not making much progress on this project, and I am certain the answer is very simple. I am constructing a form to collect data for a specialized purpose. The form and program actually work for its intended function, but I am trying to enhance the user experience by preventing customers from having to reenter all of their data should there be a problem with any of the data submitted. I have been able to do that with the contact form portion, but what I am having trouble with is the portion which has as many as 400 possible entries. So, in a nutshell, if the customers contact data is incomplete or in error, the form will ask them to return to the page and correct things. The previous data entered has been saved in the session and the input value will equal the previous entry. i.e. <tr> <td align="right" class="infoBox"><?php echo ENTRY_EMAIL_ADDRESS; ?></td> <td align=left><?php echo "<input type=text name='cemail' value=\"$cemail\" size=35 maxlength=35>" ?></td> </tr> Works perfectly, all well and good there. On the other 400 more or less entries, I am having a difficult time tweaking the string concatenation to work to achieve similar results. There are 4 columns each with $points entries asking for a dimension in either feet or inches. The <input name=> is one of ptaf,ptai,ptbf,ptbi, appended programatically with the corresponding row number or data point. i.e. "ptaf1", "ptai1", etc... This is produced by the example below and works perfectly also. <?php { $points=100; $i=1; while ($i <= $points) {echo ' <tr><td align="center" width="6"><b> ' .$i . '</b></td> <td align="right" NOWRAP>A' .$i . ' (ft) <input type="text" name="ptaf'.$i.'" size=4 maxlength=3> </td> <td align="right" NOWRAP>A' .$i . ' (in) <input type="text" name="ptai'.$i.'" size=4 maxlength=4> </td> <td align="right" NOWRAP>B' .$i . ' (ft) <input type="text" name="ptbf'.$i.'" size=4 maxlength=3> </td> <td align="right" NOWRAP>B' .$i . ' (in) <input type="text" name="ptbi'.$i.'" size=4 maxlength=4> </td> '; $i++; } } ?> I am trying to add <input value=$ptai.$i> for each field but as I mentioned I am not having any luck. It seems as if I have tried every combination imagineable, but still no luck. My head is spinning! The closest I seem to have gotten was with this: <td align="right" NOWRAP>A' .$i . ' (ft) <input type="text" size=6 maxlength=3 name="ptaf'.$i.'" value="' . "$ptaf" . $i . '" ></td> But line 17 for example returns this: <input type="text" value="17" name="ptaf17" maxlength="3" size="6"> To recap, I am trying to have the value set to whatever the customer may have entered previously. Again, I would most appreciate any help anyone can give me. If you need clarification on anything please let me know. Thanks AJ Hi Team, I have a php page where I have taken the same userid and linked in the next page and also used show/hide function. I am able to see that the userid is linking but when i submit the data is not getting insert and also no error Please help below is the Tower.php file. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BHP2</title> <style type="text/css"> <!-- #Layer1 { position:absolute; width:1005px; height:578px; z-index:1; left: 157px; top: 1px; background-color: #993399; } #Layer2 { position:absolute; width:939px; height:114px; z-index:1; left: 35px; top: 35px; } #Layer3 { position:absolute; width:451px; height:169px; z-index:2; left: 270px; top: 296px; } #Layer4 { position:absolute; width:608px; height:68px; z-index:2; left: 273px; top: 10px; } #Layer5 { position:absolute; left:82px; top:188px; width:973px; height:52px; z-index:2; } #Layer6 { position:absolute; width:243px; height:106px; z-index:2; left: 68px; top: 43px; } .style1 { font-size: xx-large; font-style: italic; } .style2 {font-size: 52px} #Layer7 { position:absolute; width:824px; height:271px; z-index:2; left: 44px; top: 237px; } .style4 { font-size: xx-large; font-style: italic; font-weight: bold; color: #FF9933; } #Layer8 { position:absolute; width:800px; height:139px; z-index:2; left: 31px; top: 67px; } #Layer9 { position:absolute; width:610px; height:30px; z-index:2; left: 34px; top: 70px; } #Layer10 { position:absolute; width:611px; height:25px; z-index:2; left: 33px; top: 110px; } #Layer11 { position:absolute; width:614px; height:30px; z-index:2; left: 33px; top: 152px; } #Layer12 { position:absolute; width:615px; height:29px; z-index:2; left: 32px; top: 193px; } #Layer13 { position:absolute; width:187px; height:35px; z-index:2; left: 318px; top: 239px; } --> </style> </head> <body> <div id="Layer1"> <form id="form5" name="form5" method="link" action="Insert.php"> <div id="Layer2"> <div id="Layer6"><img src="AZimages/BHP-Billiton-logo.jpg" width="235" height="65" alt="BHP" /></div> <h1 align="center"> </h1> <div class="style1" id="Layer4"> <h1 align="center" class="style2">BHP DATA TRACKER </h1> </div> </div> <div id="Layer7"> <div align="center"><span class="style4">SELECT THE TOWER BELOW </span> <div id="Layer13"> <input type="hidden" name="empid" value="<?php echo $_GET['id']; ?>" size="20"> <input type="hidden" name="date" value="<?php echo date("Y-m-d H:i:s"); ?>" > <input type="submit" name="B1" value="Start !" /> </div> <div id="Layer12"> <div align="left"> <input name="rad1" type="radio" value="RF" id="rad1" /> <label >RF</label> </div> </div> <div id="Layer11"> <div align="left"> <input name="rad1" type="radio" value="ISAP" id="rad1" /> <label >ISAP</label> </div> </div> <div id="Layer10"> <div align="left"> <input name="rad1" type="radio" value="GSD" id="rad1" checked="checked" /> <label >GSD</label> </div> </div> <div id="Layer9"> <div align="left"> <input name="rad1" type="radio" id="rad1" value="CSD" /> <label>CSD</label> </p> </div> </div> <br /> </div> </div> </form> </div> </body> </html> Below is the insert.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BHP DATA SUMBIT</title> <?php include ("count.php"); ?> <?php if(isset($_GET['action'])) { $action = $_GET['action']; if ($action = 'yes') { include ("Connection.php"); $PName = $_POST['rad11']; $Date = date("Y-m-d H:i:s"); $empidno = $_POST['idd']; $qsdate = $_POST['testinput']; $cb1 = $_POST['chkbox1']; $cb2 = $_POST['chkbox2']; $cb3 = $_POST['chkbox3']; $cb4 = $_POST['chkbox4']; $cb5 = $_POST['chkbox5']; $Com = $_POST['textfield2']; $dd1 = $_POST['textfield']; $dd2 = $_POST['select']; $dd3 = $_POST['select2']; $dd4 = $_POST['textfield4']; $dd5 = $_POST['textfield3']; $dd6 = $_POST['select3']; $sev = $_POST['radio1']; $olddate = $_POST['odate']; $pname = $_POST['radiobutton']; $query="INSERT INTO bhp ticketinformation (`userid`, `processname`, `begindate`, `dateposted`, `CALL`, `EMAIL`, `NEW`, `EXISTING`, `Piroty`, `MTICKET`, `Services`, `group1`, `group2`, `Icall`, `Tcreatedtime`, `comment`) VALUES ( '$empidno' , '$pname' , '$olddate' , '$Date' , '$cb1' , '$cb2' , '$cb3' , '$cb4' , '$sev' , '$dd1' , '$dd2' , '$dd3' , '$dd4' , '$dd5' , '$dd6' , '$Com')"; mysql_query($query); Header('location:tower.php?id=' . $empidno); } } ?> <head> <style type="text/css"> <!-- #Layer1 { position:absolute; width:1023px; height:592px; z-index:1; left: 167px; top: 2px; background-color: #993399; } #Layer2 { position:absolute; width:939px; height:114px; z-index:1; left: 59px; top: 3px; } #Layer3 { position:absolute; width:451px; height:169px; z-index:2; left: 270px; top: 296px; } #Layer4 { position:absolute; width:608px; height:68px; z-index:2; left: 273px; top: 10px; } #Layer5 { position:absolute; left:82px; top:188px; width:973px; height:52px; z-index:2; } #Layer6 { position:absolute; width:238px; height:69px; z-index:2; left: 68px; top: 43px; } .style1 { font-size: xx-large; font-style: italic; } .style2 {font-size: 52px} #Layer7 { position:absolute; width:979px; height:209px; z-index:2; left: 32px; top: 181px; } #Layer8 { position:absolute; width:194px; height:36px; z-index:1; left: 25px; top: 15px; } #Layer9 { position:absolute; width:178px; height:37px; z-index:2; left: 249px; top: 13px; } #Layer10 { position:absolute; width:193px; height:34px; z-index:3; left: 443px; top: 13px; } #Layer11 { position:absolute; width:204px; height:32px; z-index:4; left: 670px; top: 15px; } #Layer12 { position:absolute; width:195px; height:40px; z-index:5; left: 28px; top: 73px; } #Layer13 { position:absolute; width:182px; height:38px; z-index:6; left: 250px; top: 76px; } #Layer14 { position:absolute; width:197px; height:36px; z-index:7; left: 446px; top: 77px; } #Layer15 { position:absolute; width:214px; height:35px; z-index:8; left: 670px; top: 77px; } #Layer16 { position:absolute; width:315px; height:45px; z-index:9; left: 16px; top: 144px; } #Layer17 { position:absolute; width:343px; height:43px; z-index:10; left: 339px; top: 145px; } #Layer18 { position:absolute; width:258px; height:48px; z-index:11; left: 708px; top: 146px; } #Layer19 { position:absolute; width:321px; height:60px; z-index:3; left: 59px; top: 419px; } #Layer20 { position:absolute; width:197px; height:41px; z-index:1; left: 27px; top: 6px; } #Layer21 { position:absolute; width:193px; height:36px; z-index:2; left: 249px; top: 7px; } #Layer22 { position:absolute; width:207px; height:38px; z-index:3; left: 453px; top: 7px; } #Layer23 { position:absolute; width:237px; height:36px; z-index:4; left: 677px; top: 9px; } #Layer24 { position:absolute; width:245px; height:45px; z-index:5; left: 399px; top: 2px; } #Layer25 { position:absolute; width:99px; height:31px; z-index:6; left: 288px; top: 121px; } #Layer26 { position:absolute; width:87px; height:29px; z-index:7; left: 439px; top: 123px; } --> </style> <script language="JavaScript" > function showInfo() { var elem = document.getElementById('verify'); if(document.testform.select3.value == "verify" || document.testform.select3.value == "verify1" ) { elem.style.display="inline"; } else { elem.style.display="none"; } } </script> <script language="JavaScript"> function validator() { if(document.testform.Checkbox1.checked == false && document.testform.Checkbox2.checked == false && document.testform.Checkbox3.checked == false && document.testform.Checkbox4.checked == false) { alert ('You did not choose any of the checkboxes!'); return false; } if (document.testform.textfield.value =="") { alert("Enter Max Ticket No"); return false; } if (document.testform.select.value == "" || document.testform.select.value == "SELECT SERVICE DROP DOWN") { alert ('Select the SELECT SERVICE DROP DOWN'); return false; } if (document.testform.select2.value == "" || document.testform.select2.value == "SELECT RG GROUP") { alert ('SELECT RG GROUP'); return false; } if (document.testform.select3.value == "" || document.testform.select3.value == "SELECT GROUPS") { alert ('SELECT GROUPS'); return false; } if (document.testform.textfield2.value =="") { alert("Comments Feild is Empty.If there are no Comment then type NA(Not Applicable)"); return false; } if (document.testform.Checkbox1.checked == false) document.getElementById("chkbox1").value = ""; else document.getElementById("chkbox1").value = "EMAIL"; if (document.testform.Checkbox2.checked == false) document.getElementById("chkbox2").value = ""; else document.getElementById("chkbox2").value = "NEW"; if (document.testform.Checkbox3.checked == false) document.getElementById("chkbox3").value = ""; else document.getElementById("chkbox3").value = "EXISTING"; if (document.testform.Checkbox4.checked == false) document.getElementById("chkbox4").value = ""; else document.getElementById("chkbox4").value = "CALL"; alert('Record has been posted in the portal'); } </script> </head> <body> <div id="Layer1"> <div id="Layer2"> <div id="Layer6"><img src="AZimages/BHP-Billiton-logo.jpg" width="235" height="67" alt="BHP" /></div> <h1 align="center"> </h1> <div class="style1" id="Layer4"> <h1 align="center" class="style2">BHP DATA TRACKER </h1> </div> </div> <div id="Layer7"> <form method="POST" action="Insert.php?action=yes&&id=<?php echo $_GET['empid']; ?>" name="testform" onSubmit="return validator();"> <div id="Layer8"> <input type="checkbox" id="Checkbox4" name="checkbox4" value="CALL" /> CALL</label> </div> <div id="Layer9"> <label> <input type="checkbox" id="Checkbox1" name="checkbox1" value="EMAIL" /> EMAIL</label> </div> <div id="Layer10"> <label> <input type="checkbox" id="Checkbox2" name="checkbox2" value="NEW" /> NEW</label> </div> <div id="Layer11"> <label> <input type="checkbox" id="Checkbox3" name="checkbox3" value="EXISTING" /> EXISTING</label> </div> <div id="Layer12"> <label> <input name="radio1" type="radio" id="radio1" value="P1" checked="checked" /> P1</label> </div> <div id="Layer13"> <label> <input name="radio1" type="radio" id="radio1" value="P2" /> P2</label> </div> <div id="Layer14"> <label> <input name="radio1" type="radio" id="radio1" value="P3" /> P3</label> </div> <div id="Layer15"> <label> <input name="radio1" type="radio" id="radio1" value="P4" /> P4</label> </div> <div id="Layer16"> <label>MAXIMUM TICKET <input type="text" name="textfield" /> </label> </div> <div id="Layer17"> <label>SERVICE DROP DOWN <select name="select" style="width: 162px; height: 23px"> <option>SELECT SERVICE DROP DOWN</option> <option>OTHER(FW)</option> <option>1 MESSAGE</option> <option>1 MOBILITY</option> <option>1 VOICE</option> <option>1 SAP</option> <option>1 PORTAL</option> <option>1 COLLAB</option> <option>1 GSAP</option> <option>1 SECURITY</option> <option>1 WAN</option> <option>S DOMAIN</option> <option>1 AUTH</option> <option>1 DOCM</option> <option>1 REMOTE</option> </select> </label> </div> <div id="Layer18"> <label>RG GROUP <select name="select2" style="width: 162px; height: 23px"> <option>SELECT RG GROUP</option> <option>I-AM-AU-AM-HWT</option> <option>I-EUS-IN-CSC-DSK-CSD</option> <option>I-EUS-IN-CSC-DSK-GSD</option> <option>I-EUS-GB-DCS-BHPVICFW</option> <option>I-ITS-AU-HW</option> <option>I-SRM-AU-IAM-LAMU</option> <option>I-ITS-AU-SW</option> <option>C-BHP-AU-CSC-LSD-NONBRG</option> <option>C-BHP-AU-ACN-AQM</option> </select> </label> </div> </div> <div id="Layer19"> <label>SELECT GROUPS <select name="select3" onchange="showInfo()" style="width: 162px; height: 23px"> <option value="none" >SELECT GROUPS</option> <option value="verify">TP</option> <option value="verify1">OA</option> <option>OC</option> <option>OTHERS</option> </select> </label> <div id="verify" style="display:none;"> <br/><br/> <label>INCOMING CALL/EMAIL TIME <input type="text" name="textfield4" /> </label> <br/><br/> <label>MAXIMO TICKET CREATED TIME <input type="text" name="textfield3" /> </label> </div> <div id="Layer24"> <label>COMMENTS <input type="text" name="textfield2" /> </label> </div> <div id="Layer26"> <input name="Reset" type="reset" id="Reset" value="Reset" /> </div> <div id="Layer25"> <input type="submit" name="Submit" value="Submit" /> <input type="hidden" name="chkbox1" id="chkbox1" /> <input type="hidden" name="chkbox2" id="chkbox2" /> <input type="hidden" name="chkbox3" id="chkbox3" /> <input type="hidden" name="chkbox4" id="chkbox4" /> <input type="hidden" name="chkbox5" id="chkbox5" /> <input type="hidden" name="rad11" id="rad11" value="<?php echo $_GET['rad1']; ?>" /> <input type="hidden" name="idd" id="idd" value="<?php echo $_GET['empid']; ?>" /> <input type="hidden" name="odate" id="odate" value="<?php echo $_GET['date']; ?>" /> </form> </div> </div> </div> </body> </html> THANKS IN ADVANCED i have php code, <?php include ("connect.php"); $selecteddate = $_POST['sdate']; $sql1 = "select date from game1"; $query1 = mysql_query($sql1) or die(mysql_error()); while($row = mysql_fetch_assoc($query1)) { $rowdate = $row['date']; // problem here i this while loop only compare my latest last value in database. i want a code here which search all the data in "date" field. } if($selecteddate == $rowdate) { echo "Date already Exists"; } else { // form insertion data code here which i have and working fine } SHINSTAR is online now Add to SHINSTAR's Reputation Report Post Edit/Delete Message Hello First of all thanks for your help in advance. I build a members website and can use HTML but seem to be going round in circles with php. So Ive made a page that allows users to input there details and register this DOES Work and adds the data to a mysql data base. However I would like when they click register it sends them a email to confirm there info and at the same time send myself one so I can check there details. this is the link http://www.asian-travel-club.co.uk/php/files/register.htm Once this is done I would like to be able to see on a admin page that has a username and password to allow me to active and deactive there members. I know this would need a button added this is where I get lost. the link to the admin page ive made is http://www.asian-travel-club.co.uk/php/files/admin/ Then once i actived them they will recive an auto activtion email . I dont seem to be able to see data from the Database on mysql but i can interact with it. As one you register if you try to log in it say that the username and passwodr is incorrect. I TAKE IT IS BECAUSE THE USER DOES NOT HAVE PERMISSION> how do i do this? Any way if you go to forot password page it allows you to enter data and on submittion it chz the database and then sends you an email with your username and password attached. This is the link to the password recover page. http://www.asian-travel-club.co.uk/php/files/password_recover.php this is what is in my config.php <?php define('DB_SERVER', ''); // database server/host define('DB_USER', ''); // database username define('DB_PASS', ''); // database password define('DB_NAME', ''); // database name ?> Please help if you can i have just sent the last 4 hours trying to connect to the msql database here is the to sets of code i i'm using <?php $db_host = "host"; $db_usernamen = "username"; $db_pass = "password" $db_name = "database name"; mysql_connect("$db_host","$db_username","$db_pass") or die ("couldnot connect to mysql"); mysql_select_db("db_name") or die ("no database"); ?> this code i'm using to connect to the database <?php require "connect_to_mysql.php"; echo "<h1>success in database connection! happy coding</h1>"; ?> and i have used this one as a quick test. i have up loaded the the two codes to the sever however when i opened the web site to test it all i get is a blank screen. i have looked at a number of codes like this one and i can't see anything wrong with the code. i have uploaded the codes three times just in case the files had been corrupt while uploading have every this has not work if anyone can help i would be very greatful Hi everyone, Here's the part of the script I think is wrong : <?php include "util/log.php"; include "util/connect.php"; if (loggedin() == $NO) { header("Location: login.php"); exit(); } else if (isset($_GET["p"])) { $udata = explode("-", $_COOKIE["log"]); $query = "SELECT * FROM l_users WHERE user='$udata[0]'"; $usrsql = mysql_query($query) or handledberror(mysql_error()); $usrdata = mysql_fetch_array($usrsql); switch ($_GET["p"]) { case "delete": include "util/linkfunc.php"; if (isset($_GET['id'])) delete_link($_GET['id']); else delete_all(); $CONTENT = "pages/urls.php"; break; case "approve": include "util/approve.php"; $CONTENT = "pages/approve.php"; break; case "urlview": case "add": case "edit": include "pages/modify.php"; $CONTENT = "pages/edit.php"; break; case "reset": include "util/linkfunc.php"; if (isset($_GET['id'])) reset_link($_GET['id']); else reset_all(); $CONTENT = "pages/urls.php"; break; case "urls": default: $CONTENT = "pages/urls.php"; } } else { $udata = explode("-", $_COOKIE["log"]); $query = "SELECT * FROM l_users WHERE user='$udata[0]'"; $usrsql = mysql_query($query) or handledberror(mysql_error()); $usrdata = mysql_fetch_array($usrsql); $CONTENT = "pages/urls.php"; } ?> <html> <head><title>EzyLinkExpire :: Member's Area</title><head> <body bgcolor="#1D2B60" link=#CCFFFF vlink=#CCFFFF> <table align="center" cellspacing="0" width=90% bgcolor="white" bordercolordark="black" bordercolorlight="black"> <tr> <td bgcolor="#1D2B60"> <img src="images/logo.gif" border="0"></td> <td valign=top bgcolor="#1D2B60" align=right><font color="white" size="1" face="Verdana">Welcome <? print $usrdata["fname"] . " ". $usrdata["lname"]; ?>!<br>User Since: <? print date("F d Y",$usrdata["since"]); ?><br>Server Time:<? print date("r"); ?><br><a href="login.php?a=logout" color=#CCFFFF>Click Here To Logout</a><br><a href="members.php" color=#CCFFFF>Click Here To Goto the Main Page</a></font></td> </tr> <tr><td colspan=2 height=14 bgcolor="#1D2B60"></td></tr> <tr> <td width="100%" height="100%" colspan=2 bgcolor="white" bordercolordark="black" align="center" bordercolorlight="black" border=1 valign="top"> <br><? include $CONTENT; ?><br><br> </td> </tr> </table> </body> <style type="text/css"> table.t {border: thin solid #000000; background-color: #FFFFFF} td.th {border: thin solid #000000; background-color:#FFFFFF; font-style: bold 12px; text-align:center; font-size: 12px; font-weight:bold} td.t {border: thin solid #000000; background-color:#FFFFFF; font-style: bold 12px; text-align:center; font-size: 12px; font-weight:bold} td.te {border: thin solid #000000; background-color:#FFFFFF; text-align:center; } td.ac1 {border: thin solid #000000; background-color:#FFFFFF; text-align:left; } td.ac2 {border: thin solid #000000; background-color:#FFFFFF; text-align:left; } a.t {color: #3366FF} a.msg {color: #3366FF} font.msg {font-style: bold 12px; font-size: 12px; font-weight:bold} </style> <script language='javascript'> function deleteconfirm() { if (confirm("Are you sure you want to delete all links?")) document.location = "members.php?p=delete"; } function resetconfirm() { if (confirm("Are you sure you want to reset the hit count for all links?")) document.location = "members.php?p=reset"; } </script> </html> Thank you, Sylvain Hi , Presently we are preparing an excel for download report by querying to data base. We are querying to DB and looping through each result row and writing to excel. for 2lacs data its too much time. I found the time taken max in DB query and processing the DB data . Ant way I can make it faster ? Any parallel processing I can apply to get it faster......I expecting Huge data report in future. I need to pull all the mysql data by the order of it's date/time . How can I write the code? I'm using this as a serverside script and I'm not a php person. But i believe the below code will not pull the data. Will it work if I remove the text marked in red? $query = "SELECT * FROM sub_db WHERE the_code = '".$abc."'" ORDER BY timestampz ASC"; hello sir, i have to connect database to my live server using <?php
define('DB_HOST', 'localhost'); ?> or
This is my code. Data is been pulled from db_faq and Db_2 and then match the records against each other using array_intersect(). And as you see the data from db_faq is been pulled based on the $username. My question is how can I ignore the $username and match all rows in db_faq against the data in db_2? Basically I need to get the matching records between the 2 databases regardless of the username. $Array1 = array(); $Array2 = array(); $var1 = '$username'; $query1 = "SELECT * FROM db_faq WHERE username = '".$var1."'"; $result1 = mysql_query($query1); $score1 = mysql_fetch_assoc($result1); foreach (range('25','35') as $ltr) { $Array1[] = array($score1['roundzA' . $ltr]); } $var2 = 'new'; $query = "SELECT * FROM db_2 WHERE place = schedule"; $result = mysql_query($query); $score2 = mysql_fetch_assoc($result); foreach (range('25','35') as $ltr) { $Array2[] = array($score2['points' . $ltr]); } $count = array(); for($i=0;$i<count($Array1);++$i) { $count[$i] = count(array_intersect($Array1[$i],$Array2[$i])); } $countResult = array_sum($count); This is for band website for its event listings. The main event page list everything fine, but once selecting the "Details" link which activates the switch event. Its no longer showing anything. When I had one event in the data base it worked fine, but now I have 3 events in the database and now its not working. Page can be viewed he http://184.66.66.169/ffy/event.php Code: [Select] <?php //Event Code Here $eventid = (isset($_GET["id"])) ? intval($_GET["id"]) : 0; switch($_GET["list"]=='true') { case "0": if($_GET["id"]== $eventid) { $result = mysql_query("SELECT * FROM event ORDER by eventdate DESC"); if (!$result) { die("query failed: " . msql_error()); } while ($row = mysql_fetch_array($result)) { list($id, $eventdate, $header, $description, $image, $location) = $row; $description = nl2br($description); $eventdate = date("M j, Y",strtotime("$eventdate")); print(' <table width="680" border="0" cellpadding="14" cellspacing="0"> <tr> <td> <div class="myFont"><font size="+1" color="#4e8baf">'.$eventdate.' - </font><font size="+1"><b>'.$header.'</b></font></div> <font size="-2" color="#CCCCCC"><a href="event.php?list=true&eventid='.$id.'">Details</a></font><br /> <hr color="#FFFFFF" width="100" align="left" size="1"> </td> </tr> </table> '); }} break; case "true": if($_GET["id"]==$eventid) { $resultd = mysql_query("SELECT * FROM event WHERE id=$eventid LIMIT 1"); if (!$resultd) { die("query failed: " . msql_error()); } while ($row = mysql_fetch_array($resultd)) { list($id, $eventdate, $header, $description, $image, $location) = $row; $description = nl2br($description); $eventdate = date("M j, Y",strtotime("$eventdate")); print(' <table width="680" border="0" cellpadding="14" cellspacing="0"> <tr> <td> <div class="myFont"><font size="+1" color="#4e8baf">'.$eventdate.' - </font><font size="+1"><b>'.$header.'</b></font></div> '.$description.'<br /> <hr color="#FFFFFF" width="100" align="left" size="1"> <center> '.$location.' </center> </td> </tr> </table> '); } break; }} ?> Hi guys Can someone help me about this: The php code can be revise username and password with CURL then check database and if username & password is correct return true else false. Thanks This is the link to pull the page http://127.0.0.1/kudos/?viewkudoid=### This is the kudo-function.php page function get_kudo_info($viewkudoid){ global $wpdb; $tablename=acikudos_table_name(); $viewsql = "SELECT * FROM $tablename WHERE kudoid='$viewkudoid'"; $viewresult = $wpdb->get_results($viewsql); #$vewrow = mysql_fetch_assoc($viewresult); return $viewresult; } This is the kudo-view.php page function show_kudos($viewkudoid) { global $wpdb; $viewkudoid = $_GET['viewkudoid']; $getthekudo = get_kudo_info($viewkudoid); if ($viewkudoid == $getthekudo['kudoid']) { echo 'Congratulations, you have successfully fixed it!'; } else { echo 'Everything is displayed'; } } add_shortcode( 'kudosview', 'show_kudos' ); I know the issue is right in front of me but I can not find it. Hi All, As we know........to export excel sheet the database content....we query the data base and then process the result and using Workbook and header we export the result in excel.................. Is there any way we can reduce the down load time or increase the performance for same. ? Thanks. I am getting an error on line 3 for the original code, so I need help there, but what I do have a question on is this: http://kaboomlabs.com/PDI/test2.php Code: [Select] <?php $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) $result = $mysqli_query("SELECT * FROM comp"); echo "<SELECT name='comp'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['name']}</option>\n"; } echo "</select>\n"; $result_close(); ?> What I am attempting to do is two fold. 1. Using PHP create a pull down menu that grabs data from the database. 2. Have something in where after line three there is a dotted break, and then the rest of the list is shown. There are over 150 entities that go into this database, so the top 3 are going to be the most used, the rest are going to be in alphabetical order. Now the database has a auto-increment numbering system, the company name, address, phone number, and email if possible. I only want it to show the company name. Is this possible at all? This topic has been moved to Microsoft SQL - MSSQL. http://www.phpfreaks.com/forums/index.php?topic=347695.0 hello dear experts
good day dear friend - i need your help. import urllib import urlparse import re # import peewee import json from peewee import * #from peewee import MySQLDatabase ('cpan', user='root',passwd='rimbaud') db = MySQLDatabase('cpan', user='root',passwd='rimbaud') class User(Model): name = TextField() cname = TextField() email = TextField() url = TextField() class Meta: database = db # this model uses the cpan database User.create_table() #ensure table is created url = "http://search.cpan.org/author/?W" html = urllib.urlopen(url).read() for lk, capname, name in re.findall('<a href="(/~.*?/)"><b>(.*?)</b></a><br/><small>(.*?)</small>', html): alk = urlparse.urljoin(url, lk) data = { 'url':alk, 'name':name, 'cname':capname } phtml = urllib.urlopen(alk).read() memail = re.search('<a href="mailto:(.*?)">', phtml) if memail: data['email'] = memail.group(1) data = json.load('email') #your json data file here for entry in data: #assuming your data is an array of JSON objects user = User.create(name=entry["name"], cname=entry["cname"], email=entry["email"], url=entry["url"]) user.save() guess that there a data-file must exist: one that have been created by the script during the parsing... is this right? ) martin@linux-70ce:~/perl> python cpan_100.py Traceback (most recent call last): File "cpan_100.py", line 47, in <module> data = json.load('email') #your json data file here File "/usr/lib/python2.7/json/__init__.py", line 286, in load return loads(fp.read(), AttributeError: 'str' object has no attribute 'read' martin@linux-70ce:~/perl> this script does not work ) martin@linux-70ce:~/perl> python cpan_100.py Traceback (most recent call last): File "cpan_100.py", line 47, in <module> data = json.load('email') #your json data file here File "/usr/lib/python2.7/json/__init__.py", line 286, in load return loads(fp.read(), AttributeError: 'str' object has no attribute 'read' martin@linux-70ce:~/perl>well i suppose that in the first part of the script - the parser - part we parse data and - therefore we should create a file. I guess that this file is taken up within the second part of the script... load data . well why the script does not work!? |