Jump to content

bluwe

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bluwe's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello, I'm struggling with the following bit of code... $query = "SELECT column1, column2, column3, DATE_FORMAT(column4,'%d-%m-%y'), column5 FROM table1 WHERE column1 = '$customerid'"; $result = mysql_query($query) or die ("Unable to retrieve values.".mysql_error()); $nrows = mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $n = $i + 1; $row = mysql_fetch_array($result); extract($row); $row[DATE_FORMAT(column4, '%d-%m-%y')] = $variable; echo $variable; } I can't get the date value into $variable. Where am I going wrong? This is doing my head in! Thanks
  2. I want to check if all the values in an array are empty and if this is true echo a message or something. However, I don't want to echo anything if just one value in the array is not empty...I hope I have explain this ok! Can anyone help with this? Thanks!
  3. Exactly right. Cheers buddy!
  4. I'm trying to pass a variable from one page to another using POST. On the first page the variable has a value of "hello my friend" on the second page when I echo the posted variable I just get "hello" Any ideas why this might be? Cheers, James
  5. Thnaks for all your help, much appreciated!!
  6. This deffo works though... [code]<select name=title> <?php $dbvariable = "Dr"; $title = array ("Mr", "Mrs", "Miss", "Ms", "Dr"); foreach($title as $tname){   if($tname == $dbvariable){   echo "<option value=$tname selected>$dbvariable</option>";   } } foreach($title as $tname){ if($tname !=$dbvariable){   echo "<option value=$title>$tname</option>"; } } echo "</select>"; ?>[/code]
  7. Actually the above doesn't work, hmm....
  8. Thanks for the start Ray, needed a bit of debugging though, but finally got it working like so... [code]<select name=title> <?php $dbvariable = "Miss"; $title = array ("Mr", "Mrs", "Miss", "Ms", "Dr"); foreach($title as $tname){   if($tname == $dbvariable){   echo "<option value=$dbvariable selected>$dbvariable</option>";   } else {   echo "<option value=$title>$tname</option>";   } } echo "</select>"; ?>[/code]
  9. I just get a parse error with that "Unexpected T STRING"
  10. Thanks, but it still doesn't work! What I need to do is get the results of the query into an array, then loop through the array and do a select statement on each value in the array, then echo the values out to the scren but I just can't figure it out!
  11. Hi there, I've got a search form that allows users to search for records in the table they choose based on the column they choose which defines the variables I use in the select statement. Because they only search one one column in one table I want to use their search criteria to pull out the customer_id record for each record the search returns. I then want to use this customer id number to search all three tables in my database, then echo out the records. This is the code I've come up with but I can't seem to get it to work. I don't get any errors, just a blank screen: [code]#Search database $query = "SELECT customer_id FROM $table WHERE $column LIKE '%$searchterm%'"; $result = mysql_query($query) or die ("Unable to execute search.".mysql_error()); while ($row = mysql_fetch_array($result)) { #Get the customer id for each record $customerid = $row['customer_id']; #Retrieve records from all tables based on customer id $query = "SELECT * FROM customers, cards, digiboxes WHERE customers.customer_id = cards.customer_id AND customers.customer_id = cards.customer_id AND customers.customer_id = $customerid"; $result = mysql_query($query) or die ("Unable to execute search.".mysql_error()); while ($row1 = mysql_fetch_array($result)) { echo $row1['customer_id']; echo "<br>"; echo $row1['surname']; echo "<br>"; echo $row1['cardnumber']; echo "<br>"; echo $row1['serialnumber']; echo "<br>"; echo "<br>"; echo "<br>"; } ?>[/code] If I'm not making myself clear let me know! Thanks
  12. That's excellent! Thanks you all very much!!!
  13. Thanks for replying. I've got a title column in my customer details table with the following options: Mr, Mrs, Miss, Ms, Dr. When a user edits the customer details record it is obviously retireved from the db using a SELECT statement and displayed in a html table. I want to populate the first entry in the title drop down menu in the table with the value returned from the db, but still have the other options available. If you see what I mean! Cheers!
  14. I want to retrieve a record from my database and display the record as the default choice in a html drop down menu - is this possible? Cheers...
  15. I got it to work as a test - must be a mistake in my code! Thanks for your help!!
×
×
  • 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.