Jump to content

thara

Members
  • Posts

    604
  • Joined

Everything posted by thara

  1. hello... everyone.. I have some small problem. It is when Im fetch data from my database and print those in different location. I have a database to store images and it contain many type of images. Eg. gallery image, comments image, ad image and so on. So now I need to get only images which type is 'ad'. Note: A single user can store only 2 images as ad images. That mean there are two ad images to a particular user. It ok for me. I did it like this. $q = "SELECT image_name FROM images WHERE image_type = 'ad' AND user = $id"; $r = mysqli_query( $dbc, $q ); while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC)) { $imageName = $row['image_name']; $imageName; // two images contain in this variable. } My problem is, can anybody say, is there a way to print those 2 images in different location (in different two DIV ) and out of while loop. Eg: <div class="add1"> image1 </div> <div class="add2"> image2 </div> any comments are highly appreciated. thank you.
  2. everyone.. I need to rewrite this URL like this can anybody help me to do this using Apache’s mod_rewrite feature. any comments are greatly appreciated. Thank you.
  3. yes... I need to convert my dynamically generated URL to friendly html ULR actually it is something like this..... Eg: profile/teachers/index.php?teaId=21 to profile/teachers/vivek obroi.html Can I convert my php URL like that??? If its not possible.. is there any solution??
  4. I have created a web web site to display some teacher's profile. Every profile page generate with more dynamic information from database. In my home page I have listed every teachers' profile from database with a link to his complete profile. Eg. index.php?teacherId=21. Now I need to convert from my dynamic pages to basic static HTML pages to get some benefits for my website. Number one is get search engine higher rank to my profile pages. further I need to rename html page with teacher's name. As well as my website has a searching option. It help for users to search teacher profile according to their subjects, grades, town, city, etc. So Can I know, it is possible to create such a searching system to my web site after I made my php page to basic HTML pages... any ideas are greatly appreciated. Thank you very much..
  5. show us your code... you can upload file to dynamic location, if you want to create a folder on your server... use mkdir() function... It will create your dynamic location on the server...
  6. you can use this kind of code to validate your email address. if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $e = mysqli_real_escape_string ($dbc, $_POST['email']); } else { $errors[] = 'Please enter a valid email address!'; } use something like this to send email if validation ok... handle your register form.. if (isset ( $_POST['submitted']) ) { // if your form submit true // u can validate your input data here... like email, password..... // if validation ok.. try something like this if ( empy( $errors )) { //here u can send your email.... } } Here I used errors array to store error messages from validation process.. then I checked that errors array empty or not to send email.. It is empty mean, your validation process ok... if it is not empty there is a problem in validation process..
  7. Do u need to send an email with an account activation link?
  8. thanks for response.. I tried like that... <?php require_once ('../../includes/config.inc.php'); require_once( MYSQL1 ); $q = "SELECT category_name FROM category INNER JOIN institute_category_subject ON institute_category_subject.category_id = category.category_id WHERE institute_category_subject.institute_id = $instituteId"; while ( $row = @mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ) { if ( $row['category_name'] != $previous_category_name ) { echo '<h5>' . $row['category_name'] . '</h5>'; } $previous_category_name = $row['category_name']; } ?> then I got this error message....
  9. use like this $n = 200/100 // ur value divide by 100 $n = number_format ($n, 2); // 2.00
  10. Hello... I am some confuse with this matter. I want to print a order list with a title in php. those come from my database. Title is my category name and order list should be my subjects. I used 'institute_category_subject' table and i contain all institutes, categories and their subjects. something like this... I now need to create my list with these values. It is something like this.. category_name1 sub1 sub2 sub3 category_name2 sub1 sub2 sub3 and so on.... My problem is category id with same value going on many rows in the table and when i retrieve that id and when try to print, same category name printing repeatedly. I need to print my category name at only one time as my title and then need to print their subjects as a order list. any comments are highly appreciated. thank you.. thara is online now Report Post Edit/Delete Message
  11. hi... regoch.. how can we use join()... can you post your code to see us.. thank you..
  12. I used it to my experiments only.. I change my html structure and change css style as well. Then I could to get my expecting result. .. now I used a single query which you have coded one for my.. Its working very well. thanks in advance for your cooperation....
  13. I used again my earlier code for my experiments and use some echo statements in inner while loop to check weather every my subjects come or not into my second while loop.. There I can see every subject relevant to categories has come into the while loop.. problem is when Im going to print those subjects in a two columns table using checkbox input tag... still its print a one subject row only... This is that experimented code... <?php require_once ('../../includes/config.inc.php'); require_once( MYSQL1 ); $outQuery = "SELECT institute_category.category_id, category_name FROM institute_category INNER JOIN category ON institute_category.category_id = category.category_id WHERE institute_category.institute_id = $instituteId"; $outResult = mysqli_query( $dbc, $outQuery); while ( $outRow = mysqli_fetch_array ( $outResult, MYSQLI_ASSOC) ) { $category = $outRow['category_name']; echo '<fieldset>'; echo '<legend><span>Category : <em style="color: red;">' . $category . '</em></span></legend>'; $innerQuery = "SELECT subject.subjects, subject.subject_id FROM subject INNER JOIN category_subject ON category_subject.subject_id= subject.subject_id WHERE category_subject.category_id = {$outRow['category_id']}"; $innerResult = mysqli_query( $dbc, $innerQuery); $c = $i = 0; echo '<table class="form_table" ><tr>'; while ( $innerRow = mysqli_fetch_array( $innerResult, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } //echo $innerRow['subjects']; // here I can get all subject that relevant to one category echo '<td width="50%"><input type="checkbox" name="subject[]" value="" /> ' . $innerRow['subjects'] . '</td>' . "\n"; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; echo '</fieldset>'; } ?> This code and Psycho provide code are working in similar way.. there is nothing difference.
  14. this attachment is my from my form. I have attached it for your better understanding
  15. I checked query with mysql client and I could get my expecting result... this is that result mysql> SELECT c.category_id, c.category_name, s.subject_id, s.subjects -> FROM category AS c -> INNER JOIN category_subject AS cs USING(category_id) -> INNER JOIN subject AS s USING(subject_id) -> INNER JOIN institute_category AS ic USING (category_id) -> WHERE ic.institute_id = 37 -> ORDER BY c.category_name, s.subjects; +-------------+----------------------------+------------+------------------------+ | category_id | category_name | subject_id | subjects | +-------------+----------------------------+------------+------------------------+ | 6 | grade 12 - 13 (A/L) | 7 | Catholicism | | 3 | grade 5 (scholarship exam) | 1 | Agro & Food Technology | | 3 | grade 5 (scholarship exam) | 2 | Art | | 3 | grade 5 (scholarship exam) | 3 | Art & Craft | | 3 | grade 5 (scholarship exam) | 4 | Bialogy | | 4 | grade 6 - 10 | 2 | Art | | 4 | grade 6 - 10 | 3 | Art & Craft | | 4 | grade 6 - 10 | 4 | Bialogy | | 4 | grade 6 - 10 | 5 | Buddhism | +-------------+----------------------------+------------+------------------------+ 9 rows in set (0.00 sec) query is ok.. but I think php has a error.. It only display one subject row under category name and if there is a one subject under category it is not display.... any comments are greatly appreciated.. thank you..
  16. I tried with your code.. but then I get this error message... then I change this like this Then I can get one subject row as an output... the result is same for my earlier script...
  17. thanks for reply... I change those variable names... but still result is one row output.. this is my new code.. <?php require_once ('../../includes/config.inc.php'); require_once( MYSQL1 ); $outQuery = "SELECT institute_category.category_id, category_name FROM institute_category INNER JOIN category ON institute_category.category_id = category.category_id WHERE institute_category.institute_id = $instituteId"; $outResult = mysqli_query( $dbc, $outQuery); while ( $outRow = mysqli_fetch_array ( $outResult, MYSQLI_ASSOC) ) { $categoryId = $outRow['category_id']; $category = $outRow['category_name']; echo '<fieldset class="alt"> <legend><span>Category : <em style="color: red;">' . $category . '</em></span></legend>'; $innerQuery = "SELECT category_subject.category_id, category_subject.subject_id, subjects FROM category_subject INNER JOIN category ON category_subject.category_id = category.category_id INNER JOIN subject ON category_subject.subject_id = subject.subject_id WHERE category_subject.category_id = $categoryId"; $innerResult = mysqli_query( $dbc, $innerQuery); $c = $i = 0; echo '<table class="form_table" ><tr>'; while($innerRow = mysqli_fetch_array( $innerResult, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } echo '<td width="50%"><input type="checkbox" name="subject[]" value="' . $innerRow['category_id'] . ":" . $category . ":" . $innerRow['subject_id'] . ":". $innerRow['subjects'] . '" /> ' . $innerRow['subjects'] . '</td>' . "\n"; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; } echo '</fieldset>'; ?>
  18. This is a code pinch from a webpage of my project. Here I want to display user selected categories and then want to display its subjects that belong to category. There, users could have more than 1 category and It no problem I can print all those category in my first while loop... but problem is when Im try to print subjects it has only one row as a result.. there are more subjects in each category. can anybody tell me what has happens? this is my code.... Note: both queries are working properly.. I tried those user mysql client program. <?php require_once ('../../includes/config.inc.php'); require_once( MYSQL1 ); $q = "SELECT institute_category.category_id, category_name FROM institute_category INNER JOIN category ON institute_category.category_id = category.category_id WHERE institute_category.institute_id = $instituteId"; $r = mysqli_query( $dbc, $q); while ( $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC) ) { $categoryId = $row['category_id']; $category = $row['category_name']; echo '<fieldset class="alt"> <legend><span>Category : <em style="color: red;">' . $category . '</em></span></legend>'; $qy = "SELECT category_subject.category_id, category_subject.subject_id, subjects FROM category_subject INNER JOIN category ON category_subject.category_id = category.category_id INNER JOIN subject ON category_subject.subject_id = subject.subject_id WHERE category_subject.category_id = $categoryId"; $result = mysqli_query( $dbc, $qy); $c = $i = 0; echo '<table class="form_table" ><tr>'; while($row = mysqli_fetch_array( $result, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } echo '<td width="50%"><input type="checkbox" name="subject[]" value="' . $row['category_id'] . ":" . $category . ":" . $row['subject_id'] . ":". $row['subjects'] . '" /> ' . $row['subjects'] . '</td>' . "\n"; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; } echo '</fieldset>'; ?> any comments are greatly appreciated.. thank you
  19. I want to display like this "institute name" - "city name" you have add you profile under "option1, option2, option3, and so forth" and teaching "medium1, medium2, etc" medium classes. "registration date" I need to display every registered institute on my home page like that....... thans you..
  20. thanks for response.. Actually I have any Idea about join query. I just use right join for my experiments... can u explain how its work... any comments are greatly appreciated. Thank you
  21. I have 6 tables and need to retrieve some data at once from those tables. can any body tell me, can I select my values from one query. These values I needed. These are from my tables CREATE TABLE institutes ( institute_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT, login_id INT(4) UNSIGNED NOT NULL, address_id INT(4) NOT NULL, contact_id INT(4) NOT NULL, institute_code INT(4) NOT NULL, institute_name VARCHAR(80) NOT NULL, institute_details VARCHAR(80) NOT NULL, ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE address ( address_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT, address_one VARCHAR(40) NOT NULL, address_two VARCHAR(40) DEFAULT NULL, city_id INT(4) UNSIGNED NOT NULL, PRIMARY KEY (address_id), ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE city( city_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT, city_name VARCHAR(30) NOT NULL, state_id INT(2) UNSIGNED NOT NULL, PRIMARY KEY (city_id), ) ENGINE=MyISAM; CREATE TABLE medium( medium_id INT(2) UNSIGNED NOT NULL AUTO_INCREMENT, medium_name VARCHAR(30) NOT NULL, PRIMARY KEY (medium_id), ) ENGINE=MyISAM; CREATE TABLE options( option_id INT(2) UNSIGNED NOT NULL AUTO_INCREMENT, option_name VARCHAR(60) NOT NULL, PRIMARY KEY (option_id), ) ENGINE=MyISAM; CREATE TABLE institute_medium( im_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT, medium_id INT(2) UNSIGNED NOT NULL, institute_id INT(4) UNSIGNED NOT NULL, PRIMARY KEY (im_id) ) ENGINE=MyISAM; CREATE TABLE institute_option( io_id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT, option_id INT(2) UNSIGNED NOT NULL, institute_id INT(4) UNSIGNED NOT NULL, PRIMARY KEY (io_id) ) ENGINE=MyISAM; those are my tables I tried like this but Im confuse when Im try to get options and mediums.. there are always more than one option and medium in instutite_medium to one institute... $q = "SELECT institutes.institute_id, institute_name, city_name, DATE_FORMAT(registration_date, '%M %e, %Y') AS date, GROUP_CONCAT( medium_name SEPARATOR ', ') AS mediums FROM institutes INNER JOIN address ON institutes.address_id = address.address_id INNER JOIN city ON address.city_id = city.city_id inner join institute_medium on institute_medium.medium_id = medium.medium_id right join institutes on institutes.institute_id = institute_medium.institute_id ORDER BY registration_date DESC"; but I cant get values... any comments are greatly appreciated. thank you...
  22. thanks again for your kindness help...and wish u all the best.. Tharanga... From Sri Lanka
  23. wow..... My problem have solved...... now I can get cityid to my post array when i am submitting the form... Thank you very much my dear.... you are a nice person!!!!! I respect you... now I feel that took away a big part of my head.... Thank you again your cooperation.
  24. ok.. wait I will check again.. just I found this code from your post $districtId = (int) $_GET['district'];
×
×
  • 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.