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
https://forums.phpfreaks.com/topic/199336-function-question/
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
https://forums.phpfreaks.com/topic/199336-function-question/#findComment-1046203
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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