PHP - Please Help Echoing Select Label
Hi,
I have a select menu like this: Code: [Select] <form id="form1" name="form1" method="post" action="<?php htmlentities($_SERVER['PHP_SELF']); ?>"> <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" > <tr> <td width="38" align="left" class="UsuarioNombreHeader"><label> <input name="CurrencyAmount" type="text" class="CP_ExchangeFormFields" id="CurrencyAmount" size="6" /> </label></td> <td width="11" align="left" nowrap="nowrap" class="personalTitulo">€</td> <td width="11" align="left" nowrap="nowrap" class="UsuarioNombreHeader">to</td> <td width="204" align="left" nowrap="nowrap" class="UsuarioNombreHeader"><select name="selectCurrencyTo" class="CP_loginFormFields" id="selectCurrencyTo"> <option value="value" >Select currency</option> <option value="<?php echo $row_currency_RS['AUD']; ?>" >Australia Dollar (AUD)</option> <option value="<?php echo $row_currency_RS['BRL']; ?>" >Brazil Real (BRL)</option> <option value="<?php echo $row_currency_RS['BGN']; ?>" >Bulgaria Lev (BGN)</option> <option value="<?php echo $row_currency_RS['CAD']; ?>" >Canada Dollar (CAD)</option> <option value="<?php echo $row_currency_RS['CNY']; ?>" >China Yuan Renminbi (CNY)</option> <option value="<?php echo $row_currency_RS['HRK']; ?>" >Croatia Kuna (HRK)</option> <option value="<?php echo $row_currency_RS['CZK']; ?>" >Czech Republic Koruna (CZK)</option> <option value="<?php echo $row_currency_RS['DKK']; ?>" >Denmark Krone (DKK)</option> <option value="<?php echo $row_currency_RS['HKD']; ?>" >Hong Kong Dollar (HKD)</option> <option value="<?php echo $row_currency_RS['HUF']; ?>" >Hungary Forint (HUF)</option> <option value="<?php echo $row_currency_RS['INR']; ?>" >India Rupee (INR)</option> <option value="<?php echo $row_currency_RS['IDR']; ?>" >Indonesia Rupiah (IDR)</option> <option value="<?php echo $row_currency_RS['ILS']; ?>" >Israel Shekel (ILS)</option> <option value="<?php echo $row_currency_RS['JPY']; ?>" >Japanese Yen (JPY)</option> <option value="<?php echo $row_currency_RS['KRW']; ?>" >Korea (South) Won (KRW)</option> <option value="<?php echo $row_currency_RS['LVL']; ?>" >Latvia Lat (LVL)</option> <option value="<?php echo $row_currency_RS['LTL']; ?>" >Lithuania Litas (LTL)</option> <option value="<?php echo $row_currency_RS['MYR']; ?>" >Malaysia Ringgit (MYR)</option> <option value="<?php echo $row_currency_RS['MXN']; ?>" >Mexico Peso (MXN)</option> <option value="<?php echo $row_currency_RS['NZD']; ?>" >New Zealand Dollar (NZD)</option> <option value="<?php echo $row_currency_RS['NOK']; ?>" >Norway Krone (NOK)</option> <option value="<?php echo $row_currency_RS['PHP']; ?>" >Philippines Peso (PHP)</option> <option value="<?php echo $row_currency_RS['PLN']; ?>" >Poland Zloty (PLN)</option> <option value="<?php echo $row_currency_RS['RON']; ?>" >Romania New Leu (RON)</option> <option value="<?php echo $row_currency_RS['RUB']; ?>" >Russia Ruble (RUB)</option> <option value="<?php echo $row_currency_RS['SGD']; ?>" >Singapore Dollar (SGD)</option> <option value="<?php echo $row_currency_RS['ZAR']; ?>" >South Africa Rand (ZAR)</option> <option value="<?php echo $row_currency_RS['SEK']; ?>" >Sweden Krona (SEK)</option> <option value="<?php echo $row_currency_RS['CHF']; ?>" >Switzerland Franc (CHF)</option> <option value="<?php echo $row_currency_RS['THB']; ?>" >Thailand Baht (THB)</option> <option value="<?php echo $row_currency_RS['TRY']; ?>" >Turkey Lira (TRY)</option> <option value="<?php echo $row_currency_RS['GBP']; ?>" >United Kingdom Pound (GBP)</option> <option value="<?php echo $row_currency_RS['USD']; ?>" >US Dollar (USD)</option> </select></td> <td width="58" align="left" nowrap="nowrap" class="UsuarioNombreHeader"><input type="submit" name="button" id="button" value="convert" /></td> <td width="38" align="left" nowrap="nowrap" class="UsuarioNombreHeader"><input name="CurrencyResult" type="text" class="CP_ExchangeFormFields" id="CurrencyResult" value="<?php echo $total_euros ?>" size="6" /></td> <td width="819" align="left" nowrap="nowrap" class="UsuarioNombreHeader"><?php echo $currency_amount?> € = <?php echo $total_euros?> <?php echo $select_currency?> </td> </tr> </table> </form>This is part of a currency conversion script I have done. Now I am outputting the result of the currency conversion like this: Code: [Select] <?php echo $currency_amount?> € = <?php echo $total_euros?> <?php echo HERE_I_WANT_THE_CURRENCY_NAME?>but because the select men labels are not dynamically pulled from my DB (due to the way the DB had to be done), I can't figure out how to echo the currency name at the end of the conversion result. Any ideas?...Thanks Similar TutorialsIs it possible to have a link at the top of a page that has been displayed from a database? Just that some results show thousands of rows. Thanks.
Hi,
in my code radio button disable when passing value is "0"
<script type="text/javascript"> $('input[type="radio"]').prop('disable', function() { return $(this).next().text().match(/\((\d+)\)/)[1] == 0; }); </script>it's ok.what i want to do is,color a label or label text when this function true. <label > <input type="radio" name="radio" id="rd" value="" /> Click </label>please help me Hi All, I am currently using jpgraph on a site, and I'm trying to get the (x,y) coordinates an a chart to have two different colors ... (x = green, y = red) You can see an example he http://entropylinks.com/testgraph-dev.php?energy=2.2&entropy=1.75 Here is my code: Code: [Select] <?php // content="text/plain; charset=utf-8" require_once ("graph/src/jpgraph.php"); require_once ("graph/src/jpgraph_scatter.php"); DEFINE('MATRIX','images/matrix-big-2.png'); $datax = array(0,3); $datay = array(0,3); if(isset($_SESSION['counter']) && $_SESSION['counter'] > 1){ $x = 1.98; $y = 1.2; $count = $_SESSION['counter']; for($i = 0; $i < $count; $i++){ $datax[] += $_SESSION["entropy_$i"]; $datay[] += $_SESSION["energy_$i"]; } } else { $datax = explode('-', $_GET['energy']); $datay = explode('-', $_GET['entropy']); } $idx=0; function xyCallback($yval) { global $datay, $idx; return "($yval-".$datay[$idx++].")"; } $graph = new Graph(550,550); $graph->SetScale("intint",0,3,0,3); $graph->img->SetMargin(40,40,40,40); $graph->SetBackgroundImage(MATRIX,BGIMG_FILLPLOT); $graph->title->SetFont(FF_ARIAL,FS_BOLD); $graph->xaxis->SetTitle('CORPORATE ENTROPY','middle'); $graph->yaxis->SetTitle('CORPORATE ENERGY','middle'); $graph->yaxis->SetTextTickInterval(1,2); $sp1 = new ScatterPlot($datax,$datay); $sp1->mark->SetSize(10); $sp1->mark->SetFillColor("darkblue"); $sp1->mark->SetType(MARK_FILLEDCIRCLE); $sp1->value->SetMargin(17); $sp1->value->SetFormatCallback('xyCallback'); $sp1->value->SetColor("darkgreen"); $sp1->value->SetFont(FF_FONT0,FS_NORMAL); $sp1->value->Show(); $txt = new Text("Low"); // store text $txt->SetFont(FF_FONT0,FS_NORMAL); $txt->SetScalePos(0.5,0); $txt->SetColor('darkblue'); $txt->Center(50,150,75); $graph->AddText( $txt); // write to position $txt = new Text("Medium"); // store text $txt->SetFont(FF_FONT0,FS_NORMAL); $txt->SetScalePos(1.5,0); $txt->SetColor('darkblue'); $txt->Center(50,150,75); $graph->AddText( $txt); // write to position $txt = new Text("High"); // store text $txt->SetFont(FF_FONT0,FS_NORMAL); $txt->SetScalePos(2.5,0); $txt->SetColor('darkblue'); $txt->Center(50,150,75); $graph->AddText( $txt); // write to position $txt = new Text("Low"); // store text $txt->SetFont(FF_FONT0,FS_NORMAL); $txt->SetScalePos(-0.03,0.5); $txt->SetAngle(90); $txt->SetColor('darkblue'); $txt->Center(50,150,75); $graph->AddText( $txt); // write to position $txt = new Text("Medium"); // store text $txt->SetFont(FF_FONT0,FS_NORMAL); $txt->SetScalePos(-0.03,1.5); $txt->SetAngle(90); $txt->SetColor('darkblue'); $txt->Center(50,150,75); $graph->AddText( $txt); // write to position $txt = new Text("High"); // store text $txt->SetFont(FF_FONT0,FS_NORMAL); $txt->SetScalePos(-0.03,2.5); $txt->SetAngle(90); $txt->SetColor('darkblue'); $txt->Center(50,150,75); $graph->AddText( $txt); // write to position $graph->Add($sp1); $graph->Stroke(); ?> Here's the class code that controls the scatter graph Code: [Select] //=================================================== // CLASS ScatterPlot // Description: Render X and Y plots //=================================================== class ScatterPlot extends Plot { public $mark,$link; private $impuls = false; //--------------- // CONSTRUCTOR function __construct($datay,$datax=false) { if( (count($datax) != count($datay)) && is_array($datax)) { JpGraphError::RaiseL(20003);//("Scatterplot must have equal number of X and Y points."); } parent::__construct($datay,$datax); $this->mark = new PlotMark(); $this->mark->SetType(MARK_SQUARE); $this->mark->SetColor($this->color); $this->value->SetAlign('center','center'); $this->value->SetMargin(0); $this->link = new LineProperty(1,'black','solid'); $this->link->iShow = false; } //--------------- // PUBLIC METHODS function SetImpuls($f=true) { $this->impuls = $f; } function SetStem($f=true) { $this->impuls = $f; } // Combine the scatter plot points with a line function SetLinkPoints($aFlag=true,$aColor="black",$aWeight=1,$aStyle='solid') { $this->link->iShow = $aFlag; $this->link->iColor = $aColor; $this->link->iWeight = $aWeight; $this->link->iStyle = $aStyle; } function Stroke($img,$xscale,$yscale) { $ymin=$yscale->scale_abs[0]; if( $yscale->scale[0] < 0 ) $yzero=$yscale->Translate(0); else $yzero=$yscale->scale_abs[0]; $this->csimareas = ''; for( $i=0; $i<$this->numpoints; ++$i ) { // Skip null values if( $this->coords[0][$i]==='' || $this->coords[0][$i]==='-' || $this->coords[0][$i]==='x') continue; if( isset($this->coords[1]) ) $xt = $xscale->Translate($this->coords[1][$i]); else $xt = $xscale->Translate($i); $yt = $yscale->Translate($this->coords[0][$i]); if( $this->link->iShow && isset($yt_old) ) { $img->SetColor($this->link->iColor); $img->SetLineWeight($this->link->iWeight); $old = $img->SetLineStyle($this->link->iStyle); $img->StyleLine($xt_old,$yt_old,$xt,$yt); $img->SetLineStyle($old); } if( $this->impuls ) { $img->SetColor($this->color); $img->SetLineWeight($this->weight); $img->Line($xt,$yzero,$xt,$yt); } if( !empty($this->csimtargets[$i]) ) { if( !empty($this->csimwintargets[$i]) ) { $this->mark->SetCSIMTarget($this->csimtargets[$i],$this->csimwintargets[$i]); } else { $this->mark->SetCSIMTarget($this->csimtargets[$i]); } $this->mark->SetCSIMAlt($this->csimalts[$i]); } if( isset($this->coords[1]) ) { $this->mark->SetCSIMAltVal($this->coords[0][$i],$this->coords[1][$i]); } else { $this->mark->SetCSIMAltVal($this->coords[0][$i],$i); } $this->mark->Stroke($img,$xt,$yt); $this->csimareas .= $this->mark->GetCSIMAreas(); $this->value->Stroke($img,$this->coords[0][$i],$xt,$yt); $xt_old = $xt; $yt_old = $yt; } } // Framework function function Legend($aGraph) { if( $this->legend != "" ) { $aGraph->legend->Add($this->legend,$this->mark->fill_color,$this->mark,0, $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); } } } // Class Does anyone have a solution for this? Is it even possible? Do I need to somehow modify the class to render these different colors? Feel free to ask any questions you may have, I'm 99% complete with this, but I just can't seem to change the colors of the plot labels. Thanks! ok i think and hope this will be my last issue with this site. i have two forms on the same contact page, but right now theyre using the same error label. this means if ONE has an error, both forms show as that same error. id like to somehow separate this and give each one its own label. i tried doing like error[2] for the 2nd button instead of error[] but then i didnt know what to change the actual "error label" to. do i changed the "$errors = array();" part? to create a second label? i tried to google on it and couldnt figure it out. thanks a million to anyone who even reads <?php if (isset($errors)) { foreach ($errors as $error) { echo("<p>$error<p>\n"); } } ?> so my question basically is, how do i use this code below to create a second error case AND label please!! <?php if ($_POST['send']) { $errors = array(); if ($_POST['captcha'] != $_SESSION['captchacode']) { $errors[] = "You didn't enter the correct letters!"; } + <?php if (isset($errors)) { foreach ($errors as $error) { echo("<p>$error<p>\n"); } } ?> Hello. I have a basic form and I want to check for errors by making sure the user inputs everything, if not an error explaining to the user what needs to be fixed. (very common on all forms) When I use echo in my script, it displays at the top of my browser. How do I put the error codes right beside my form elements? I currently don't have all the error checking included but I want to get a few sorted out before anything else. Form Page: http://www.fusionfashionhair.com/registration.php My PHP Code all above DOCTYPE in the php file. Code: [Select] <?php $submit = $_POST['submit']; // Form Data // Check all form inputs using check_input function $name = strip_tags($_POST['name']); $address = strip_tags($_POST['address']); $email = strip_tags($_POST['email']); $repeatemail = strip_tags($_POST['repeatemail']); $phone = strip_tags($_POST['phone'], "Enter your Phone Number"); $salonname = strip_tags($_POST['salonname']); $salonaddress = strip_tags($_POST['salonaddress']); $salonprov = strip_tags($_POST['salonprov']); $salonpostal = strip_tags($_POST['salonpostal']); $salonconfirm = strip_tags($_POST['salonconfirm']); $enewsletter = strip_tags($_POST['enewsletter']); $saloncountry = strip_tags($_POST['saloncountry']); $password = strip_tags($_POST['password']); $repeatpassword = strip_tags($_POST['repeatpassword']); $date = date("Y-m-d"); // Set e-mail recipient $myemail = "info@fusionfashionhair.com"; if ($submit) { //check for existance if ($name&&$password&&$repeatpassword&&$email) { if ($password==$repeatpassword) { if ($email==$repeatemail) { //check password length if (strlen($password)>32||strlen($password)<6) { echo '<p class="formecho">Password must be between 6 and 32 characters</p>'; } else { // Thank you Page $insertGoTo = "thankyou.php"; header(sprintf("Location: %s", $insertGoTo)); // encrypt password $temppass = $password; $password = md5($password); $repeatpassword = md5($repeatpassword); // dBase file include "dbConfig.php"; //open database //generate random number for activation process $random = md5(rand(23456789,987654321)); // register the user! // Set default username $username = $email; // INSERT INTO user... replace user with table name // make sure you have the same number and order of values as the database has $queryreg = mysql_query(" INSERT INTO user VALUES ('','$name','$username','$password','$date','$email','$phone','$address','$salonname','$salonaddress','$salonprov','$salonpostal','$saloncountry','$salonconfirm','$enewsletter','$random','0')"); //Insert ID based on last ID in database $lastid = mysql_insert_id(); //send activation email $to = $email; $subject = "Activate Salon Member Acctount at Fusion Fashion Hair"; $headers = "From: webmaster@fusionfashionhair.com"; $server = "mail.fusionfashionhair.com"; //change php.ini and set SMTP to $server ini_set("SMTP",$server); $body = " $name from $salonname is wanting a membership, \n\n Please click on the link provided below to activate the account with Fusion Fashion Hair http://www.fusionfashionhair.com/activate.php?id=$lastid&code=$random \n\n Username = $username \n Password = $temppass \n Thank you, Customer Service "; //function to send email mail($to, $subject, $body, $headers); } } else echo '<p class="formecho">Your passwords do not match!</p>'; } else echo '<p class="formecho">Your Emails do not match!</p>'; }//End check Existance else echo '<p class="formecho">Please fill in <b>ALL</b> fields!</p>'; }// End if Sumbit ?> I'm not sure if this is the right section, if not, please move it on proper one, i'm still newbie. However, here's my problem, i'm using jquery to replace standard check boxes with images, and here's the code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { /* see if anything is previously checked and reflect that in the view*/ $(".checklist input:checked").parent().addClass("selected"); /* handle the user selections */ $(".checklist .checkbox-select").click( function(event) { event.preventDefault(); $(this).parent().addClass("selected"); $(this).parent().find(":checkbox").attr("checked","checked"); } ); $(".checklist .checkbox-deselect").click( function(event) { event.preventDefault(); $(this).parent().removeClass("selected"); $(this).parent().find(":checkbox").removeAttr("checked"); } ); }); </script> Here's the css: <style type="text/css"> body { font: 12px/1.3 "Lucida Grande","Lucida","Arial",Sans-serif; } form { margin: 0 0 30px 0; } legend { font-size: 17px; } fieldset { border: 1; } .checklist { list-style: none; margin: 0; padding: 0; } .checklist li { float: left; margin-right: 10px; background: url(i/checkboxbg.gif) no-repeat 0 0; width: 105px; height: 80px; position: relative; font: normal 11px/1.3 "Lucida Grande","Lucida","Arial",Sans-serif; } .checklist li.selected { background-position: -105px 0; } .checklist li.selected .checkbox-select { display: none; } .checkbox-select { display: block; float: left; position: absolute; top: 55px; left: 10px; width: 85px; height: 23px; background: url(i/select.gif) no-repeat 0 0; text-indent: -9999px; } .checklist li input { display: none; } a.checkbox-deselect { display: none; color: white; font-weight: bold; text-decoration: none; position: absolute; top: 55px; right: 10px; } .checklist li.selected a.checkbox-deselect { display: block; } .checklist li label { display: block; text-align: center; padding: 8px; } .sendit { display: block; float: left; top: 118px; left: 10px; width: 115px; height: 34px; border: 0; cursor: pointer; background: url(i/sendit.gif) no-repeat 0 0; text-indent: -9999px; margin: 20px 0; } </style> And finally the form thing <ul class="checklist"><li><input name="jqdemo" value="value5" type="checkbox" id="choice_c"/><label for="choice_c">Some Text Here to be checked - clicked</label><a class="checkbox-select" href="#">Click</a><a class="checkbox-deselect" href="#">Cancel</a></li></ul> I would like that my text on top of checkboxes become clickable. Hello, I have a PHP page (below) that is suppose to update a field in my database. For some reason it does not update. I am trying to echo that sql with this script. Any help would be greatly appreciated. Thanks JR Code: [Select] $p = (100-$_POST[$c])/100; $sql = "delete from products_groups where customers_group_id = ".$sppc['customers_group_id']; echo $sql; tep_db_query($sql); $sql = "insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p"; echo $sql; tep_db_query($sql); Below is the complete code, Code: [Select] <?php require('includes/application_top.php'); ?> <!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script language="javascript" src="includes/general.js"></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> <div id="popupcalendar" class="text"></div> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'template_top.php'); ?> <!-- header_eof //--> <?php if (isset($_POST['Update'])) { $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { if ($sppc["customers_group_name"] != "Retail"){ //$sppc['customers_group_id'] $c = "CG_".$sppc['customers_group_id']; $tmp = $_POST[$c]; if ($tmp != 0) { $p = (100-$_POST[$c])/100; tep_db_query("delete from products_groups where customers_group_id = ".$sppc['customers_group_id']); tep_db_query ("insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p"); } //if not 0 } //if not Retail } } ?> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo "Special Pricing Discount Setup"; ?></td> <td class="specialPrice" align="right"> </td> </tr> </table></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" align="left"> <?php if (isset($_POST['Update'])) { echo "<center>Updated!</center>"; } ?> </td> </tr> <?php $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { ?> <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"> <td class="dataTableContent" align="left"> <?php if ($sppc["customers_group_name"] != "Retail"){ echo $sppc["customers_group_name"]; } if (isset($_POST['Update'])) { if ($sppc["customers_group_name"] != "Retail"){ $c = "CG_".$sppc['customers_group_id']; $tmp = $_POST[$c]; echo " Current Discount is $tmp%" ; } } ?> </td> </tr> <?php } ?> </table></td> </tr> <tr> <td valign="top"> <form action="" method="post"> <table border="0" width="40%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" align="left"> </td> <td> </td> </tr> <?php $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"; $sppc_query = tep_db_query($sppc_query_raw); while( $sppc = tep_db_fetch_array( $sppc_query ) ) { if ($sppc["customers_group_name"] != "Retail"){ ?> <tr> <td class="smallText" align="left">Set New Percentage (%) Discount for <?=$sppc["customers_group_name"]?> :</td> <td><input name="CG_<?=$sppc['customers_group_id']?>" type="text" size="5" value="0"></td> </tr> <?php } } ?> <tr> <td colspan="2" align="center"><input type="submit" name="Update" value="Update"></td> </tr> </table> </form> </td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> This problem is existing on a few pages so I'll be in the clear if I can figure out to solve it on one page. Problem is on form submission its still echoing back that sortorder variable which makes it hard for it to compare on the success function to display the right message because the message should be good, bad1, bad2, ... . So is there anyway around that or do I need to do something on the client side of the form page. <?php // Include the database page require ('../inc/dbconfig.php'); if ( isset( $_POST['menuid'] ) ) { $menuid = (int)$_POST['menuid']; $query = "SELECT COUNT(sortorder) AS numOrder FROM `menuitems` WHERE `menu_id` = '".$menuid."'"; $result = mysqli_query ($dbc, $query); $row = mysqli_fetch_array( $result, MYSQL_ASSOC ); $sortorder = $row[ 'numOrder' ] + 1; echo $sortorder; } if (isset($_POST['submitmenuitem'])) { $menuid = mysqli_real_escape_string($dbc, $_POST['menuid']); $itemname = mysqli_real_escape_string($dbc, $_POST['itemname']); $itemurl = mysqli_real_escape_string($dbc, $_POST['itemurl']); $sortorder = mysqli_real_escape_string($dbc, $_POST['sortorder']); $contentpage = mysqli_real_escape_string($dbc, $_POST['contentpage']); $newscategory = mysqli_real_escape_string($dbc, $_POST['newscategory']); $application = mysqli_real_escape_string($dbc, $_POST['application']); $query = "SELECT * FROM `menuitems` WHERE (`itemname` = '".$itemname."') OR (`itemurl` = '".$itemurl."') OR (`contentpage_id` = '".$contentpage."') OR (`application_id` = '".$application."') OR (`newscategory_id` = '".$newscategory."') AND `menu_id` = '".$menuid."'"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); if ($rows == 0) { $query = "INSERT INTO `menuitems` (menu_id, itemname, itemurl, sortorder, contentpage_id, newscategory_id, application_id, creator_id, datecreated, enabled) VALUES ('".$menuid."','".$itemname."','".$itemurl."','".$sortorder."','".$contentpage."', '".$newscategory."', '".$application."', 1, NOW(), 0)"; mysqli_query($dbc, $query); echo "good"; } else { $row = mysqli_fetch_array($result); if (($row['itemname'] == $itemname) && ($row['newscategory_id'] == $newscategory)) echo 'bad9'; elseif (($row['itemname'] == $itemname) && ($row['application_id'] == $application)) echo 'bad8'; elseif (($row['itemname'] == $itemname) && ($row['contentpage_id'] == $contentpage)) echo 'bad7'; elseif (($row['itemname'] == $itemname) && ($row['itemurl'] == $itemurl)) echo 'bad6'; elseif ($row['newscategory_id'] == $newscategory) echo 'bad5'; elseif ($row['application_id'] == $application) echo 'bad4'; elseif ($row['contentpage_id'] == $contentpage) echo 'bad3'; elseif ($row['itemurl'] == $itemurl) echo 'bad2'; elseif ($row['itemname'] == $itemname) echo 'bad1'; } } if (isset($_POST['deletemenuitem'])){ $menuitemID = (int)$_POST['menuitemID']; $query = "UPDATE `menuitems` SET `enabled` = '1' WHERE `id` = '".$menuitemID."' LIMIT 1"; mysqli_query($dbc,$query); } ?> $lastfm = file_get_contents('http://www.last.fm/group/Rishloo/members'); $users = explode('" id="r4_', $lastfm); $users = explode('">', $users[1]); var_dump($users[0]); that is only echoing one ID http://www.last.fm/group/Rishloo/members 1 id for each member it should be echoing.. any idea why it isnt? $lastfm = file_get_contents('http://www.last.fm/group/Rishloo/members'); $grab_id=explode('" id="r4_', $lastfm); for($b=1; $b<count($grab_id); $b++){ $getid=explode('">', $grab_id[$b]); echo count($getid[0]); } that echos all 1's.. any help is appreciated.. thanks thanks Hello guys, I want to get the values of 3rd level of my referral but it did not echo any value but if i put the ref id directly on the code, it will echo the values. why is it so? or am i doing it the wrong way? in my database i have a table test_referral id acct_name ref_id refer_id 1 john J1234 0 2 bull B3456 J1234 3 doe D5567 J1234 4 frank F7788 J1234 5 jimmy J9990 J1234 6 tommy T6784 F7788 7 tom T9988 F7788 8 girly G8866 D5567 9 fred F0099 J9990 10 ronaldo R7722 B3456 thanks $stmt= $pdo->query("SELECT * FROM test_referral WHERE acct_name='Chidi Okafor'"); $parent = $stmt->fetch(PDO::FETCH_LAZY); echo "<ul><li>"; echo $parent['acct_name']; $ref_id = $parent['ref_id']; echo "</li><ul>"; $stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_id'"); $child_count = $stmt->rowCount(); while($child = $stmt->fetch(PDO::FETCH_LAZY)){ echo "<li>"; echo $child['acct_name']; $ref_ids = $child['ref_id']; echo "</li>"; } //$reff = "F7788"; //$stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$F7788'"); $stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_ids'"); $child_count2 = $stmt->rowCount(); while($children = $stmt->fetch(PDO::FETCH_LAZY)){ echo "<ul><li>"; echo $children['acct_name']; echo "</li></ul>"; } Edited by Mr-Chidi, 25 December 2014 - 05:34 AM. I am having issue creating a checkbox that uses a onClick() js method. I believe this might be due to the fact that I am echoing the html but if any one could help id appreciate it. echo "<tr><td>WrkComp</td><td><input type='checkbox'" ?> <script>onClick="show()" </script> <? "name='WrkComp[]' value='DEP' '.$checked.' '.$Disabled.'/></td>"; Hi all, On my website I have a Functions file which holds information about the user for the game, but earier on today I added ranks which are for the users money. So for the ammout of money they have gives them a different money rank. Heres what ive got: function wealthrank(){ if (($info->money >= "0") && ($info->money < "10000")){ $wealth = "Poor (£0 - £10,000)"; $done="1"; } elseif (($info->money >= "10000") && ($info->money < "500000")){ $wealth = "Won The Lottery (£10,000- £500,000)"; $done="1"; } elseif (($info->money >= "500000") && ($info->money < "5000000")){ $wealth = "Too Much (£500,000 - £5,000,000)"; $done="1"; } elseif (($info->money >= "5000000") && ($info->money < "20000000")){ $wealth = "Millionare (£5,000,000 - £20,000,000)"; $done="1"; } elseif (($info->money >= "20000000") && ($info->money < "75000000")){ $wealth = "Owns The Streets (£20,000,000 - £75,000,000)"; $done="1"; } elseif (($info->money >= "75000000") && ($info->money < "100000000")){ $wealth = "Won The Euro Millions (£75,000,000 - £100,000,000)"; $done="1"; } elseif (($info->money >= "100000000") && ($info->money < "300000000")){ $wealth = "Multi millionare (£100,000,000 - £300,000,000)"; $done="1"; } elseif (($info->money >= "300000000") && ($info->money < "700000000")){ $wealth = "Owns A Bank (£300,000,000 - £700,000,000)"; $done="1"; } elseif (($info->money >= "700000000") && ($info->money < "1500000000")){ $wealth = "Rather Rich (£700,000,000 - £1,500,000,000)"; $done="1"; } elseif (($info->money >= "1500000000") && ($info->money < "5000000000")){ $wealth = "Billionare (£1,500,000,000 - £5,000,000,000)"; $done="1"; } elseif (($info->money >= "5000000000") && ($info->money < "70000000000")){ $wealth = "Owner Of The Land (£5,000,000,000 +)"; $done="1"; } elseif ($info->money >= "100000000000"){ $wealth = "Nearly As Rich As NoName (Hidden!)"; $done="1"; } if (!$done){ $done="0"; } if ($done == "1"){ mysql_query("UPDATE users SET wealthrank='$wealth' WHERE username='$username'"); }} wealthrank(); For some reason its not echoing the correct wealth rank, even at that its only echoing the defult wealth rank. Here is what I done to test it. <?php session_start(); include ("includes/functions.php"); include ("includes/config.php"); logincheck(); $username = $_SESSION['username']; $get = mysql_query ("SELECT * FROM users WHERE username='$username'"); $fetch = mysql_fetch_object($get); ?> Testing something: <?php echo ($username); ?><br /> Wealth Rank: <?php echo ($fetch->wealthrank); ?><br /> Is there something wrong with the way im fetching it from the Database or something wrong with the code? Thanks for any help given. Hey i'm just woundering how i would echo numbers from a database like 1000000 lets say 1 million how would i go about on echoing it like this 1,000,000 ZhsHero Hi, this is how I echo some results from my DB: Code: [Select] <?php if(mysql_num_rows($execute)>0){ do{ echo " " .$result['id_cliente']. " " .$result['company_name']. " " .$result['cliente_tel']. " " ; }while($result = mysql_fetch_assoc($execute)); }else{ echo " No customer found. " ; } ?> and this echoes the results in one paragraph. I need to print the results in rows...and I need help with that. :shy:Thanks Hi all, ive got a script witch im wanting to echo all the selected users in a table.. It selects and echos the users but just dosent add on to the table. <?php $themembers = mysql_query("SELECT * FROM users WHERE crew = '$user->crew'"); $ammoutmembers = mysql_num_rows($themembers); ?> <html> <head> <title>Crew Members || SD</title> </head> <body> <?php if ($crewstuff->boss == $username || $crewstuff->coowner == $username || $crewstuff->underboss == $username){ ?> <table width='80%' align='center' class='table' cellpadding='0' cellspacing='0' border='1'> <tr> <td class='header' colspan='3' align='center'>Current Crew Members</td> </tr> <tr> <td class='omg' align='center' width='40%'>Username</td><td class='omg' align='center' width='30%'>Rep</td><td class='omg' width='30%' align='center'>Kick</td> </tr> <?php if ($ammoutmembers != "0"){ while ($member11 = mysql_fetch_object($themembers)){ ?> <tr> <td width='40%'><?php echo("<a href='profile.php?viewuser=$member11->username' target='mainFrame'>$member11->username</a>"); ?></td><td width='30%'><?php echo ("".number_format($member11->rep).""); ?></td><td width='30%'><?php echo("<a href='?action=members&kick=$member11->username'>Kick</a>"); ?></td> </tr> <tr> <td colspan='3' class='omg' align='center'>Any member kicked is logged.</td> </tr> </table> <?php } // $member11 }// $ammoutmembers }elseif ($crewstuff->member == $username){ echo ("Your not being here , without being staff."); } ?> Is there way I can make it so it will be something like this layout: Username | Rep | Kick ---------------------------------- username | 0 | Kick username | 0 | kick For each user thats echoed? Thanks for help given i'm not sure whether this should be in this section or the ajax section. i'm trying to echo out an ajax script so that a page loads in a div tag after a link is clicked in the menu. Without the "echo", it works fine, but as soon as i include it within the "echo", it stops working. Any help would be great else echo" <div id='fcontrol'> <table border='1' class ='tstyle'> <tr height ='700'><td valign='top' class='ssbg' width='120'><div id='menu'> <a href='javascript:ajaxpage(''new_section.php'', ''contentarea'');'>Add new section</a><br/><br/> <a href='javascript:ajaxpage('new_sub_section.php', 'contentarea');'>Add new section to forum</a><br/><br/><a href='index.php'>Back to forum</a><br/><br/></div></td><td class='tcontrol' width='700' valign='top'> <center><div id='contentarea'>Control Panel</div></center></td></tr> </table></div> </div> "; ?> I want to echo the contents of column 4 for my username only, and it doesn't show anything. I can do if ($memberQuery->fetchColumn(4) < 2)() though. Code: [Select] $host = 'localhost'; $database = ''; $db_username = ''; $db_password = ''; if (($db = new PDO("mysql:host=$host;dbname=$database", $db_username, $db_password)) == NULL) { echo $db->getMessage(); } $memberQuery = $db->prepare("SELECT * FROM members WHERE username=:username"); $memberQuery->execute(array(':username' => $_SESSION['username'])); $result = $memberQuery->fetchColumn(4); echo "$result"; how do i echo "checked=checked" for a checkbox? here is what i have: Code: [Select] <input type='checkbox' name='ip_automatic_login' id='ip_automatic_login' value='1' if($IPCheck == true) {/"checked=checked/" } /> this code will be echoed! i am having issues checking which value is checked in a form. here is my code for it: Code: [Select] <input type="radio" name="accountActivation" id="no" value="no" checked=" <? if (isset($register_errors)) { if (($_POST['accountActivation']) == "no") { echo "checked"; } } ?> " /> when i first open the page, no is checked. why is this, when there should be no errors, and the radio should not even be checked in the first place? |