Jump to content


Photo

Is it possible?


  • Please log in to reply
3 replies to this topic

#1 Codeman0013

Codeman0013
  • Members
  • PipPip
  • Member
  • 20 posts
  • LocationCentral Illinois USA

Posted 22 September 2006 - 08:31 PM

Hey is it possible to run a query and not allow the others to run until the ones above it have been executed like on page load i only want one thing to load and as the user submits then run the next on and so on here is my code if its possible ot change it i would appreciate any tips..

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_industry = "SELECT industry_id, industry_name FROM tbl_industry ORDER BY industry_name ASC";
$rs_industry = mysql_query($query_rs_industry, $conn_dj) or die(mysql_error());
$row_rs_industry = mysql_fetch_assoc($rs_industry);
$totalRows_rs_industry = mysql_num_rows($rs_industry);

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_productcategory = "SELECT productCat_id, productCat_name, industry_id FROM tbl_productcat WHERE industry_id = '$_GET[industry_id]' ORDER BY productCat_name";
$rs_productcategory = mysql_query($query_rs_productcategory, $conn_dj) or die(mysql_error());
$row_rs_productcategory = mysql_fetch_assoc($rs_productcategory);
$totalRows_rs_productcategory = mysql_num_rows($rs_productcategory);

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_product = "SELECT products_id, products_name, productCat_id FROM tbl_products WHERE productCat_id = '$_GET[productCat_id]' ORDER BY products_name";
$rs_product = mysql_query($query_rs_product, $conn_dj) or die(mysql_error());
$row_rs_product = mysql_fetch_assoc($rs_product);
$totalRows_rs_product = mysql_num_rows($rs_product);

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_outsidena = "SELECT * FROM intl_countries ORDER BY intl_countries.name";
$rs_outsidena = mysql_query($query_rs_outsidena, $conn_dj) or die(mysql_error());
$row_rs_outsidena = mysql_fetch_assoc($rs_outsidena);
$totalRows_rs_outsidena = mysql_num_rows($rs_outsidena);

Remember to always look for those dang ; they can be a killer!

#2 Seraph

Seraph
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 22 September 2006 - 09:33 PM

Ajax seems like your only hope. Though that is too advanced for you if you can't figure it out your self. And I don't know ajax too well. sorry

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 September 2006 - 02:36 AM

Well, depending on how large these tables are, you might be able to preload this and do it client-side...
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 Daen

Daen
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 27 September 2006 - 12:01 AM

If you don't mind having the page reload every time the user submits something or picks a new value, then you can do it with php and a little bit of javascript.  You just need to have a few hidden form fields on your page, and when the user submits one button, the javascript sets the form field value to some flag key value, then submits the form with page.submit().  Your php code looks for the flag value, then runs the query you want, and spits out the result page with the new results of the query.

If you do mind the page reloading, then you'll have to go with AJAX, I think.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users