Jump to content

jonnewbie12

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Everything posted by jonnewbie12

  1. DOHHHHH whole day mucking about for an underscore. THANK YOU VERY VERY MUCH
  2. Sure. Thanks. Problem I have is that I am trying to get two if statements doing two different things. For example, the 1st row in the 'moisture' column returns the value of 1 so I want it to say "moisture resistant". BUT I also query another column "Fire" in the same row. This returns a value of 0 so I want it to do nothing. If it had a value of 1 then it would say "flame retardant". I have copied the code so you can see what I am trying to do: <?php require_once('Connections/blindserver.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_blindserver, $blindserver); $query_Recordset1 = "SELECT * FROM materials WHERE G = 'pattern'"; $Recordset1 = mysql_query($query_Recordset1, $blindserver) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link type="text/css" rel="stylesheet" href="../magiczoomplus.css"/> <script type="text/javascript" src="../magiczoomplus.js"></script> <title>Untitled Document</title> </head> <body> <p> </p> <a href="<?php echo $row_Recordset1['fabricpicture']; ?>" class="MagicZoomPlus" rel="caption-source:span;caption-position:right" title="<?php echo $row_Recordset1['fabricgroup']; ?> <?php echo $row_Recordset1['E']; ?>"> <img src="<?php echo $row_Recordset1['fabricpicture']; ?>" name="Grey" width="100" height="100" border="0" class="MagicZoomPlus" id="Grey"/> <span><strong><?php echo $row_Recordset1['fabricgroup']; ?> <?php echo $row_Recordset1['E']; ?></strong> </p> <?php echo $row_Recordset1['fabricmaterial']?> </P> Max Width = <?php echo $row_Recordset1['width']?> </p> Max Drop = <?php echo $row_Recordset1['drop']?> </p> <?php if ($rowRecordset1['moisture'] ==1) {echo "moisture resistant";} ?> </p> <?php if ($rowRecordset1['flame'] ==1) {echo "flame retardant";} ?></p> and [a href=example.html]here is a link[/a]</span>. </a> </body> </html> <?php mysql_free_result($Recordset1); ?>
  3. Totally baffled here! I have a Recordset that returns numerous values from a table. The 1st row value in one of the columns called 'moisture' is 1. When I insert an IF command to to perform a task (echo some text) if the value is 1 it just doesn't work. Here is the code. <?php if ($rowRecordset1['moisture'] =="1") {echo "moisture resistant";} ?> I know the value is 1 because if I echo the the recordset as follows the value comes up as 1: <?php echo $row_Recordset1['moisture'];?> I canty for the life of me figure out what I am doing wrong with such a simple code. The Field type in MY PHP admin is set to INT, collation utf8_general_CI, NULL is off and default is none. There are no attributes. ANYONE????? :-[
  4. Sorry as name suggests a newbie! Var dump? Strings the same? Sorry.
  5. Sorry to be a newbie. I am writing some code that is supposed to query a row in my database. If that row returns the value "yes" I want to display a text or image. It is currently being written within a pop up box, hence within the <span> parameters. Problem is it just doesnt work and was hoping someone could tell me why. Have I got too many brackets? Should the values in the PHP admin table be set differently? The bit I am having trouble is the 'IF commands". Although the row 'moisture' has a yes value in the database it does not perform the echo. The code is below:[/b][/b] <a href="<?php echo $row_Recordset1['fabricpicture']; ?>" class="MagicZoomPlus" rel="caption-source:span;caption-position:right" title="<?php echo $row_Recordset1['fabricgroup']; ?> <?php echo $row_Recordset1['E']; ?>"> <img src="<?php echo $row_Recordset1['fabricpicture']; ?>" name="Grey" width="100" height="100" border="0" class="MagicZoomPlus" id="Grey"/> <span><strong><?php echo $row_Recordset1['fabricgroup']; ?> <?php echo $row_Recordset1['E']; ?></strong> </p> <?php echo $row_Recordset1['fabricmaterial']?> </P> Max Width = <?php echo $row_Recordset1['width']?> </p> Max Drop = <?php echo $row_Recordset1['drop']?> </p> <?php if ($rowRecordset1['moisture']=="yes") {echo "moisture resistant";} ?> </p> <?php if ($rowRecordset1['flame'] == "yes") {echo "flame retardant";} ?></span>. </a>
  6. Afraid I could use a little help if you know the code for that? Sorry
  7. I know I am pushing my luck but I dont suppose you know how to get only the last record within that code as I am actually trying to enable the user to enter a value that falls withtin certain ranges using the <= commands? Here is how it looks now. mysql_select_db($database_blindserver, $blindserver); $query_Recordset2 = "SELECT prices.price FROM prices where prices.width <= '".$_POST['width']."' and prices.drop <= '".$_POST['drop']."'"; $Recordset2 = mysql_query($query_Recordset2, $blindserver) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2);mysql_select_db($database_blindserver, $blindserver);
  8. Thank you so much. What can I say 12 hours of mucking about and you solved it in 2 minutes. Thanks very much indeed for the really quick response. You have made my headache go away!
  9. Sorry to be dim. I am sue there is a simple answer to this. I am trying to build a PHP page that returns the value of a column and a row from an SQL database. All the connections and servers are running fine. I am running PHP5.2.16. Put simply I am trying to get the price of material when it is a certain width and drop. The first column shows the width the second shows the drop and the third shows the price. I am using Dreamweaver CS5. I have a simple form on the page that has two fields, one for width and one for drop. When the user enters the value in the form I want it to query the database and retrieve the price where the form fields match BOTH database columns for width and drop. I can do it for one column but not for both. I have tried all different permutations of the WHERE and AND commands but cant seem to get it to work. This is my latest attempt. I am sure there is an easier way. Can someone PLEASE help? The Browser keeps saying: "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 'drop =NULL' at line 1" Here is the code for the whole page which is very short: <?php require_once('Connections/blindserver.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_blindserver, $blindserver); $query_Recordset1 = sprintf("SELECT price FROM prices WHERE width = %s AND drop =%s", GetSQLValueString($_REQUEST['width'], "int"), GetSQLValueString($_REQUEST['drop'], "int")); $Recordset1 = mysql_query($query_Recordset1, $blindserver) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> .kj { font-size: 16px; color: #000; } </style> </head> <body> <form id="form1" name="form1" method="post" action=""> <p> <label for="width">width</label> <input name="width" type="text" id="width" /> </p> <p> <label for="drop">drop</label> <input name="drop" type="text" id="drop" /> </p> <p> </p> <p> <input type="submit" name="submit" id="submit" value="Submit" /> </p> </form> <p><span class="kj"></span><?php echo $row_Recordset1['price']; ?></p> </body> </html> <?php mysql_free_result($Recordset1); ?>
×
×
  • 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.