Jump to content

coder1

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

coder1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. R0bb0b, thanks for your help. of course it works, i just missed a semi colon at the end of my array. Many many thanks for you help.
  2. Here's my array. $month = array("January"=>1,"February"=>2,"March"=>3,"April"=>4,"May"=>5"June"=>6,"July"=>7,"August"=>8,"September"=>9,"October"=>10,"November"=>11,"December"=>12 ) here the dropdownlist. I did what u posted. <select name="completemonth" id="completemonth" > <option value="0" SELECTED>Month</option> <?php foreach($month as $key=>$value){ ?> <option <?php echo isset($_POST['completemonth']) && $_POST['completemonth'] == $key?'selected="selected" ':""; ?>value="<?php echo $key; ?>"><?php echo $value[0]; ?></option> <?php }?> </select> I m getting a blank page.
  3. hey thanks for the reply again, I wanted the string month ie 'March' in the text display of the dropdownlist, in the the value, I want 03.
  4. I don't know, I found an example on the web, how should they be? Thanks.
  5. I have 2 dimensional array: $month = array(01=>array('January'),02=>array('February'),03=>array('March'),04=>array('April'),05=>array('May'),06=>array('June'),07=>array('July'),08=>array('August'),09=>array('September'),10=>array('October'),11=>array('November'),12=>array('December')); 1)I want to loop throught the array and populate a dropdownlist in a html form with the above array. I want the string version of the month to be a diplay text, and number to be in the value. like this <select> <option value="01">January</option> </select> 2)when the form is submitted, I want to echo out the selected value in the dropdownlist as selected. any help would be much apperciated. thanks.
  6. I have a form search form that can pass up to 14 parameters (all dropdown list and 2 groups of radio buttons) the user can select combination. 1) Whats the best away to build a query string from the form to pass to mysql query as currently what am doing is for each. Am not sure if that is the best way of doing it? if ($_POST["location"]!="") { $searchstring=$searchstring.$_POST["location"]; } if ($_POST["propertytype"]!="") { $searchstring=$searchstring.' and `type` = \''.$_POST["propertytype"].'\''; } The query can return large resultset so I implemented a simple paging. 2) how do go about using the above $_post method to build a query string to pass to a url. thanks in advance.
  7. I said in my post, i m just send example of my form.. its is actually like this: search form is this. <form name="drop_list" id="drop_list" action="<?php echo htmlentities($_SERVER["PHP_SELF"]);?>" method="post" onSubmit="return OnSubmitForm();"> <fieldset> <legend>search form</legend> <TABLE> <TR> <TD> </TD> <TD><INPUT TYPE="radio" name="transtype" value ="sale" <?php if($ttype != 'rent') echo 'checked="checked"';?> onClick='setSaleSelection();'> Sale <INPUT TYPE="radio" name="transtype" value ="rent" <?php if($ttype=='rent') echo 'checked="checked"';?> onClick='setRentDefault();'> Rent</TD> </TR> <TR> <TD>Location:</TD> <TD> <SELECT name="location" alt="Location" title="Location"> <option value="0" SELECTED>Location</option> <option value="" <?php if (!(strcmp("", $_POST["location"]))) {echo "selected=\"selected\"";} ?>>Select Location</option> <?php do { ?> <option value="<?php echo $row_Recordset1['location']?>"<?php if (!(strcmp($row_Recordset1['location'], $_POST["location"]))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['location']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </SELECT></TD> </TR> <TR> <TD>Bedrooms:</TD> <TD> <select name="bedrooms" style="width:150px;"alt="Bedrooms" title="Bedrooms"> <option value="0" SELECTED>Bedrooms</option> <?php for($x = 0; $x < count($bedroomarray); $x++){ // write "selected" if the value matches the one posted if($bedroomarray[$x] == $_POST['bedrooms']){ $selected = 'selected'; }else{ $selected = ''; } // print the option echo '<option value="'.$bedroomarray[$x].'"'.$selected.'>'.$bedroomarray[$x].'</option>'; } ?> </SELECT> </TD> </TR> <TR> <TD>Price from:</TD> <TD> <select name="pricefrom" alt="Price from" title="Price from"> <option value="">Price from</option> </select> </TD> </TR> <TR> <TD>Price to:</TD> <TD> <select name="priceto" alt="Price to" title="Price to"> <option value="">Price to</option> </select> </TD> </TR> <TR> <TD>Property Type:</TD> <TD> <SELECT name="propertytype" alt="Property type" title="Property type"> <option value="" <?php if (!(strcmp("", $_POST["propertytype"]))) {echo "selected=\"selected\"";} ?>>Choose...</option> <?php do { ?> <option value="<?php echo $row_Recordset2['propertytype']?>"<?php if (!(strcmp($row_Recordset2['propertytype'], $_POST["propertytype"]))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset2['propertytype']?></option> <?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); $rows = mysql_num_rows($Recordset2); if($rows > 0) { mysql_data_seek($Recordset2, 0); $row_Recordset2 = mysql_fetch_assoc($Recordset2); } ?> </SELECT> </TD> </TR> <TR> <TD>Country:</TD> <TD> <SELECT NAME="country" alt="Country" title="Country"> <option value="0">Dubai</option> <?php for($x = 0; $x < count($countryarray); $x++){ // write "selected" if the value matches the one posted if($countryarray[$x] == $_POST['country']){ $selected = 'selected'; }else{ $selected = ''; } // print the option echo '<option value="'.$countryarray[$x].'"'.$selected.'>'.$countryarray[$x].'</option>'; } ?> </SELECT> </TD> </TR> <TR> <TD>Off plan:</TD> <TD><input <?php if (!(strcmp($_POST["offplan"],"-1"))) {echo "checked=\"checked\"";} ?> name="offplan" type="radio" value="-1"></TD> </TR> <TR> <TD>Completed:</TD> <TD><input <?php if (!(strcmp($_POST["offplan"],"0"))) {echo "checked=\"checked\"";} ?> name="offplan" type="radio" value="0"></TD> </TR> <TR> <TD>Added to site:</TD> <TD> <select name="addedtosite" alt="Added to site" title="Added to site"> <option value="9999" <?php if (!(strcmp(9999, $_POST["addedtosite"]))) {echo "selected=\"selected\"";} ?>>Anytime</option> <option value="1" <?php if (!(strcmp(1, $_POST["addedtosite"]))) {echo "selected=\"selected\"";} ?>>Last 24 Hours</option> <option value="3" <?php if (!(strcmp(3, $_POST["addedtosite"]))) {echo "selected=\"selected\"";} ?>>Last 3 days</option> <option value="7" <?php if (!(strcmp(7, $_POST["addedtosite"]))) {echo "selected=\"selected\"";} ?>>Last 7 days</option> <option value="14" <?php if (!(strcmp(14, $_POST["addedtosite"]))) {echo "selected=\"selected\"";} ?>>Last 14 days</option> </select> </TD> </TR> <TR> <TD>Sort by:</TD> <TD> <select name="sortby" alt="Sort by" title="Sort by"> <option value="desc" <?php if (!(strcmp("desc", $_POST["sortby"]))) {echo "selected=\"selected\"";} ?>>Highest Price</option> <option value="asc" <?php if (!(strcmp("asc", $_POST["sortby"]))) {echo "selected=\"selected\"";} ?>>Lowest Price</option> </select> </TD> </TR> <TR> <TD></TD> <TD> <input type="submit" id="submit" name="submit" value="Search properties"> </TD> </TR> </TABLE> </fieldset> </form> the above is my actual form on both pages. when I submit the form i get no data found message, this makes think that the problem lies with the paging stuff <?php $query_Recordset3 = $searchstring; $Recordset3 = mysql_query($query_Recordset3, $mydb) or die(mysql_error()); //$row_Recordset3 = mysql_fetch_assoc($Recordset3); $nume = mysql_num_rows($Recordset3); $page_name="result.php"; // If you use this code with a different page ( or file ) name then change this if(!isset($start)) { // This variable is set to zero for the first page $start = 0; } $eu = ($start - 0); $limit = 10; // No of records to be shown per page. $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; $query= $searchstring." limit $eu, $limit "; $result=mysql_query($query); echo mysql_error(); ?> <?php if($nume == '0'){ echo '<b>No data found</b>'; }else{ //display records here } ?> when i submit the form from result.php i get the above message. If i submit the form from search.php then it displays records.
  8. burn1337, thank you for looking into my post, firstly I wanted get it working as is, I will be using stored procedure, hence I did'nt bother with saving myself from sql injection (this just me playing around, see if i can get it working first), secondly i only sent segment of my code that am having problem with i forgot to add the php tags. Most importantly, perhaps I have'nt explained myself properly. 1) I have 2 search form that are identical - 1 page called search.php which is a basic html form. which when submitted goes to a page called result.php (which displays result of query based on the search critera) in result.php (directed from search.php) everything is fine, it (result.php) executes the query based on the query string and results are displayed. I looked at the results, now I want to change my serach citeria, so instead of hitting the back button, I put the same form (as the one in serach.php) inside the result.php, I hit submit, I get nothing. I wanted know to why? what am I doing wrong? I know it possible submit a form to it self and and do what whatever processing. If I don't use the form on the result.php, but instead go back and cahnge my serach citeria on (search.php) again every displays perfectly on result.php. Anyways I m not sure if I have explained myself properly. I would really apperciate if anyone help. I saw an expamle of this rightmove website, and I wanted implement it something similer. Many thanks.
  9. Thanks for that advise, but it did'nt work. here's example of my form. search.php (the first one.) <BODY> <FORM METHOD="POST" ACTION="result.php"> <TABLE> <TR> <TD>Label1</TD> <TD> <SELECT NAME="Label1"> <OPTION VALUE="Label1">Label1</OPTION> </SELECT> </TD> </TR> <TR> <TD>Label2</TD> <TD> <SELECT NAME="Label2"> <OPTION VALUE="Label2">Label2</label> </SELECT> </TD> </TR> <TR> <TD>Label3</TD> <TD> <SELECT NAME="Label3"> <OPTION VALUE="Label3">Label3<OPTION VALUE=""> </SELECT> </TD> </TR> <TR> <TD>label4</TD> <TD> <SELECT NAME=""> <OPTION VALUE="label4">label4</option> </SELECT> </TD> </TR> <TR> <TD>radio</TD> <TD><INPUT TYPE="radio" NAME="radio" id="radio"></TD> </TR> <TR> <TD>radio1</TD> <TD><INPUT TYPE="radio" NAME="radio1" id="radio1"></TD> </TR> </TABLE> <INPUT TYPE="submit"> </FORM> in the result.php I have following. <div id="header">header</div> <div id="leftcol"> $searchstring='select * from testtable where currency=\''.$lclcurrency.'\' and `location` like \'%%'; if ($_POST["lable1"]!=""){ $searchstring=$searchstring.$_POST["lable1"]; } if ($_POST["lable2"]!=""){ $searchstring=$searchstring.$_POST["lable2"]; } if ($_POST["lable3"]!=""){ $searchstring=$searchstring.$_POST["lable3"]; } am doing the above for the form fields. //executing the query. $query_Recordset3 = $searchstring; $Recordset3 = mysql_query($query_Recordset3, $mydb) or die(mysql_error()); $nume = mysql_num_rows($Recordset3); the above does work, as first time i come from search.php, it bring resultset. //Paging stuff.(basic, display 10 records per page) $page_name="result.php"; // If you use this code with a different page ( or file ) name then change this if(!isset($start)) { // This variable is set to zero for the first page $start = 0; } $eu = ($start - 0); $limit = 10; // No of records to be shown per page. $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; $query= $searchstring." limit $eu, $limit "; $result=mysql_query($query); echo mysql_error(); if($nume == '0'){ echo '<b>No data found</b>'; }else{ display result set. } //below is the paging navigation. if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging /////////////// Start the bottom links with Prev and next link with page numbers ///////////////// echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>"; //// if our variable $back is equal to 0 or more then only we will display the link to move back //////// if($back >=0) { print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; } //////////////// Let us display the page links at center. We will not display the current page as a link /////////// echo "</td><td align=center width='30%'>"; $i=0; $l=1; for($i=0;$i < $nume;$i=$i+$limit){ if($i <> $eu){ echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> "; } else { echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red $l=$l+1; } echo "</td><td align='right' width='30%'>"; ///////////// If we are not in the last page then Next link will be displayed. Here we check that ///// if($this1 < $nume) { print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} echo "</td></tr></table>"; }// end of if checking sufficient records are there to display bottom navigational link. </div> <div id="right> <!--the same form as the 1 in search.php--> <FORM METHOD="POST" ACTION="result.php"> <TABLE> <TR> <TD>Label1</TD> <TD> <SELECT NAME="Label1"> <OPTION VALUE="Label1">Label1</OPTION> </SELECT> </TD> </TR> <TR> <TD>Label2</TD> <TD> <SELECT NAME="Label2"> <OPTION VALUE="Label2">Label2</label> </SELECT> </TD> </TR> <TR> <TD>Label3</TD> <TD> <SELECT NAME="Label3"> <OPTION VALUE="Label3">Label3<OPTION VALUE=""> </SELECT> </TD> </TR> <TR> <TD>label4</TD> <TD> <SELECT NAME=""> <OPTION VALUE="label4">label4</option> </SELECT> </TD> </TR> <TR> <TD>radio</TD> <TD><INPUT TYPE="radio" NAME="radio" id="radio"></TD> </TR> <TR> <TD>radio1</TD> <TD><INPUT TYPE="radio" NAME="radio1" id="radio1"></TD> </TR> </TABLE> <INPUT TYPE="submit"> </FORM> </div> So basically on the result.php on the right column i have the samee form, I echo out the stuff selected from the pervious page. if the form is submitted from search.php, it all works well. however if i submit the form on the result.php. I get no data found, even though there is data.
  10. on the searchresult.php I have the following: I build the query string like this from post. and form, its just normal html form, in both forms the input types are named the same. I get any errors as such on the second page when submit, no rows are returned from db. $searchquery ='select agency, address1, address2, address3, pobox, telephone, location, bedrooms, `type`, id, price, userid, shortdescription, photo1, country, sale, id from mytesttable where currency=\''.$lclcurrency.'\' and `location` like \'%%'; $searchquery =$searchquery .' and `type` = \''.$_POST["ptype"].'\'';
  11. I have 2 forms, in 2 different pages. when user first enters the site, they get a search page (search.php), which is a form with various droplist and few radio buttons. when they hit submit, they are directed to searchresult.php, which displays of course the search result (I have page with 3 column layout), the left column, search result is displayed and the right column has the form same as the 1 in search.php page with perivously selected values. when i m in the searchresult.php, i want change something on form (perhaps selcet something different) and hit submit, i don't get any results, even though there are results to be returned. on the searchresult.php am post to variables to build my query string. I have seen one example used on the rightmove website, an trying use same technique. $_POST['test; Please, any help or advise will be much apperciated.
  12. I have 4 four images which I use like radio buttons.Each one has 2 images, one normal and fade, when the user clicks on 1 image, i want to the image to change from fade to normal, whilst the other 3 images are faded. I have written something by looking around the Internet. I have the following code. It however doesn't work on firefox or ie7. Please could you give me some help with this. <html> <head> function doit(imgObj){ var cell = imgObj.value; // save value of clicked image //var cell1 = imgObj.id; //alert(cell1); if(cell =='AED'){ document.images['AED1'].src = "images/UAE.png"; currency = 'AED'; } if(cell =='GBP'){ document.images['GBP1'].src = "images/UK.png"; currency = 'GBP'; } if(cell =='EUR'){ document.images['EUR1'].src = "images/EU.png"; currency = 'EUR'; } if(cell =='USA'){ document.images['USA1'].src = "images/USA.png"; currency = 'USA'; } if(currency !='AED'){ document.images['AED1'].src = "images/UAEfade.gif"; } if(currency !='GBP'){ document.images['GBP1'].src = "images/UKfade.gif"; } if(currency !='EUR'){ document.images['EUR1'].src = "images/EUfade.gif"; } if(currency !='USA'){ document.images['USA1'].src = "images/USfade.gif"; } } </head> <body> <img src="images/UAE.png" name='img1' value="AED" id="AED1" onClick='doit(this)'> <img src="images/UKfade.gif" name='img1' value="GBP" id="GBP1" onClick='doit(this)'> <img src="images/EUfade.gif" name='img1' value="EUR" id="EUR1" onClick='doit(this)'> <img src="images/USfade.gif" name='img1' value="USA" id="USA1" onClick='doit(this)'> </body> </html> Any help with be much appreciated.
×
×
  • 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.