Jump to content

Eggzorcist

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

Contact Methods

  • MSN
    jeanpefoster@gmail.com

Profile Information

  • Gender
    Male
  • Location
    Hong-Kong, S.A.R.

Eggzorcist's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. How do I make sure the entitlement will be: query:, suggestions: and data: ?
  2. I'm thinking of using json_encode. But I think we cna only put in one variable in the function. I'm asking how can I create some kind of multi dimensional array to support this format using json_encode. or can I put 3 variables in, in my case json_encode($var1, $array[], $array[])
  3. I'm having some trouble formatting my variables for the proper JSON encode I'm trying to pull. Here is the json encode I'm trying to output: { query:'Li', suggestions:['Liberia','Libyan Arab Jamahiriya','Liechtenstein','Lithuania'], data:['LR','LY','LI','LT'] } the information is just for testing right now. Don't mind that. I want to input 3 fields. query is only one variable $query. Then we have the suggestions array and the data array. How could i make a 4 dimensional array to show li singled out, then the other two arrays? How is this done and what is it called? Not sure what way I should go about doing this.
  4. I want them to be able to submit using the button. But I'm using an ajax form select which highlights possible users from the database. I want the user to be abl to user the arrow keys to go up and down the list and when they press enter to select that user. I want the submit to work just not by pressing enter button.
  5. I used that so when the user pressed enter it wouldn't submit. How can I solve that issue then?
  6. trying to catch it so I'm print_r post and nothing is added to $_POST array. I'm wondering what I'm doing wrong? <?php print_r($_POST); ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>" onsubmit="return false;" class="asholder"> <small style="float:right">Hidden ID Field: <input type="text" id="userID" value="" style="font-size: 10px; width: 20px;" disabled="disabled" /></small> <input style="width: 200px" type="text" id="personinput" value="" placeholder="Person" /><br /> <input type="radio" name="owes" value="sUser" placeholder="Who Owe's Who?" /> owes me <input type="radio" name="owes" value="mUser" /> I owe them <br /> <input style="width: 200px" type="text" id="amount" value="" placeholder="Amount of..." /><br /> <textarea style="width: 200px; height: 50px;" id="comment" value="" placeholder="Comment"></textarea><br /> <input type="submit" name="submit" value="submit" id="submit" /> </form> </div> any help would be greatly appreciated.
  7. I want multiple rows but the output needs to be $values = array( 1 => "value1"); so I can grab them with values[1]...values[4]...
  8. Hey there, I've been looking through the PDO classes on php.net but am a bit confused by how to fetch a one dimensional array. Is this possible or will i have to fetch an assoc then transfer through a loop? I've also heard of FETCH_INT as the fetching style but it's not in the php manual. Any help..
  9. Hey everyone. For some reason, one of my function does not display what it is supposed to and even outside the function after it has been called any echo's after it won't be echoe'd. Here is my function: function friendsList($id){ $query = $dbh->prepare("SELECT users.id, users.fb_id, users.fb_pic, users.fn FROM users INNER JOIN friendlist ON users.fb_id = friendlist.friend2 WHERE friendlist.friend1 = ? AND friendlist.status = 1"); $query->bindValue(1, $id); $query->execute(); $friendNum = $query->rowCount(); $friendList = $query->fetchAll(PDO::FETCH_ASSOC); $output = ""; foreach($friendList as $row){ $output .= "<img src ='". $row['users.fb_pic']. "alt = '". $row['users.fn'] ."' /> "; $output .= $row['users.fn']. "</br>"; } return $output; } Could it be my MAMP server? I don't get any PHP errors and have looked numerous times throughout this function to find nothing out of the ordinary. Thanks for the headsup
  10. Hi everyone. My question does it become too much for a social media site to have too many queries to the database. Maybe my database retrieval ability is very weak though I find myself having trouble trying to get lots of information from my database in only in a few queries. For example. I have a database that looks like this: id1, id2, var1. the Id's are user IDs. Though I also need both user's names which is from the users db. THough I'm having trouble obtaining both their names. SELECT * FROM users, owes WHERE (owes.id1 = 1 OR owes.id2 = 1) AND owes.active = 1 AND owes.confirmed = 1 AND owes.id1 = users.id AND owes.id2 = users.id Though my last SQL line does not select both, instead it selects nothing because users.id seem to already have a user taken and thus since the first users.id is not = var2 nothing is selected. I want to select the data which id = 1 is at id1 or id2, while selecting the profile info of id = 1 and id = 2. is this possible all in one query?
  11. Hi there, I'm fairly new to OOP, but not PDO. I was wondering what is the best practice for using PDO inside an object? Should I use my try-catch inside my construct? Though I use the database for all objects so what's the best way? Thanks
  12. Hi there, an unusual problem has occured. It's the first time I've had this issue. I'm printing a loop inside a <section><section> html code which is within the echo of the php code. For some reason when the php echoed variables do not stretch the html <section>. The section stays small as if there were nothing in it. if (isset($fListData)){ echo "<section class='fResults'><ul class='friendlist'>"; foreach ($fListData as $row){ $fDisplay = "<li><a href='profile.php?pf=".$row['id']."'>"; $fDisplay .= $row['firstname']. " " .$row['lastname']; $fDisplay .= " (".$row['username'].")</a></li>"; echo $fDisplay; } echo "</ul></section>"; } else { echo "<p>You currently have no friends. Use the search!</p>"; }
  13. Yes I'm aware of that. But in one I try to bind the first query with the owing.ownee = USERID and owing.ower = "every value found". while the second query is the opposite. How would I do that? So technically I don't need one of the parameters in each query but to save on a query I put in both. My question was how can I bind a value that makes it so that logic or value doesn't matter whatever it is. so I can catch owing.ower = every value. Thanks
  14. Hi everybody. I was just wondering whether there is a value in PHP we can plugin to the PDO which makes it so it suits all values? In practice I want to use a PDO statement for two functions. Here is my PDO->prepare statement.. "SELECT users.firstname, users.lastname, users.id, owing.type, owing.forWhat, owing.amount FROM users, owing WHERE (owing.ownee = ? && owing.ower = ?) && owing.status = ?" The thing is I use this data in two different ways. One dataset needs owing.ownee to me userID and the other can be whatever. While the second dataset needs the ower to be UserID while it doens't matter who the ownee is. I was wondering if this were possible or did I need another query entirely?
  15. I've found the problem. It was actually with a faulty UPDATE statement. I was using or instead of AND. That's why too many rows were getting played with. "UPDATE friendlist SET status = ? WHERE (friend1 = ? && friend2 = ?) OR (friend1 = ? && friend2 = ?) " worked like a charm.
×
×
  • 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.