Jump to content

function question


wmguk

Recommended Posts

Hi, I'm trying to pass a database variable to a function...

 

<?php
    global $__CMS_CONN__;
    $sql = "SELECT * FROM " . TABLE_PREFIX . "products";
    $stmt = $__CMS_CONN__->prepare($sql);
    $stmt->execute(array($id));
    while ($row = $stmt->fetchObject()) {
	$pid = $row->pid;
        $pname = $row->pname;
        $pdesc = $row->pdesc;
        $pprice = $row->pprice;
    ?>
      
<a href="<?php echo get_url('plugin/ecat/edit'.$pid); ?>"><img src="<?php echo ECAT_ROOT;?>images/product_edit.jpg" align="middle" alt="Edit Product" /></a>

 

However it goes to /plugin/ecat/edit1 or edit2 etc etc. - I'm trying to get it to go to edit and pass $pid to a function

function edit($id) {
    	$this->display('ecat/views/edit');
    }

 

any ideas?

Link to comment
Share on other sites

ok, I am using a CMS system called WolfCMS, and I am trying to make a plugin for it.

 

Basically I have a section of files, some with functions in, and others using those functions...

 

My ultimate goal is to edit a product. - Name, Desc, Price (ID is fixed)....

 

So, I click on <a href="<?php echo get_url('plugin/ecat/edit'.$pid); ?> and it checks my function list for edit()

 

function edit($id) {
    	$this->display('ecat/views/edit');    
}

 

so how do i get it to assign $id to the $pid in the url?

 

once the id is assigned, it will edit the code using

<h1><?php echo __('Edit Product'); ?></h1>

<form action="<?php echo get_url('plugin/ecat/edit_prod' . $product->id); ?>" method="post">
<input name="pid" type="hidden" value="<?php echo $pid; ?>"/>
<table width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="200">Product Name:</td>
    <td><input name="pname" type="text" value="<?php echo $pname; ?>"/></td>
  </tr>
  <tr>
    <td>Product Description</td>
    <td><input name="pdesc" type="text" value="<?php echo $pdesc; ?>"/></td>
  </tr>
  <tr>
    <td>Product Price:</td>
    <td><input name="pprice" type="text" value="<?php echo $pprice; ?>"/></td>
  </tr>
  <tr>
    <td> </td>
    <td><input class="button" name="commit" type="submit" accesskey="s" value="<?php echo __('Save'); ?>" /></td>
  </tr>
</table>

</form>[code]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.