ibexy Posted February 5, 2008 Share Posted February 5, 2008 I have declared some variables global but still cant get them to have values. I am using a text box + submit button and I want values to transfer from a table into these varibles and execute on click of the button. Any help? Link to comment https://forums.phpfreaks.com/topic/89562-visibility-of-variables/ Share on other sites More sharing options...
kenrbnsn Posted February 5, 2008 Share Posted February 5, 2008 Code please? Ken Link to comment https://forums.phpfreaks.com/topic/89562-visibility-of-variables/#findComment-458820 Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 any code? Link to comment https://forums.phpfreaks.com/topic/89562-visibility-of-variables/#findComment-458821 Share on other sites More sharing options...
vidyadoiphode Posted February 5, 2008 Share Posted February 5, 2008 can u send code? please see how the global variables are used. You can get some good links here. http://php-infosource.blogspot.com/ Link to comment https://forums.phpfreaks.com/topic/89562-visibility-of-variables/#findComment-458831 Share on other sites More sharing options...
ibexy Posted February 5, 2008 Author Share Posted February 5, 2008 I am working in joomla. What happens here is that I am retrieving values from a atble and then assingning a text box and and a button to each line. As each line is treived, I assigne the values to the variable declared global (see green shaded area). Later, I try to store these values in a table in the $_POST action for the buttons (See brown shaed areas). Its working fine. My problem is that nothing is being stored. (I have edited the program to make it shorter) <? global $database, $ueConfig, $my, $mosConfig_lang, $mainframe, $mosConfig_live_site, $_SERVER, $Itemid, $m_id,$m_description,$m_price; $gjp_path = $mosConfig_absolute_path.'/components/com_comprofiler/plugin/user/plug_groupjivetab'; $absolute_path = $mainframe->getCfg('absolute_path'); // Function buystuff if(isset($_POST['txtbuy'])){ $qty_bought=$_POST['txtbuy']; $query = "INSERT INTO #__joe_bought_items SET item_id='$m_id',description='$m_description', qty='$qty_bought',price= '$m_price', buyer_id='$my->id'"; $database->setQuery( $query ); $database->query() or die( $database->stderr() ); } // End Buy Stuff {Other codes} ?> <div align="center"> </p> </p> {other codes} <? $name_of_txt_box="txtbuy"; $type_of_txt_box="text"; $size_of_txt_box="8"; $post_method="POST"; $action_to_call="components/com_dailymessage/buy_shares.php"; $box_style="margin-top: 0; margin-bottom: 0"; $button_input_type="submit"; $button_value="Buy"; $button_name="btnbuy"; foreach($rows as $row) { // IBEX $m_id=$row->id; $m_description=$row->description; $m_qty=$row->qty; $m_price=$row->price; echo "<tr>"; echo "<td>" . $starttags . $row->id . $endtags . "</td>"; echo "<td>" . $starttags . $row->item . $endtags . "</td>"; echo "<td>" . $starttags . $row->description . $endtags . "</td>"; echo "<td>" . $starttags . $row->qty . $endtags . "</td>"; if ($row->item == 'Shares') echo "<td>" . $starttags . $system_share_value . $endtags . "</td>"; else echo "<td>" . $starttags . $row->price . $endtags . "</td>"; if ($total_credit >= $row->price) { // Below without action parameter echo "<td><form method=".$post_method."><p style=".$box_style."><input type=".$type_of_txt_box ." name=".$name_of_txt_box." size=".$size_of_txt_box."><input type=".$button_input_type." value=".$button_value." name=".$button_name."</p></form></td>"; // ibex old codes: echo "<td><a href=" . $row->action . ">buy</a></td></tr>"; } else { echo "<td>Unaffordable</td></tr>"; } } ?></table> </div> </br> <? {other codes} ?> Link to comment https://forums.phpfreaks.com/topic/89562-visibility-of-variables/#findComment-458849 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.