Form Selection Help Needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
VVal
Forum Newbie
Posts: 3
Joined: Thu Jul 09, 2009 3:38 pm

Form Selection Help Needed

Post by VVal »

Good afternoon to everyone, I have a dilemma on my hands, well to me it is, can anyone be so kind as to assist me.
Below is my statement for a form for which I need the user to input the date and select a user and return the records that the user have inputted over a period of time.
I got the portion for the date to work fine, however I am not sure how I go about collecting the selection made from the form in order to return the desired result.
Please help if you can.

Thank you

Code: Select all

 
<?php
$dbcon = mysql_connect("localhost", "common", "admin");
if (!$dbcon)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("inventory", $dbcon);
 
 
if($_POST["execsearch"] != "" && $_POST["fr_date"] != "" && $_POST["to_date"] != "")
    {
#$result = mysql_query("SELECT * FROM customer" );
 
$query = "SELECT fname, lname, (SELECT CONCAT_WS(' ', fname, lname) FROM queuser WHERE username = createdby) AS createdby, createdtime, updatedtime, purpose, (SELECT CONCAT_WS(' ', fname, lname) FROM queuser WHERE username = updatedby) AS updatedby, comments, (SELECT description FROM branch WHERE customer.branchid = branch.branchid) AS branchid FROM customer WHERE updatedtime >= '".$_POST["fr_date"]."' AND updatedtime <= '".$_POST["to_date"]."'ORDER BY branchid";
    $result=mysql_query($query, $dbcon);
 
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo strtoupper("<td>" . $row['fname'].' '. $row['lname']) . "</td>";
  echo strtoupper("<td>" . $row['createdby']) . "</td>";
  echo strtoupper("<td>" . $row['starttime']) . "</td>";
  echo strtoupper("<td>" . $row['endtime']) . "</td>";
  echo strtoupper("<td>" . $row['purpose']) . "</td>";
  echo "<td>" . $row['updatedby'] . "</td>";
  echo "<td>" . $row['comments'] . "</td>"; 
  echo "<td>" . $row['branchid'] . "</td>"; 
  echo "</tr>";
  }
echo "</table>";mysql_close($dbcon);
 
}
 
?>
Last edited by Benjamin on Thu Aug 06, 2009 6:47 am, edited 1 time in total.
Reason: Changed code type from text to php.
towerspl
Forum Newbie
Posts: 20
Joined: Mon Aug 03, 2009 7:37 am

Re: Form Selection Help Needed

Post by towerspl »

looks like your posting the data, using it in sql and then looping out the results, nothing wrong with what i can see although the following is annoying:

the code is messy hard to read and use mysql_real_escape_string or i could delete your database in about 2 seconds(sry just very annoying that you dont know that as you are writting php code should be fundamental!)
VVal
Forum Newbie
Posts: 3
Joined: Thu Jul 09, 2009 3:38 pm

Re: Form Selection Help Needed

Post by VVal »

My apologies for annoying you towerspl I am basically new to this and trying, I would think that as someone who knows the topic you could at least point out where I have gone wrong and not try to tear me down.
I would want to think that people come to these forums to seek help and the genuine person who wants to help would point them in the right direction.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Form Selection Help Needed

Post by aceconcepts »

So where exactly do you need help?
towerspl
Forum Newbie
Posts: 20
Joined: Mon Aug 03, 2009 7:37 am

Re: Form Selection Help Needed

Post by towerspl »

sry if i was so blunt but if you read any book or tutorial on mysql in php the real_escape will be in the basics. I am not sure exactly what the problem is with your code after scanning it it looks to me like it is working fine(except what i pointed out lol)

Couple of good places to learn from w3schools.com, php.net and also a good book to learn from is the php 5 zend certified training book which I am currently reading through, it start from the basics and goes to advanced. I have learnt a lot after reading that book.
Post Reply