Jump to content

chimp

Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Posts posted by chimp

  1. Hi,

     

    I have developed a very simple database

     

    Database name:

    ApprovedProducts

     

    Table Name:

    approved

     

    that has a few fields:

     

    ProdID (number)

    Description (Text)

    Group (Text)

    MSDS (link)

    TDS (link)

     

    I am trying to develope a webpage for my small run business to ensure i am always up to date with datasheets, I would like to lay the page out similar to on the next link:

     

    http://www.crcind.com/csp/web/DSOverview.csp?lng=3&country=ALL&idx=1020986

     

    My plan is to hold the database in a read only folder on my network and have the php form on my intranet page.

     

    The idea is that if someone want to browse for a product they can look down the list and click on the msds/tds link to open the pdf file attached.

     

    I have zero idea how to start this off could someone please help me.

  2. ok i stripped the code right down thought it would be easier if people could see the whole picture

    I have spent absolutely weeks playing around with this but cant get it to work no matter what.

    I am trying to change a couple of fields in my php page from a text box to a drop down box.

    Fields i am trying to change on my form are:

    Php form name ----- Mysql store name

    Beds              -----  Bed
    Bathroom        -----  Bath

    I store the values of the drop down box in my mysql table

    Table structure is as follows:

    [code]
    CREATE TABLE `categories` (
      `id` int(11) NOT NULL auto_increment,
      `title` varchar(50) default NULL,
      `description` text,
      `image` varchar(50) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;

    --
    -- Dumping data for table `categories`
    --

    INSERT INTO `categories` VALUES (14, 'Yes', '-', '');
    INSERT INTO `categories` VALUES (15, 'No', '-', '');
    [/code]

    so in this case you can see I am just trying to use a yes or no value.

    I want to store this in my table as a number

    I already use the results from the drop down options in another field but cant seem to get this duplicated for my other fields.

    my database store structure is as follows

    [code]

      `bed` int(11) default NULL,
      `bath` int(11) default NULL,

    [/code]

    I want my php code to be able to update the database using only yes or no values from my categories field…

    [code=php:0]
      $updateSQL = sprintf("UPDATE items SET `long`=%s, `lat`=%s, cid=%s, title=%s, price=%s, special_price=%s, description=%s, address=%s, city=%s, `state`=%s, zip=%s, bed=".GetSQLValueString($_REQUEST['bed'],"text").", bath=".GetSQLValueString($_REQUEST['bath'],"text").", subdiv=".GetSQLValueString($_REQUEST['subdiv'],"text").", schoold = ".GetSQLValueString($_REQUEST['schoold'],"text").", year = ".GetSQLValueString($_REQUEST['year'],"int").", lot_size = ".GetSQLValueString($_REQUEST['lot_size'],"double").", sqft = ".GetSQLValueString($_REQUEST['sqft'],"double")." WHERE id=".GetSQLValueString($_REQUEST['id'],"int")."",
                          GetSQLValueString($address['long'], "text"),
                          GetSQLValueString($address['lat'], "text"),
                          GetSQLValueString($_POST['cat'], "int"),
                          GetSQLValueString($_POST['title'], "text"),
                          GetSQLValueString($_POST['price'], "double"),
                          GetSQLValueString($_POST['special_price'], "double"),
                          GetSQLValueString($_POST['description'], "text"),
                          GetSQLValueString($_POST['address'], "text"),
                          GetSQLValueString($_POST['city'], "text"),
                          GetSQLValueString($_POST['state'], "text"),
                          GetSQLValueString($_POST['zip'], "text"),
                          GetSQLValueString($_POST['id'], "int")
      );
    [/code]

    and further down my code is this

    [code=php:0]
      <tr>
        <td class="colText">Bed(s)</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="bed" type="text" id="bed" value="<?php echo $row_item['bed']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Bathroom(s)</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="bath" type="text" id="bath" value="<?php echo $row_item['bath']; ?>" size="15"></td>
      </tr>
    [/code]

    i believe this bit is the code that i need to be using to use for the drop down box.

    [code=php:0]
        <td class="colText">Category</td>
        <td bgcolor="#FFFFFF"><select name="cat" id="cat">
          <?php
    do {
    ?>
          <option value="<?php echo $row_cat['id']?>"<?php if (!(strcmp($row_cat['id'], $row_item['cid']))) {echo "SELECTED";} ?>><?php echo $row_cat['title']?></option>
          <?php } while ($row_cat = mysql_fetch_assoc($cat));
      $rows = mysql_num_rows($cat);
      if($rows > 0) {
          mysql_data_seek($cat, 0);
      $row_cat = mysql_fetch_assoc($cat);
      }
    ?>
    [/code]

    Please help this is driving me insane, i have cut out all the rubbish from the code, and only left in the bits that refer to the section i am trying to change.
  3. I have spent absolutely weeks playing around with this but cant get it to work no matter what.

    I am trying to change a couple of fields in my php page from a text box to a drop down box.

    Fields i am trying to change on my form are:

    Php form name ----- Mysql store name

    Beds              -----  Bed
    Bathroom        -----  Bath
    Year              -----  Year
    Local Authority-----  Subdiv
    Local Hospital  -----  Schoold
    Grounds Acres -----  lot_size
    Sqfeet          -----  sqft

    I store the values of the drop down box in my mysql table

    Table structure is as follows:

    [code]
    CREATE TABLE `categories` (
      `id` int(11) NOT NULL auto_increment,
      `title` varchar(50) default NULL,
      `description` text,
      `image` varchar(50) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;

    --
    -- Dumping data for table `categories`
    --

    INSERT INTO `categories` VALUES (14, 'Yes', '-', '');
    INSERT INTO `categories` VALUES (15, 'No', '-', '');
    [/code]

    so in this case you can see I am just trying to use a yes or no value.

    I want to store this in my table as a number

    I already use the results from the drop down options in another field but cant seem to get this duplicated for my other fields.

    my database store structure is as follows

    [code]
    CREATE TABLE `items` (
      `id` int(11) NOT NULL auto_increment,
      `cid` int(11) default NULL,
      `scid` int(11) default NULL,
      `mid` int(11) default NULL,
      `title` varchar(50) default NULL,
      `price` double default NULL,
      `special_price` double default NULL,
      `pdate` datetime default NULL,
      `sold` varchar(4) default NULL,
      `description` text,
      `address` varchar(50) default NULL,
      `city` varchar(45) default NULL,
      `state` varchar(45) default NULL,
      `zip` varchar(50) default NULL,
      `exp` int(11) default NULL,
      `featured` varchar(4) default NULL,
      `active` varchar(5) default NULL,
      `hits` int(11) default NULL,
      `bed` int(11) default NULL,
      `bath` int(11) default NULL,
      `subdiv` int(11) default NULL,
      `schoold` int(11) default NULL,
      `year` int(11) default NULL,
      `lot_size` int(11) default NULL,
      `sqft` int(11) default NULL,
      `lat` varchar(40) default NULL,
      `long` varchar(40) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
    [/code]

    I want my php code to be able to update the database using only yes or no values from my categories field…

    [code=php:0]
    <?php require_once('Connections/myconn.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    //begin debug
    //print $_REQUEST['city'];
    //die();
    //end debug

    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

    //fetch logn and lat for address
    $request_address = $_REQUEST['address'] . ', '.$_REQUEST['city'].' '.$_REQUEST['state'].' '.$_REQUEST['zip'];
    require('admin/xmlparse.ini.php');
    require('admin/llfetch.php');

      $updateSQL = sprintf("UPDATE items SET `long`=%s, `lat`=%s, cid=%s, title=%s, price=%s, special_price=%s, description=%s, address=%s, city=%s, `state`=%s, zip=%s, bed=".GetSQLValueString($_REQUEST['bed'],"text").", bath=".GetSQLValueString($_REQUEST['bath'],"text").", subdiv=".GetSQLValueString($_REQUEST['subdiv'],"text").", schoold = ".GetSQLValueString($_REQUEST['schoold'],"text").", year = ".GetSQLValueString($_REQUEST['year'],"int").", lot_size = ".GetSQLValueString($_REQUEST['lot_size'],"double").", sqft = ".GetSQLValueString($_REQUEST['sqft'],"double")." WHERE id=".GetSQLValueString($_REQUEST['id'],"int")."",
                          GetSQLValueString($address['long'], "text"),
                          GetSQLValueString($address['lat'], "text"),
                          GetSQLValueString($_POST['cat'], "int"),
                          GetSQLValueString($_POST['title'], "text"),
                          GetSQLValueString($_POST['price'], "double"),
                          GetSQLValueString($_POST['special_price'], "double"),
                          GetSQLValueString($_POST['description'], "text"),
                          GetSQLValueString($_POST['address'], "text"),
                          GetSQLValueString($_POST['city'], "text"),
                          GetSQLValueString($_POST['state'], "text"),
                          GetSQLValueString($_POST['zip'], "text"),
                          GetSQLValueString($_POST['id'], "int")
      );
    //echo $updateSQL;
    //die();
      mysql_select_db($database_myconn, $myconn);
      $Result1 = mysql_query($updateSQL, $myconn) or die(mysql_error());

      $updateGoTo = "a_index.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }


    ?>
    <? include('header.php'); ?>
    <?php


    //fetch all categories from database , and load into a assoc array
    mysql_select_db($database_myconn, $myconn);
    $query_cat = "SELECT * FROM categories ORDER BY title ASC";
    $cat = mysql_query($query_cat, $myconn) or die(mysql_error());
    $row_cat = mysql_fetch_assoc($cat);
    $totalRows_cat = mysql_num_rows($cat);

    //fetch member information from  datebase where email matches session varable
    $colname_minfo = "1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_minfo = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_myconn, $myconn);
    $query_minfo = sprintf("SELECT * FROM members WHERE email = '%s'", $colname_minfo);
    $minfo = mysql_query($query_minfo, $myconn) or die(mysql_error());
    $row_minfo = mysql_fetch_assoc($minfo);
    $totalRows_minfo = mysql_num_rows($minfo);

    mysql_select_db($database_myconn, $myconn);
    $query_city = "SELECT * FROM city ORDER BY title ASC";
    $city = mysql_query($query_city, $myconn) or die(mysql_error());
    $row_city = mysql_fetch_assoc($city);
    $totalRows_city = mysql_num_rows($city);

    mysql_select_db($database_myconn, $myconn);
    $query_state = "SELECT * FROM `state` ORDER BY title ASC";
    $state = mysql_query($query_state, $myconn) or die(mysql_error());
    $row_state = mysql_fetch_assoc($state);
    $totalRows_state = mysql_num_rows($state);

    //fetch all active credits from accounting table in database
    $colname_a = $row_minfo['id']; // store member id
    mysql_select_db($database_myconn, $myconn);
    $query_a = sprintf("SELECT * FROM accounting WHERE mid = %s", $colname_a) . " and active = 'Yes'";
    //echo $query_a;
    $a = mysql_query($query_a, $myconn) or die(mysql_error());
    $row_a = mysql_fetch_assoc($a);
    $totalRows_a = mysql_num_rows($a);

    //fetch item from database and place in assoc array
    if (isset($_GET['id'])) {
      $colname_item = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
    }
    mysql_select_db($database_myconn, $myconn);
    $query_item = sprintf("SELECT * FROM items WHERE id = %s", $colname_item) .  " and mid =" . $row_minfo['id'];

    $item = mysql_query($query_item, $myconn) or die(mysql_error());
    $row_item = mysql_fetch_assoc($item);
    $totalRows_item = mysql_num_rows($item);
    ?>
    <link href="mystyle.css" rel="stylesheet" type="text/css">


    <form method="POST" action="<?php echo $editFormAction; ?>" name="form1">
    <table width="500" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF">
      <caption align="left" class="pageTitle">
      <h1>Edit Property Listing</h1>
      </caption>
      <tr>
        <td class="colText">Category</td>
        <td bgcolor="#FFFFFF"><select name="cat" id="cat">
          <?php
    do {
    ?>
          <option value="<?php echo $row_cat['id']?>"<?php if (!(strcmp($row_cat['id'], $row_item['cid']))) {echo "SELECTED";} ?>><?php echo $row_cat['title']?></option>
          <?php } while ($row_cat = mysql_fetch_assoc($cat));
      $rows = mysql_num_rows($cat);
      if($rows > 0) {
          mysql_data_seek($cat, 0);
      $row_cat = mysql_fetch_assoc($cat);
      }
    ?>
        </select></td>
      </tr>
        <tr>
        <td class="colText">Price:</td>
        <td bgcolor="#FFFFFF"><input name="price" type="text" id="price" value="<?php echo $row_item['price']; ?>" size="25"></td>
      </tr>
      <tr>
        <td class="colText">Address</td>
        <td bgcolor="#FFFFFF"><input name="address" type="text" id="address" value="<?php echo $row_item['address']; ?>" size="40"></td>
      </tr>
      <tr>
        <td class="colText">City/Town</td>
        <td bgcolor="#FFFFFF">      <span class="rowText">
    <? if(mysql_num_rows($city) <=0){?>
        <input name="city" type="text" id="city" value="<?php echo $row_item['city'] ?>">
    <? }else { ?>
        <select name="city" id="city">
          <?php
    do {
    ?>
          <option value="<?php echo $row_city['title']?>"<?php if ($row_city['title'] == $row_item['city']) {echo "SELECTED";} ?>><?php echo $row_city['title']?></option>
          <?php
    } while ($row_city = mysql_fetch_assoc($city));
      $rows = mysql_num_rows($city);
      if($rows > 0) {
          mysql_data_seek($city, 0);
      $row_city = mysql_fetch_assoc($city);
      }
    ?>
        </select>
    <? } ?>
        </span></td>
      </tr>
      <tr>
        <td class="colText">County</td>
        <td bgcolor="#FFFFFF"><span class="rowText">      <select name="state" id="state" style="width: 109px;">
          <?php
    do {
    ?>
          <option value="<?php echo $row_state['stitle']?>"<?php if (!(strcmp($row_state['stitle'], $row_item['state']))) {echo "SELECTED";} ?>><?php echo $row_state['title']?></option>
              <?php
    } while ($row_state = mysql_fetch_assoc($state));
      $rows = mysql_num_rows($state);
      if($rows > 0) {
          mysql_data_seek($state, 0);
      $row_state = mysql_fetch_assoc($state);
      }
    ?>
          </select>
    </span></td>
      </tr>
      <tr>
        <td class="colText">Postcode</td>
        <td bgcolor="#FFFFFF"><input name="zip" type="text" id="zip" value="<?php echo $row_item['zip']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Bed(s)</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="bed" type="text" id="bed" value="<?php echo $row_item['bed']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Bathroom(s)</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="bath" type="text" id="bath" value="<?php echo $row_item['bath']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Year</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="year" type="text" id="year" value="<?php echo $row_item['year']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Local Authority</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="subdiv" type="text" id="subdiv" value="<?php echo $row_item['subdiv']; ?>" size="40" maxlength="60"></td>
      </tr>
      <tr>
        <td class="colText">Local Hospital</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="schoold" type="text" id="schoold" value="<?php echo $row_item['schoold']; ?>" size="40" maxlength="60"></td>
      </tr>
      <tr>
        <td class="colText">Grounds (Acres)</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="lot_size" type="text" id="lot_size" value="<?php echo $row_item['lot_size']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Square Feet </td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="sqft" type="text" id="sqft" value="<?php echo $row_item['sqft']; ?>" size="15"></td>
      </tr>
      <tr>
        <td colspan="2" class="colText"><p>Description</p>    </td>
      </tr>
      <tr>
        <td colspan="2" class="colText"><div align="center">
          <textarea name="description" cols="70" rows="15" id="description"><?php echo $row_item['description']; ?></textarea>
        </div></td>
      </tr>
      <tr>
        <td colspan="2"><div align="right">
            <input name="id" type="hidden" id="id" value="<?php echo $row_item['id']; ?>">
            <input type="submit" name="Submit4" value="Submit">
            <input type="reset" name="Submit22" value="Reset">
            <input name="Submit32" type="button" onClick="window.location='a_index.php'" value="Cancel">
        </div></td>
      </tr>
    </table>
    <input type="hidden" name="MM_update" value="form1">
    </form>
    <? include('footer.php'); ?>
    <?php
    mysql_free_result($city);

    mysql_free_result($state);

    mysql_free_result($item);
    ?>
    [/code]

    Please help this is driving me insane
  4. hi i am lost!!! really lost, i have some php script that i am trying to slightly change by adding a new text entry field.

    I have made the change and get the following error when i click my submit button.

    [code]
    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 '&bname='450', price=NULL, special_price='Simply immaculate detac
    [/code]


    my table structure is as follows:

    [code]
      `b&bname` varchar(50) default NULL,
      `id` int(11) NOT NULL auto_increment,
      `cid` int(11) default NULL,
      `scid` int(11) default NULL,
      `mid` int(11) default NULL,
      `title` varchar(50) default NULL,
      `price` double default NULL,
      `special_price` double default NULL,
      `pdate` datetime default NULL,
      `sold` varchar(4) default NULL,
      `description` text,
      `address` varchar(50) default NULL,
      `city` varchar(45) default NULL,
      `state` varchar(45) default NULL,
      `zip` varchar(50) default NULL,
      `exp` int(11) default NULL,
      `featured` varchar(4) default NULL,
      `active` varchar(5) default NULL,
      `hits` int(11) default NULL,
      `bed` varchar(10) default NULL,
      `bath` varchar(10) default NULL,
      `subdiv` varchar(60) default NULL,
      `schoold` varchar(60) default NULL,
      `year` int(11) default NULL,
      `lot_size` double default NULL,
      `sqft` double default NULL,
      `lat` varchar(40) default NULL,
      `long` varchar(40) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;

    [/code]



    It is an edit.php file, so i am trying to edit a current record in my mysql table.

    the new field i have added is called "b&bname"

    I have added a new field in mymsql table called "b&bname"

    i really don't get why i am getting this error.

    please help... 

    my full code is here:

    [code=php:0]
    <?php require_once('Connections/myconn.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    //begin debug
    //print $_REQUEST['city'];
    //die();
    //end debug

    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

    //fetch logn and lat for address
    $request_address = $_REQUEST['address'] . ', '.$_REQUEST['city'].' '.$_REQUEST['state'].' '.$_REQUEST['zip'];
    require('admin/xmlparse.ini.php');
    require('admin/llfetch.php');

      $updateSQL = sprintf("UPDATE items SET `long`=%s, `lat`=%s, cid=%s, title=%s, b&bname=%s, price=%s, special_price=%s, description=%s, address=%s, city=%s, `state`=%s, zip=%s, bed=".GetSQLValueString($_REQUEST['bed'],"text").", bath=".GetSQLValueString($_REQUEST['bath'],"text").", subdiv=".GetSQLValueString($_REQUEST['subdiv'],"text").", schoold = ".GetSQLValueString($_REQUEST['schoold'],"text").", year = ".GetSQLValueString($_REQUEST['year'],"int").", lot_size = ".GetSQLValueString($_REQUEST['lot_size'],"double").", sqft = ".GetSQLValueString($_REQUEST['sqft'],"double")." WHERE id=".GetSQLValueString($_REQUEST['id'],"int")."",
                          GetSQLValueString($address['long'], "text"),
                          GetSQLValueString($address['lat'], "text"),
                          GetSQLValueString($_POST['cat'], "int"),
                          GetSQLValueString($_POST['title'], "text"),
                          GetSQLValueString($_POST['price'], "double"),
                          GetSQLValueString($_POST['special_price'], "double"),
                          GetSQLValueString($_POST['description'], "text"),
          GetSQLValueString($_POST['b&bname'], "text"),
                          GetSQLValueString($_POST['address'], "text"),
                          GetSQLValueString($_POST['city'], "text"),
                          GetSQLValueString($_POST['state'], "text"),
                          GetSQLValueString($_POST['zip'], "text"),
                          GetSQLValueString($_POST['id'], "int")
      );
    //echo $updateSQL;
    //die();
      mysql_select_db($database_myconn, $myconn);
      $Result1 = mysql_query($updateSQL, $myconn) or die(mysql_error());

      $updateGoTo = "a_index.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }


    ?>
    <? include('header.php'); ?>
    <?php


    //fetch all categories from database , and load into a assoc array
    mysql_select_db($database_myconn, $myconn);
    $query_cat = "SELECT * FROM categories ORDER BY title ASC";
    $cat = mysql_query($query_cat, $myconn) or die(mysql_error());
    $row_cat = mysql_fetch_assoc($cat);
    $totalRows_cat = mysql_num_rows($cat);

    //fetch member information from  datebase where email matches session varable
    $colname_minfo = "1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_minfo = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_myconn, $myconn);
    $query_minfo = sprintf("SELECT * FROM members WHERE email = '%s'", $colname_minfo);
    $minfo = mysql_query($query_minfo, $myconn) or die(mysql_error());
    $row_minfo = mysql_fetch_assoc($minfo);
    $totalRows_minfo = mysql_num_rows($minfo);

    mysql_select_db($database_myconn, $myconn);
    $query_city = "SELECT * FROM city ORDER BY title ASC";
    $city = mysql_query($query_city, $myconn) or die(mysql_error());
    $row_city = mysql_fetch_assoc($city);
    $totalRows_city = mysql_num_rows($city);

    mysql_select_db($database_myconn, $myconn);
    $query_state = "SELECT * FROM `state` ORDER BY title ASC";
    $state = mysql_query($query_state, $myconn) or die(mysql_error());
    $row_state = mysql_fetch_assoc($state);
    $totalRows_state = mysql_num_rows($state);

    //fetch all active credits from accounting table in database
    $colname_a = $row_minfo['id']; // store member id
    mysql_select_db($database_myconn, $myconn);
    $query_a = sprintf("SELECT * FROM accounting WHERE mid = %s", $colname_a) . " and active = 'Yes'";
    //echo $query_a;
    $a = mysql_query($query_a, $myconn) or die(mysql_error());
    $row_a = mysql_fetch_assoc($a);
    $totalRows_a = mysql_num_rows($a);

    //fetch item from database and place in assoc array
    if (isset($_GET['id'])) {
      $colname_item = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
    }
    mysql_select_db($database_myconn, $myconn);
    $query_item = sprintf("SELECT * FROM items WHERE id = %s", $colname_item) .  " and mid =" . $row_minfo['id'];

    $item = mysql_query($query_item, $myconn) or die(mysql_error());
    $row_item = mysql_fetch_assoc($item);
    $totalRows_item = mysql_num_rows($item);
    ?>
    <link href="mystyle.css" rel="stylesheet" type="text/css">


    <form method="POST" action="<?php echo $editFormAction; ?>" name="form1">
    <table width="500" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF">
      <caption align="left" class="pageTitle">
      <h1>Edit Property Listing</h1>
      </caption>
      <tr>
        <td class="colText">Category</td>
        <td bgcolor="#FFFFFF"><select name="cat" id="cat">
          <?php
    do {
    ?>
          <option value="<?php echo $row_cat['id']?>"<?php if (!(strcmp($row_cat['id'], $row_item['cid']))) {echo "SELECTED";} ?>><?php echo $row_cat['title']?></option>
          <?php } while ($row_cat = mysql_fetch_assoc($cat));
      $rows = mysql_num_rows($cat);
      if($rows > 0) {
          mysql_data_seek($cat, 0);
      $row_cat = mysql_fetch_assoc($cat);
      }
    ?>
        </select></td>
      </tr>
      <tr>
        <td class="colText">B&B Name:</td>
        <td bgcolor="#FFFFFF"><input name="b&bname" type="text" id="b&bname" value="<?php echo $row_item['b&bname']; ?>" size="25"></td>
      </tr>

        <tr>
        <td class="colText">Price:</td>
        <td bgcolor="#FFFFFF"><input name="price" type="text" id="price" value="<?php echo $row_item['price']; ?>" size="25"></td>
      </tr>
      <tr>
        <td class="colText">Address</td>
        <td bgcolor="#FFFFFF"><input name="address" type="text" id="address" value="<?php echo $row_item['address']; ?>" size="40"></td>
      </tr>
      <tr>
        <td class="colText">City/Town</td>
        <td bgcolor="#FFFFFF">      <span class="rowText">
    <? if(mysql_num_rows($city) <=0){?>
        <input name="city" type="text" id="city" value="<?php echo $row_item['city'] ?>">
    <? }else { ?>
        <select name="city" id="city">
          <?php
    do {
    ?>
          <option value="<?php echo $row_city['title']?>"<?php if ($row_city['title'] == $row_item['city']) {echo "SELECTED";} ?>><?php echo $row_city['title']?></option>
          <?php
    } while ($row_city = mysql_fetch_assoc($city));
      $rows = mysql_num_rows($city);
      if($rows > 0) {
          mysql_data_seek($city, 0);
      $row_city = mysql_fetch_assoc($city);
      }
    ?>
        </select>
    <? } ?>
        </span></td>
      </tr>
      <tr>
        <td class="colText">County</td>
        <td bgcolor="#FFFFFF"><span class="rowText">      <select name="state" id="state" style="width: 109px;">
          <?php
    do {
    ?>
          <option value="<?php echo $row_state['stitle']?>"<?php if (!(strcmp($row_state['stitle'], $row_item['state']))) {echo "SELECTED";} ?>><?php echo $row_state['title']?></option>
              <?php
    } while ($row_state = mysql_fetch_assoc($state));
      $rows = mysql_num_rows($state);
      if($rows > 0) {
          mysql_data_seek($state, 0);
      $row_state = mysql_fetch_assoc($state);
      }
    ?>
          </select>
    </span></td>
      </tr>
      <tr>
        <td class="colText">Postcode</td>
        <td bgcolor="#FFFFFF"><input name="zip" type="text" id="zip" value="<?php echo $row_item['zip']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Bed(s)</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="bed" type="text" id="bed" value="<?php echo $row_item['bed']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Bathroom(s)</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="bath" type="text" id="bath" value="<?php echo $row_item['bath']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Year</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="year" type="text" id="year" value="<?php echo $row_item['year']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Local Authority</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="subdiv" type="text" id="subdiv" value="<?php echo $row_item['subdiv']; ?>" size="40" maxlength="60"></td>
      </tr>
      <tr>
        <td class="colText">Local Hospital</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="schoold" type="text" id="schoold" value="<?php echo $row_item['schoold']; ?>" size="40" maxlength="60"></td>
      </tr>
      <tr>
        <td class="colText">Grounds (Acres)</td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="lot_size" type="text" id="lot_size" value="<?php echo $row_item['lot_size']; ?>" size="15"></td>
      </tr>
      <tr>
        <td class="colText">Square Feet </td>
        <td bgcolor="#FFFFFF" class="rowText"><input name="sqft" type="text" id="sqft" value="<?php echo $row_item['sqft']; ?>" size="15"></td>
      </tr>
      <tr>
        <td colspan="2" class="colText"><p>Description</p>    </td>
      </tr>
      <tr>
        <td colspan="2" class="colText"><div align="center">
          <textarea name="description" cols="70" rows="15" id="description"><?php echo $row_item['description']; ?></textarea>
        </div></td>
      </tr>
      <tr>
        <td colspan="2"><div align="right">
            <input name="id" type="hidden" id="id" value="<?php echo $row_item['id']; ?>">
            <input type="submit" name="Submit4" value="Submit">
            <input type="reset" name="Submit22" value="Reset">
            <input name="Submit32" type="button" onClick="window.location='a_index.php'" value="Cancel">
        </div></td>
      </tr>
    </table>
    <input type="hidden" name="MM_update" value="form1">
    </form>
    <? include('footer.php'); ?>
    <?php
    mysql_free_result($city);

    mysql_free_result($state);

    mysql_free_result($item);
    ?>
    [/code]
  5. I am trying to display some data via php that i have stored in my mysql database,

    I seem to have worked the code out for the text that i want displayed but when i enter the info for the photo that is stored in my mysql i just get the web link displayed instead of the actual image.

    My Mysql database structure is as follows:

    [code]
    create table Players ( PlayerID integer not null primary key auto_increment , Forename varchar(50) , Surname varchar(50) not null , DOB date , RegNo tinyint , Photo varchar(255) , Nickname varchar(50) , Comments varchar(255) , Position varchar(50) , GamesPlayed tinyint , GoalsScored tinyint );
    [/code]

    My php code is as follows:

    [code]
    <? $username="root"; $password=""; $database="players"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM players"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $Forename=mysql_result($result,$i,"Forename"); $Surname=mysql_result($result,$i,"Surname"); $DOB=mysql_result($result,$i,"DOB"); $Nickname=mysql_result($result,$i,"Nickname"); $Photo=mysql_result($result,$i,"Photo"); echo "<b>$Forename$Surname</b><br>Date Of Birth: $DOB<br>Nickname: $Nickname<br>Photo: $Photo<br><br><hr><br>"; $i++; } ?>
    [/code]

    the image is stored in the table under the field called Photo, it is stored as a url to the image as follows:

    http://uxellaleague.com/images/teams_200506/red_tile.jpg

    but is displayed as follows

    Chimp
    Date Of Birth: 1971-04-08
    Nickname: Gaffer
    Photo: http://uxellaleague.com/images/teams_200506/red_tile.jpg
    E-mail:
    Web:

    someone has said that this may help but i have no idea how to get it to work, should i leave the words std url in, for example?

    [code]
    $out .= "<img src=\".$prow['Std_URL'])."\" width=\"".$iSize['0']."\" height=\"".$iSize['1']."\" border=\"0\" alt=\"Select this for a more detailed image\">";
    [/code]

    Please Help

    Thanks in advance
    Andy
×
×
  • 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.