Jump to content

sam20e

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

sam20e's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, This is my update.php code : http://pastebin.com/RsqgRyhg
  2. Thank you for your prompt response. I adjusted my code but its still letting empty records to be saved. 1) I channged formObj to my form id 2) I changed id to another column/field name Apart from these 2 changes I copy/paste your new codes, so it should work right? am I making any errors? If you have any other JS scrtips to validate easily can you share with me?
  3. Hi Thank you for the reply. This is what I have so far : HTML <!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> <title>Search</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <form action="post.php" method="GET"> <input type="text" name="text" /> <input type="submit" value="Search" /> </form> </body> </html> PHP <?php mysql_connect("localhost", "db", "pass") or die("Connection Failed"); mysql_select_db("db")or die("Connection Failed"); $text= $_POST['text']; $query = "select * from table where text= '$text'"; $result = mysql_query($query); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "Name: ".$line['name']; echo " Age: ".$line['age']; echo "<br>\n"; } ?> It works great, but this is displaying result in a new window, i want the result to be shown bellow my button and also need to show no records found if the query result is null/na
  4. Hello I have a textbox and a input button which will insert a mysql record, however i need to validate that textbox if its empty it shouldnt allow that button to insert any record but show a popup error. my script : <script Language="JavaScript"> function Blank_TextField_Validator() { // Check the value of the element named text_name // from the form named text_form if (frmContact.id.value == "") { // If null display and alert box alert("Please fill in the text field."); // Place the cursor on the field for revision frmContact.id.focus(); // return false to stop further processing return (false); } // If text_name is not null continue processing return (true); } </script> Form : <form name="frmContact" id="frmContact" method="POST" action="index.php" onsubmit="return Blank_TextField_Validator()"> however its not validating or showing any error. any help?
  5. hi im new to these stuff and appreciate any help. im creating a simple form with 1 textbox and a search button. when the button is pressed a select query should run and check the mysql database and list that result on that same page. For example, lets say there is a textbox named Lastname, then the search button should search mysql and list down the last name matching that name. Form code : <!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> <title>Search</title> </head> <body> <form action="post.php" method="GET"> <input type="text" name="query" /> <input type="submit" value="Search" /> </form> </body> </html> Any help? I need to show the result right bellow the button, and if no match found it should display an error : no match found thanks
  6. Hi guyz I found this code : http://pastebin.com/gK4qTxVy This is to check the mysql connection, the problem is this checks the DB connection internally only. I mean you need to upload this file to the server and check the connection, what i want is where i can externally check the connection.. Meaning if i host this php in my server, i should be able to check any db connection by providing the server name or server ip. Currently if I do this it says access denied in my local server. anyone can guide? Thanks
  7. i did following : <select name="day_new" id="day_new" class="tyextfild validate-selection required"> <?php if($day_new == '') { $day_new=date(d, strtotime($d_soc_exp_date)); } $gnrl->getDropdownList(range( 1, 31 ),$day_new); ?> </select> <select name="month_new" id="month_new" class="tyextfild validate-selection required"> <?php if($month_new == '') { $month_new=date('m', strtotime($d_soc_exp_date)); } for($i=00; $i <= 12; $i++ ) { $selected = ( in_array('$i',explode(',',$month_new) ) ? "selected=\"selected\"" : "" ); echo "<option value=\"$i\"$selected>". date(M, $i) ."</option>"; } ?> </select> <select name="year_new" id="year_new" class="tyextfild validate-selection required"> <?php if($year_new == '') { $year_new=date(Y, strtotime($d_soc_exp_date)); } $gnrl->getDropdownList(range( '1970', date( 'Y', time() ) ),$year_new); ?> </select> in this database record has been already stored.. date and year showing correct figure stored in the db.. but month not showing.. according to db March should be selected but this one Dec getting selected any help?
  8. Hi ok, this is what i want. I have a birthday form. the above code is for date dropdown, month drop down, year drop down. now i need another set of drop down for example anniversary date : date dropdown, month drop down, year drop down. when i copy my birthday dropdown code and create an anniversary set, it shows birthday set value even though database contains correct value in short i need another set of birthday dropdown...
  9. Hi Pls refer bellow mentioned code.. this code will prompt 2 hyperlinks when we click that it will export the result to CSV file.. My problem is i can set the conditions in where clause for 2 links individually.. but i need to select the different table columns.. example for these 2 csv export links, i can set the condition in 'where'=>"WHERE id=1", But i got only 1 definition : $sql_query = "select * from $table ".$where; can anyone advise me how can i have different select query for these 2 links individually? so i can select any column from tbl1 or tbl2 for example i need something like this : $sql_query1 = "select id,name from $table ".$where; $sql_query2 = "select firstname,lastname from $table ".$where; $sql_query3= "select location from $table ".$where; This is the full code : <?php function exportMysqlToCsv($table,$where = '',$filename = 'Report.csv') { $csv_terminated = "\n"; $csv_separator = ","; $csv_enclosed = '"'; $csv_escaped = "\\"; $sql_query = "select * from $table ".$where; // Gets the data from the database $result = mysql_query($sql_query); $fields_cnt = mysql_num_fields($result); $schema_insert = ''; for ($i = 0; $i < $fields_cnt; $i++) { $l = $csv_enclosed . str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, stripslashes(mysql_field_name($result, $i))) . $csv_enclosed; $schema_insert .= $l; $schema_insert .= $csv_separator; } // end for $out = trim(substr($schema_insert, 0, -1)); $out .= $csv_terminated; // Format the data while ($row = mysql_fetch_array($result)) { $schema_insert = ''; for ($j = 0; $j < $fields_cnt; $j++) { if ($row[$j] == '0' || $row[$j] != '') { if ($csv_enclosed == '') { $schema_insert .= $row[$j]; } else { $schema_insert .= $csv_enclosed . str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, $row[$j]) . $csv_enclosed; } } else { $schema_insert .= ''; } if ($j < $fields_cnt - 1) { $schema_insert .= $csv_separator; } } // end for $out .= $schema_insert; $out .= $csv_terminated; } // end while header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Length: " . strlen($out)); // Output to browser with appropriate mime type, you choose header("Content-type: text/x-csv"); //header("Content-type: text/csv"); //header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=$filename"); echo $out; exit; } // please assign more table with assoiciated name. $lst_csv_req = array( 'All Employees Records'=> array( 'table'=>'tbl1', 'where'=>"WHERE id=1", 'db'=>'testdb'), 'All Employees Records2'=> array( 'table'=>'tbl2', 'where'=>"WHERE id=1", 'db'=>'testdb') ); if(isset($_GET['action'])): $host = 'localhost'; // MYSQL database adress $db = 'testdb'; // MYSQL database name $user = 'testdb'; // Mysql Datbase user $pass = 'testdb'; // Mysql Datbase password // Connect to the database $link = mysql_connect($host, $user, $pass); //mysql_select_db($db); if(array_key_exists ( $_GET['action'] , $lst_csv_req)) { $req_arr = $lst_csv_req[$_GET['action']]; if(!isset($req_arr['table']) || trim($req_arr['table']) == '') { echo 'Please check array. table name not entered'; exit; } if(!isset($req_arr['db']) || trim($req_arr['db']) == '') { echo 'Please check array. DB name not entered'; exit; } // $where = ' '.@$req_arr['table'].' '; $where = ' '.@$req_arr['where'].' '; mysql_select_db($req_arr['db']); $table= $req_arr['table']; // this is the tablename that you want to export to csv from mysql. exportMysqlToCsv($table, $where); } else { echo "requested report does not exist."; } endif; // generate link: echo "<strong>Report download link:</strong><br /> --------------------------------------------<br />"; foreach($lst_csv_req as $key=>$vale): $link = $_SERVER['PHP_SELF']."?action={$key}"; echo "<a href='$link '>{$key} - [ Download Report ]<br /></a>"; endforeach; ?> Thanks
  10. Hi I have one date field drop down : $day = $_POST['day']; $mon = $_POST['month']; $year = $_POST['year']; $dob = $year . "-" . $mon . "-" . $day; $ins = array( 'd_dob' => $dob ); <tr> <td align="left" valign="middle">Date Of Birth<span class="astrikrequired">*</span>: </td> <td align="left" valign="middle"> <select name="day" id="day" class="tyextfild validate-selection required"> <?php if($day == '') { $day=date(d, strtotime($d_dob)); } $gnrl->getDropdownList(array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'),$day); ?> </select> <select name="month" id="month" class="tyextfild validate-selection required"> <?php if($month == '') { $month=date(m, strtotime($d_dob)); } ?> <option value="01" <?php if(in_array('01',explode(',',$month))) echo 'selected="selected"';?> >Jan</option> <option value="02" <?php if(in_array('02',explode(',',$month))) echo 'selected="selected"';?>>Feb</option> <option value="03" <?php if(in_array('03',explode(',',$month))) echo 'selected="selected"';?>>Mar</option> <option value="04" <?php if(in_array('04',explode(',',$month))) echo 'selected="selected"';?>>Apr</option> <option value="05" <?php if(in_array('05',explode(',',$month))) echo 'selected="selected"';?>>May</option> <option value="06" <?php if(in_array('06',explode(',',$month))) echo 'selected="selected"';?>>Jun</option> <option value="07" <?php if(in_array('07',explode(',',$month))) echo 'selected="selected"';?>>Jul</option> <option value="08" <?php if(in_array('08',explode(',',$month))) echo 'selected="selected"';?>>Aug</option> <option value="09" <?php if(in_array('09',explode(',',$month))) echo 'selected="selected"';?>>Sep</option> <option value="10" <?php if(in_array('10',explode(',',$month))) echo 'selected="selected"';?>>Oct</option> <option value="11" <?php if(in_array('11',explode(',',$month))) echo 'selected="selected"';?>>Nov</option> <option value="12" <?php if(in_array('12',explode(',',$month))) echo 'selected="selected"';?>>Dec</option> </select> <select name="year" id="year" class="tyextfild validate-selection required"> <?php if($year == '') { $year=date(Y, strtotime($d_dob)); } $gnrl->getDropdownList(array('1960','1961','1962','1963','1964','1965','1966','1967','1968','1969','1970','1971','1972','1973','1974','1975','1976','1977','1978','1979','1980','1981','1982','1983','1984','1985','1986','1987','1988','1989','1990','1991','1992','1993','1994','1995','1996','1997','1998','1999','2000','2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012'),$year); ?> </select> </td> </tr> This works perfectly. After i select date/month/year,and submit, its showing the results stored in the db without any issues... now i need another date set same thing like this. for ex date/month/year drop down. i tried changing the variable names etc but still it shows incorrect date/month/year (previous data) can help me how can i create another set of this 3 dorp down without issues? Thanks
  11. Hi I have a PHP script. Its a library management system. So after all the books are stored in the database i need to create multiple reports - like clicking a link which will execute the SQL command and export the result to CSV. Can anyone guide me how can we do this CSV export? Thanks Sam
  12. i juz tried to connect them but im not sure whether i have done that correctly... plz correct me Customer >o---------------------------------l Agency Customer >o--------------------------------o<Tours Customer l----------------------------------o<Payment Agency >o----------------------------------l Tours Tours l-------------------------------------o<Hotel is this is correct plz help
  13. this is the scene... a tour company books tours from diferent agencies... customers given invioice and their details bn entered into the system... should develop a Entity Relationship Diagram - Crow Foot model... plz help... i have given the tables pic....
×
×
  • 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.