Jump to content

plodos

Members
  • Posts

    212
  • Joined

  • Last visited

Everything posted by plodos

  1. yes, ım losing my search value Query: select * from person where like '%%' it is empty if I use like that, just an idea...I dont knpw how to write:) echo "<p align=\"center\"><b><a href=\"search.php?page=$back&search=$search&type=$type\"><< Back </a>"; What must I do for work this code ?
  2. <?php include("dbconfig.php"); function title_case($title) { // deleted } $search = mysql_real_escape_string($_POST['search']); $type = mysql_real_escape_string($_POST['type']); $page = $_GET["page"]; if(empty($page) or !is_numeric($page)){ $page = 1; } $limit = 25; $query1 = mysql_query("select * from person where $type like '%$search%'") or die (mysql_error () ); $rowNumber = mysql_num_rows($query1); $pageNumber = ceil($rowNumber / $limit); $start = ($page-1)*$limit; $data = mysql_query("select * from person where $type like '%$search%' ORDER BY lname ASC LIMIT $start,$limit") or die (mysql_error ()); while($info=mysql_fetch_array($data)) { if($info['no']=="1") { echo title_case($info['lname'])." ".title_case($info['fname']).", ".$info['country']." <br>"; } if($info['no']=="2") { echo title_case($info['lname'])." ".title_case($info['fname']).", ".$info['country']." <br>"; } } if($page > 1){ $back = $page-1; echo "<p align=\"center\"><b><a href=\"search.php?page=$back\"><< Back </a>"; }else{ echo "<p align=\"center\"><b> << Back "; } echo " | "; if($page>=$pageNumber){ echo "Next >> </b></p>"; }else{ $next = $page+1; echo "<a href=\"search.php?page=$next\">Next >></a></b></p>"; } ?> Im trying to using paging 0-25, 25-50 ....... first page is listing all records 0-25, but when I click to next page....program is giving there errors?... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%%'' at line 1 I used this paging code before, i didnt face any problem....but now this scipts first page is showing the records 0-25, why the second page is giving this error ? Some of the mysql datas are uppercase/lowercase like ERIK, Erik, erik...and im trying the search with lowercase...it can be an error? without paging $data = mysql_query("select * from person where $type like '%$search%' ORDER BY lname ASC LIMIT $start,$limit") or die (mysql_error ()); while($info=mysql_fetch_array($data)) { if($info['no']=="1") { echo title_case($info['lname'])." ".title_case($info['fname']).", ".$info['country']." <br>"; } if($info['no']=="2") { echo title_case($info['lname'])." ".title_case($info['fname']).", ".$info['country']." <br>"; } } I want to show these records with paging? :S ? :S ?
  3. No. next page shows nothing, just an error..... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%%'' at line 1
  4. $_POST['search'] and $_POST['type'] is not blank.... for example im searching 'Mobile', program finds 43 rows.... First page is listing 25 records, but when I click the next page, just an error....next page must show 18 records...
  5. <?php include("dbconfig.php"); function title_case($title) { // Our array of 'small words' which shouldn't be capitalised if // they aren't the first word. Add your own words to taste. $smallwordsarray = array( 'of','a','the','and','an','or','nor','but','is','if','then','else','when', 'at','from','by','on','off','for','in','out','over','to','into','with' ); // Split the string into separate words $words = explode(' ', $title); foreach ($words as $key => $word) { // If this word is the first, or it's not one of our small words, capitalise it // with ucwords(). if ($key == 0 or !in_array($word, $smallwordsarray)) $words[$key] = ucwords(strtolower($word)); } // Join the words back into a string $newtitle = implode(' ', $words); return $newtitle; } $search = mysql_real_escape_string($_POST['search']); $type = mysql_real_escape_string($_POST['type']); $page = $_GET["page"]; if(empty($page) or !is_numeric($page)){ $page = 1; } $limit = 25; $query1 = mysql_query("select * from person where $type like '%$search%'") or die (mysql_error () ); $rowNumber = mysql_num_rows($query1); $pageNumber = ceil($rowNumber / $limit); $start = ($page-1)*$limit; $data = mysql_query("select * from person where $type like '%$search%' ORDER BY lname ASC LIMIT $start,$limit") or die (mysql_error ()); while($info=mysql_fetch_array($data)) { if($info['committee_no']=="1") { echo title_case($info['lname'])." ".title_case($info['fname']).", ".$info['country']." <br>"; } if($info['no']=="2") { echo title_case($info['lname'])." ".title_case($info['fname']).", ".$info['country']." <br>"; } } if($page > 1){ $back = $page-1; echo "<p align=\"center\"><b><a href=\"search.php?page=$back\"><< Back </a>"; }else{ echo "<p align=\"center\"><b> << Back "; } echo " | "; if($page>=$pageNumber){ echo "Next >> </b></p>"; }else{ $next = $page+1; echo "<a href=\"search.php?page=$next\">Next >></a></b></p>"; } ?> Im trying to using paging 0-25, 25-50 ....... first page is listing all datas 0-25, but when I click to next page....program is giving there errors?... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%%'' at line 1 I used this paging code before, i didnt face any prbblem....but now this scipts first page is showing the datas 0-25, why the second page is giving this error ???? Some of the mysql datas are uppercase/lowercase like ERIK, Erik, erik...and im trying the search with lowercase...it can be an error?
  6. Im trying to using paging 0-25, 25-50 ....... first page is listing all datas 0-25, but when I click to next page....program is giving there errors?...
  7. $Rows = mysql_num_rows(mysql_query("select * from person where $type like '%$search%'")) or die (mysql_error ()); Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/search.php on line 187 -----------------------and------------------ $data = mysql_query("select * from person where $type like '%$search%' ORDER BY lname ASC LIMIT $start,$limit") or die (mysql_error ()); You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%%'' at line 1 What are these problems?
  8. echo ucwords(strtolower($info['lname']))." ".ucwords(strtolower($info['fname']))."}, {".$info['country']." (Nat) <br>; echo ucwords(strtolower($info['university'])) <br>; I didnt apply the code Parse error: syntax error, unexpected '(', expecting ',' or ';
  9. Problem 1 ) Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/wasetorg/public_html/search.php on line 177 $data = mysql_query("select * from person where $type like '%$search%' ORDER BY lname ASC LIMIT 0,30"); while($info=mysql_fetch_array($data)) { if($info['no']=="1") { echo" {ucwords(strtolower($info['lname']))} {ucwords(strtolower($info['fname']))} "; //line 177 } } Problem 2) Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:......... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:......... while($info=mysql_fetch_array($data)) { if($info['no']=="1") { echo" {$info['lname']} {$info['fname']}"; } Some of the mysql datas are uppercase/lowercase like ERIK, Erik, erik....maybe because of that it gives "supplied argument is not a valid" worning... where $type like '%$search%' Im using like operators, if I convert all data with ucwords(), I can match the true datas.... How can I solve these problems? I didnt do it....
  10. thank you... I used this system include("dbconfig.php"); $name =mysql_real_escape_string($_POST['name']); $surname = mysql_real_escape_string($_POST['surname']); $sql = mysql_query("SELECT * FROM person WHERE fname = '$name' AND lname = '$surname'"); if(mysql_num_rows($sql) < 1){ $add_person= mysql_query(" INSERT INTO person (fname,lname) VALUES ('$name','$surname') "); if($add_person){ include('ok.html'); } else echo "Error"; } } but I have one more question:) phpmyadmin recorded the empty data....If the user click register 5 times...mysql is saving the first data with full information and other 4 fields are empty like 1 nokia mobile 2 3 4 5 6 samsung mobile 7 8 sony mobile how can I block the emyty data?
  11. form.html <form action="a.php" method="post"> <table border="0" bgcolor="#ececec" cellspacing="5"> <tr> <td>Name</td><td> <input name="name" type="text" id="name" size="25"/></td> </tr> <tr> <td>Surname</td><td> <input name="surname" type="text" id="surname" size="25"/></td> </tr> </table> </form> a.php <?php include("dbconfig.php"); $name =mysql_real_escape_string($_POST['name']); $surname = mysql_real_escape_string($_POST['surname']); $add_person= mysql_query(" INSERT INTO person (fname,lname) VALUES ('$name','$surname') "); if($add_person) { include('ok.html'); } else { echo "Error"; } ?> This is my sample code, I want to improve that, how can I block the repeated data.... If the person click the Register button 3 times, database is saving the person information 3 times, and when I listed, query show me 3 same information.... what must I do ? I want to see unique information for each person....I want to block multiple records, please help...
  12. this is working..... $data = mysql_query("select * from person where no='1' ORDER BY person_id DESC"); problem is here $data = mysql_query("select * from person where no='1' AND UNIQUE(email) ORDER BY person_id DESC"); I got an error like : mysql fetch array worning, supplied argument like that... How can I solve the problem?
  13. select name,title from person output record no: 300 title : aaaaaaaaaaaaaaaaaaaa name: George Borks record no: 301 title : aaaaaaaaaaaaaaaaaaaa name: George Borks record no: 302 title : aaaaaaaaaaaaaaaaaaaa name: George Borks .......... ........ ....... For exapmle, George Borks registered 3 times....and when I listed data, there are 3 records, It is not good to see repeated records on the web page.. How can I listed only one ( without repeated George Bush),
  14. EACH MEMBER HAS GRADE like that sql table CREATE TABLE `person` ( .............................. `grade` INT NOT NULL, ............................. ) php/query for list the members without GRADE system <?php include('dbconfig.php'); $data = mysql_query("select p.* from join_person_committee j, person p where j.committee_id=1 AND j.person_id = p.person_id"); //sample query without GRADE while($info=mysql_fetch_array($data)) { echo" {$info['fname']} {$info['lname']}, {$info['country']} <br>"; echo" {$info['uni']}<br>"; echo" {$info['uni_dept']}<br>"; } ?> grade = 0 normal member grade = 0-50 silver member grade = 50-100 gold member If user has 100 Grade, output will be like that echo" {$info['fname']} {$info['lname']}, {$info['country']} ([b]GOLD MEMBER[/b])<br>"; echo" {$info['uni']}<br>"; echo" {$info['uni_dept']}<br>"; If user has 50 Grade, output will be like that echo" {$info['fname']} {$info['lname']}, {$info['country']} ([b]SILVER MEMBER[/b])<br>"; echo" {$info['uni']}<br>"; echo" {$info['uni_dept']}<br>"; If user has 0 Grade, output will be like that echo" {$info['fname']} {$info['lname']}, {$info['country']} ([b]NORMAL MEMBER[/b])<br>"; echo" {$info['uni']}<br>"; echo" {$info['uni_dept']}<br>"; Thats not possible to write NORMAL/SILVER/GOLD MEMBERs one by one for each user..There must be a auto-system.. You understood what I mean... How can I write these code? What must I do? Who can give me the sample/example code? Thanks for helping me....
  15. sql CREATE TABLE `person` ( `person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR(20) NOT NULL, `fname` VARCHAR( 40 ) NOT NULL , `lname` VARCHAR( 40 ) NOT NULL , `email` VARCHAR( 128 ) NOT NULL , `country` VARCHAR( 128 ) NOT NULL , `university` TEXT NOT NULL, `university_dept` TEXT NOT NULL, `phone` VARCHAR(40) NOT NULL, `fax` VARCHAR(40) NOT NULL, `research_field` TEXT NOT NULL, `address` TEXT NOT NULL, `date` DATETIME ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `committee` ( `committee_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` TEXT NOT NULL ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `join_person_committee` ( `person_id` INT NOT NULL , `committee_id` SMALLINT NOT NULL , PRIMARY KEY ( `person_id` , `committee_id` ) ) ENGINE = MYISAM ; insert into committee values(`10`,`Electrical`); insert into committee values(`9`,`Industrial`); insert into committee values(`8`,`Engineering`); insert into committee values(`7`,`Processing`); insert into committee values(`6`,`Mathematics`); insert into committee values(`5`,`Biological`); insert into committee values(`4`,`Computer`); insert into committee values(`3`,`Computational`); insert into committee values(`2`,`Sciences`); insert into committee values(`1`,`Technology`); error SQL : INSERT INTO committee VALUES ( `10` , `Electrical` ); MySQL : #1054 - Unknown column '10' in 'field list' I changed all of them " ' " , still there is a problem?
  16. sql CREATE TABLE `person` ( `person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR(20) NOT NULL, `fname` VARCHAR( 40 ) NOT NULL , `lname` VARCHAR( 40 ) NOT NULL , `email` VARCHAR( 128 ) NOT NULL , `country` VARCHAR( 128 ) NOT NULL , `university` TEXT NOT NULL, `university_dept` TEXT NOT NULL, `phone` VARCHAR(40) NOT NULL, `fax` VARCHAR(40) NOT NULL, `research_field` TEXT NOT NULL, `address` TEXT NOT NULL, `date` DATETIME ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `committee` ( `committee_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` TEXT NOT NULL ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `join_person_committee` ( `person_id` INT NOT NULL , `committee_id` SMALLINT NOT NULL , PRIMARY KEY ( `person_id` , `committee_id` ) ) ENGINE = MYISAM ; insert into committee values('10','Electrical'); insert into committee values('9','Industrial'); insert into committee values('8','Engineering'); insert into committee values('7','Processing'); insert into committee values('6','Mathematics'); insert into committee values('5','Biological'); insert into committee values('4','Computer'); insert into committee values('3','Computational'); insert into committee values('2','Sciences'); insert into committee values('1','Technology'); query SELECT committee_id FROM committee WHERE name = `Electrical` LIMIT 0 , 30 MySQL #1054 - Unknown column 'Electrical' in 'where clause' query has a problem? dou you know why?
  17. error is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''PERSON'' at line 1 sql codes CREATE TABLE `person` ( `person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR(20) NOT NULL, `fname` VARCHAR( 40 ) NOT NULL , `lname` VARCHAR( 40 ) NOT NULL , `email` VARCHAR( 128 ) NOT NULL , `country` VARCHAR( 128 ) NOT NULL , `university` TEXT NOT NULL, `university_dept` TEXT NOT NULL, `phone` VARCHAR(40) NOT NULL, `fax` VARCHAR(40) NOT NULL, `research_field` TEXT NOT NULL, `address` TEXT NOT NULL, `date` DATETIME ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `committee` ( `committee_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` TEXT NOT NULL ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `join_person_committee` ( `person_id` INT NOT NULL , `committee_id` SMALLINT NOT NULL , PRIMARY KEY ( `person_id` , `committee_id` ) ) ENGINE = MYISAM ; What is wrong...?
  18. codes... $total_id = mysql_query("SELECT * FROM 'PERSON'"); $num_rows = mysql_num_rows($total_id); $num_rows++; $sql = "select 'committee_id' from 'committee' where 'name'='$committee'"; $id = mysql_query($sql); $result = mysql_fetch_assoc($id); foreach ($result as $v) { $k=$v; } $count_commit = $k; errors Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/committees/add.php on line 19 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/public_html/committees/add.php on line 24 Warning: Invalid argument supplied for foreach() in /home/public_html/committees/add.php on line 25 How can I solve these errors?
  19. I havent any exprience....could you check the code... I used two insert, 3 different table and join Its is working but, thats better to make a good code;) <?php include("dbconfig.php"); $title=$_POST['title']; $name = $_POST['name']; $surname = $_POST['surname']; $email = $_POST['email']; $country = $_POST['country']; $university = $_POST['university']; $university_dept = $_POST['university_dept']; $phone=$_POST['phone']; $fax = $_POST['fax']; $committee = $_POST['committee']; $link = $_POST['link']; $research = $_POST['research']; $address = $_POST['address']; $date = date("Y-m-d H:m:s"); $total_id = mysql_query("SELECT * FROM PERSON"); $num_rows = mysql_num_rows($total_id); $num_rows++; $sql = "select committee_id from committee where name='$committee'"; $id = mysql_query($sql); $result = mysql_fetch_assoc($id); foreach ($result as $v) { $k=$v; } $count_commit = $k; // which committe selected $add_person= mysql_query(" INSERT INTO person (title,fname,lname,email,country,university,university_dept,phone,fax,research_field,address,paper_link,date) VALUES ('$title','$name','$surname','$email','$country','$university','$university_dept','$phone','$fax','$research','$address','$link','$date') "); $add_join_person_committee = mysql_query(" INSERT INTO join_person_committee (person_id,committee_id) values ('$num_rows','$count_commit') "); if($add_person && $add_join_person_committee) { header('Location: http://localhost/committee/organization'); } else { echo "Error"; } ?> dbase.sql CREATE TABLE `person` ( `person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR(20) NOT NULL, `fname` VARCHAR( 40 ) NOT NULL , `lname` VARCHAR( 40 ) NOT NULL , `email` VARCHAR( 128 ) NOT NULL , `country` VARCHAR( 128 ) NOT NULL , `university` TEXT NOT NULL, `university_dept` TEXT NOT NULL, `phone` VARCHAR(40) NOT NULL, `fax` VARCHAR(40) NOT NULL, `research_field` TEXT NOT NULL, `address` TEXT NOT NULL, `paper_link` TEXT NOT NULL, `date` DATETIME ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `committee` ( `committee_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` TEXT NOT NULL ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `join_person_committee` ( `person_id` INT NOT NULL , `committee_id` SMALLINT NOT NULL , PRIMARY KEY ( `person_id` , `committee_id` ) ) ENGINE = MYISAM ;
  20. <center> <form name="combowithtext"> <select name="example" size="1" onChange="showtext()"> <option value="AAA">AAA</option> <option value="BBB">BBB</option> <option value="CCC">CCC</option> </select> <input name="text" type="text" id="text" size="28"/> <script language="javascript"> <!-- var shortcut=document.combowithtext var descriptions=new Array() descriptions[0]="aaa" descriptions[1]="bbb" descriptions[2]="ccc" shortcut.text.value=descriptions[shortcut.example.selectedIndex] function showtext() { shortcut.text.value=descriptions[shortcut.example.selectedIndex] } //--> </script> </form> </center> There will be only bombobox in the form, input field must be hidden, but i didnt do it If the user select AAA from combobox, then input field will be visible with aaa text If the user select BBB from combobox, then input field will be visible with bbb text If the user select BBB from combobox, then input field will be visible with ccc text ------------------------------------------------------------------------------ I used disabled but I dont want that <input disabled name="text" type="text" id="text" size="28"/> I need visible/hidden inputField Pls help me...
  21. unfortunately, everything is same... I dont know how many combinations I wrote.... Maybe coding must be different, I didnt understand anything...
  22. <form> <select name="contact"> <option value="1">1</option> <option value="2">2</option> <option value="3">4</option> <option value="4">4</option> </select> <?php if($_GET[contact]=="1"){?> <td>Code</td> <td><input name="add list" type="text" id="add list" value="<?php echo $_GET['add list'];?>" size="28"/></td> <?php } ?> <!-- ****************************************** --> <?php if($_GET[contact]=="2"){?> <td>Modeeee</td> <td><input name="add list asd" type="text" id="add list asd" value="<?php echo $_GET['add list asd'];?>" size="28"/></td> <?php } ?> ..... .... And <?php if($_GET[contact]=="1"){?> I used this code, nothing is changed... Who knows the solution way....:S
  23. thnx for urgent reply....but I test it, nothing is changed. Still same problem..... <form> <select name="contact"> <option value="1">1</option> <option value="2">2</option> <option value="3">4</option> <option value="4">4</option> </select> <?php if(isset($_GET['1'])){?> <td>Code</td> <td><input name="add list" type="text" id="add list" value="<?php echo $_GET['add list'];?>" size="28"/></td> <?php } ?> <!-- ****************************************** --> <?php if(isset($_GET['2'])){?> <td>Modeeee</td> <td><input name="add list asd" type="text" id="add list asd" value="<?php echo $_GET['add list asd'];?>" size="28"/></td> <?php } ?> ..... .... .... .... When the user select something from the combobox, Form otomaticly will add extra field or will change the field... I need that...but How :S
×
×
  • 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.