PHP - Getting Current Month And Displaying Result On Chart
Hello all,
Am trying to calculate some data and display the result of the current month in a chart form. i just don't know how to get the current month. this is not working..
<?php include('mysql_connect.php'); $date = 'MONTH(CURRENT_DATE())'; $status = 'paid'; //mysql_select_db("hyprops", $con); $query = mysql_query("SELECT sum(amount) 'amount', department FROM requisition WHERE status = '$status' AND date='$date' "); $category = array(); $category['name'] = 'department'; //$series1 = array(); //$series1['name'] = 'actual'; $series2 = array(); $series2['name'] = 'amount'; //$series3 = array(); //$series3['name'] = 'Highcharts'; while($r = mysql_fetch_array($query)) { $category['data'][] = $r['department']; // $series1['data'][] = $r['actual']; $series2['data'][] = $r['amount']; // $series3['data'][] = $r['highcharts']; } $result = array(); array_push($result,$category); //array_push($result,$series1); array_push($result,$series2); //array_push($result,$series3); print json_encode($result, JSON_NUMERIC_CHECK); mysql_close($con); ?>Please how can i solve this issue? Thanks in advance Similar TutorialsHi, I'm wanting to find rows whose date is within the next week of the current month of the current year. The format of the date is, for example: 2010-10-28 Any ideas guys? Thanks lots! How to acheive it friends? i want my current codes to show results accouding to current month followed by year, the precious month goes to the page two.
would really appreciate if someone could help me acheive it
$tableName="records"; Edited by lovephp, 02 December 2014 - 11:50 AM. hey guys, im trying to create a local event website displaying a calendar for each month showing local events. now i haven't got around to actually setting up the database yet so im sure i will be back with more questions about that soon, however im just trying to get the site frame work and im using a lot of includes as the site is subject to a lot of change etc. \ now basically i have a page called 'whatson.php' which im using this code to switch the include depending on the link clicked Code: [Select] <?php switch($_GET['changePage']) { default: case 'default': include('test1.php'); break; case 'january': include('january.php'); break; case 'february': include('february.php'); break; case 'march': include('march.php'); break; case 'april': include('april.php'); break; case 'may': include('may.php'); break; case 'june': include('june.php'); break; case 'july': include('july.php'); break; case 'august': include('august.php'); break; case 'september': include('september.php'); break; case 'october': include('october.php'); break; case 'novemeber': include('novemeber.php'); break; case 'december': include('december.php'); break; } ?> now what i want is the default page at the to to display the current month, so i was wondering if there is anyway somebody could help me out with a code that gets the current month from the server or somewhere and inserts it into the default month part at the top of that code... any help would be amazing I am trying to create a loop that will work through the dates of the current month; I have the following piece of code for the loop: Code: [Select] $monthFloor = DateTime::createFromFormat('j H:i:s', '1 0:0:0'); $monthCeiling = DateTime::createFromFormat('j H:i:s', $monthFloor->format('t').' 0:0:0'); for ( $monthDate = DateTime::createFromFormat('Y-m-d H:i:s', $monthFloor->format('Y-m-d H:i:s')); $monthDate->format('d') <= $monthCeiling->format('d'); $monthDate->modify('+ 1 day') ) { echo $monthDate->format('Y-m-d H:i:s')."<br />"; } But when I run this, it loops through the dates of the current month twice!? why is it doing this? and how can I rectify the loop so it only goes through the month once? Am trying to query my DB and use the result to create a chart. code pasted below;
<?php $date = $_POST['Date']; //$date = '25/05/2010'; $date = str_replace('/', '-', $date); $new_date = date('Y-m-d', strtotime($date)); //echo $new_date; include('mysql_connect.php'); // Settings for the graph include "libchart/classes/libchart.php"; $chart = new VerticalBarChart(600, 520); $chart = new VerticalBarChart(); $dataSet = new XYDataSet(); $query1 = mysql_query ("select * from requisition where date = '$new_date' ") or die(mysql_error()); while($row = mysql_fetch_array($query1)) { //$amt = $row['amount']; // check each department and sum up all their data if ( $row['department'] = "ICT") { $total1 = $total1 + $row['amount']; //exit; } else if ( $row['department'] = "Supply Chain/ Asset Integrity") { $total2 = $total2 + $row['amount']; //exit; } else if ( $row['department'] = "Account") { $total3 = $total3 + $row['amount']; //exit; } else if ( $row['department'] = "Admin / Services ") { $total4 = $total4 + $row['amount']; //exit; } else if ( $row['department'] = "Business Development") { $total5 = $total5 + $row['amount']; //exit; } else if ( $row['department'] = "Manpower") { $total6 = $total6 + $row['amount']; //exit; } else if ( $row['department'] = "Maintenance") { $total7 = $total7 + $row['amount']; //exit; } else if ( $row['department'] = "HR") { $total8 = $total8 + $row['amount']; //exit; } else if ( $row['department'] = "Marine Logistics") { $total9 = $total9 + $row['amount']; //exit; } //$dataSet->addPoint(new Point($row['department'], $row['amount'])); } $dataSet->addPoint(new Point("ICT", $total1)); $dataSet->addPoint(new Point("Supply Chain", $total2)); $dataSet->addPoint(new Point("Account", $total3)); $dataSet->addPoint(new Point("Admin / Services", $total4)); $dataSet->addPoint(new Point("Business Development", $total5)); $dataSet->addPoint(new Point("Manpower", $total6)); $dataSet->addPoint(new Point("Maintenance", $total7)); $dataSet->addPoint(new Point("HR", $total8)); $dataSet->addPoint(new Point("Logistics", $total9)); $chart->setDataSet($dataSet); $chart->setTitle("Report By Date - $date"); $chart->render("generated/date.png"); header("Location: view_date.php"); //header ('lcoation : '); ?> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: When i Try to view the result, it only displays the first one in the IF statement. please, what am i doing wrong? Thanks in advance Hello, I'm trying to work out a method of displaying a pie chart depending on the values in an array by looping for a different value of $i, here's what I have so far: for($i = 0; $i < 11; $i++) { $colour = $i; $fraction = ($pie_data[$i]/$total); $pie_angle = $fraction*360; ImageFilledArc($myImage, 100, 100, 200, 180, STARTANGLE, ENDANGLE, $colour, IMG_ARC_PIE); } As you can see I've got fractions, which I'm converting into an angle. However, I can't think of a way to have the startangle and endangle parameters of the ImageFilledArc function depend on all of the previous pie angles, because I'm hoping this pie chart can vary as pieces of data forming each wedge (and each fraction) change. Can anybody help with this? Thanks so much for your help. I am writing code in the ZEND framework and i need to get the current day in like 2012-02-03: In the controller: Code: [Select] $time=date('YYYY-mm-dd',time()); $this->view->time=$time;In view: Code: [Select] <?php echo $this->time; ?> Output: 2012201220122012-0202-0303 I dont know why it is displaying like that instead of once...there is no loop anywhere. I'm using the fairly simple below code to output a list of the latest articles, but I'm wanting (not sure if it's possible) to display the articles from the current day in bold so users recognise that they are new and the older ones non-bold. I've tried a few things, but they're not giving the desired results. Code: [Select] <?php $con = mysql_connect("localhost","xxx","xxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxx", $con); $result = mysql_query("SELECT * FROM `articles` WHERE `quotes` NOT LIKE '%yes%' ORDER BY `date` DESC limit 0,14"); echo "<table class='links' border='0' width='100%'>"; while($row = mysql_fetch_array($result)) { echo '<tr><td width="270" valign="top"><h4>» <a href="news/display/'.$row['id'].'">'.$row['title'].'</a></td><td width="40" valign="top"><span class="small">'.date("M d", strtotime($row['date'])).'</span></h4></td></tr>'; } mysql_close($con); ?> Cheers! When I echo the current time, the hour is what it is plus one: echo date("h:i:s:A"); Real time is 3:46:33 Would display 4:46:33 What is wrong here? i have it set up so the user picks the year and session and then the database shows all the games in that specific year and session and then displays them with a link to their photo galleria and also shows the record(wins - losses - ties) but the way i have it know its not displaying the first result here is the code Code: [Select] <?php //declares $y as year played and $s as session $y = ' '; $s = ' '; //handles submition of form for picking year and session if (isset($_POST['submit'])) { $data = mysql_real_escape_string($_POST['session']); $exploeded = explode(",", $data); $y = $exploeded[0]; $s = $exploeded[1]; } //Query for the selection menu $squery = "SELECT DISTINCT(Year_Played), Sessions FROM pinkpanther_games"; $sresults = mysql_query($squery) or die("squery failed ($squery) - " . mysql_error()); //checks $y and $s to see if their is a vaule if ($y == ' '){$y = '20112012';} if ($s == ' '){$s = '2';} //Query for getting record and for getting all the appropriate info for displaying the games $query = " SELECT (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Tie' ) AS 'Tie', (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Win') AS 'Win', (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Loss') AS 'Lose', Opponent AS Opponent, Score AS Score, Gallery_no AS Gal, Win_Loss AS Record FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s"; $results = mysql_query($query) or die("Query failed ($query) - " . mysql_error()); $row_a = mysql_fetch_assoc($results); //Set record variables $wins = $row_a['Win']; $loss = $row_a['Lose']; $tie = $row_a['Tie']; //creates from and selection menu for year and session echo "<tr><td colspan='2'><form method='post' action=''><select name='session' class='txtbox2'>"; while ($srow = mysql_fetch_assoc($sresults)){ echo "<option value='" . $srow['Year_Played'] . "," . $srow['Sessions'] . "'>" . $srow['Year_Played'] . " Session " . $srow['Sessions'] . "</option>"; } echo "</select><input type='submit' name='submit' value='Go' class='txtbox2' /></form></td></tr>"; //displays record echo "<tr><td colspan='2'>" .$wins . " - " . $loss . " - " . $tie . "</td></tr>"; echo "<tr></tr>"; //displays games and scores in appropriate year and session while ($row = mysql_fetch_assoc($results)){ $opp = $row['Opponent']; $score = $row['Score']; $gal = $row['Gal']; $wlt = $row['Record']; //styles games acording to if win lose or tie if ($wlt == 'Win'){ echo "<tr><td class='win'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='win'>"; echo $score . ""; echo "</td></tr>"; } if ($wlt == 'Loss'){ echo "<tr><td class='loss'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='loss'>"; echo $score . ""; echo "</td></tr>"; } if ($wlt == 'Tie'){ echo "<tr><td class='tie'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='tie'>"; echo $score . ""; echo "</td></tr>"; } } ?> Hi, I have a settings page which updates the users details. However, I want their current details displayed in the form fields, but I cannot get any result. I have only tried to echo out the first name first, but can't seem to get that to work.
<?php session_start(); error_reporting(E_ALL); ini_set('display_errors', '1'); $username = $_SESSION['loggedinuser']; //MySqli Select Query require( 'database.php' ); $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $firstname = $row['firstname']; include 'includes/overall/header.php' ?> <form action="settingscheck.php" method="post"> <ul> <li> First Name:<br> <input type="text" name="<?php echo $firstname; ?>" id="firstname"> </li> <li> Last Name:<br> <input type="text" name="lastname" id="lastname"> </li> <li> Email:<br> <input type="text" name="email" id="email"> </li> <li> Email Again:<br> <input type="text" name="email_again" id="email_again"> </li> <li> Address Line 1:<br> <input type="text" name="address_1" id="address_1"> </li> <li> Address Line 2:<br> <input type="text" name="address_2" id="address_2"> </li> <li> Town:<br> <input type="text" name="town" id="town"> </li> <li> County*:<br> <select name="county"> <option value="">Please Select</option> <option value="Non-UK">Non UK Resident</option> <option value="Aberdeenshire">Aberdeenshire </option> <option value="Anglesey">Anglesey </option> <option value="Angus">Angus </option> <option value="Argyllshire">Argyllshire </option> <option value="Ayrshire">Ayrshire </option> <option value="Banffshire">Banffshire </option> <option value="Bedfordshire">Bedfordshire </option> <option value="Berkshire">Berkshire </option> <option value="Berwickshire">Berwickshire </option> <option value="Brecknockshire">Brecknockshire </option> <option value="Buckinghamshire">Buckinghamshire </option> <option value="Buteshire">Buteshire </option> <option value="Caernarfonshire">Caernarfonshire </option> <option value="Caithness">Caithness </option> <option value="Cambridgeshire">Cambridgeshire </option> <option value="Cardiganshire">Cardiganshire </option> <option value="Carmarthenshire">Carmarthenshire </option> <option value="Cheshire">Cheshire </option> <option value="Clackmannanshire">Clackmannanshire </option> <option value="Cornwall">Cornwall </option> <option value="Cromartyshire">Cromartyshire </option> <option value="Cumberland">Cumberland </option> <option value="Denbighshire">Denbighshire </option> <option value="Derbyshire">Derbyshire </option> <option value="Devon">Devon </option> <option value="Dorset">Dorset </option> <option value="Dumfriesshire">Dumfriesshire </option> <option value="Dunbartonshire">Dunbartonshire </option> <option value="Durham">Durham </option> <option value="East Loathian">East Loathian </option> <option value="Essex">Essex </option> <option value="Fife">Fife </option> <option value="Flintshire">Flintshire </option> <option value="Glamorgan">Glamorgan </option> <option value="Gloucestershire">Gloucestershire </option> <option value="Hampshire">Hampshire </option> <option value="Herefordshire">Herefordshire </option> <option value="Hertfordshire">Hertfordshire </option> <option value="Huntingdonshire">Huntingdonshire </option> <option value="Inverness-shire">Inverness-shire </option> <option value="Kent">Kent </option> <option value="Kincardineshire">Kincardineshire </option> <option value="Kinross-shire">Kinross-shire </option> <option value="Kirkcudbrightshire">Kirkcudbrightshire </option> <option value="Lanarkshire">Lanarkshire </option> <option value="Lancashire">Lancashire </option> <option value="Leicestershire">Leicestershire </option> <option value="Lincolnshire">Lincolnshire </option> <option value="Merioneth">Merioneth </option> <option value="Middlesex">Middlesex </option> <option value="Midlothian">Midlothian </option> <option value="Monmouthshire">Monmouthshire </option> <option value="Montgomeryshire">Montgomeryshire </option> <option value="Morayshire">Morayshire </option> <option value="Nairnshire">Nairnshire </option> <option value="Norfolk">Norfolk </option> <option value="Northamptonshire">Northamptonshire </option> <option value="Northumberland">Northumberland </option> <option value="Nottinghamshire">Nottinghamshire </option> <option value="Orkney">Orkney </option> <option value="Oxfordshire">Oxfordshire </option> <option value="Peeblesshire">Peeblesshire </option> <option value="Pembrokeshire">Pembrokeshire </option> <option value="Perthshire">Perthshire </option> <option value="Radnorshire">Radnorshire </option> <option value="Renfrewshire">Renfrewshire </option> <option value="Ross-shire">Ross-shire </option> <option value="Roxburghshire">Roxburghshire </option> <option value="Rutland">Rutland </option> <option value="Selkirkshire">Selkirkshire </option> <option value="Shetland">Shetland </option> <option value="Shropshire">Shropshire </option> <option value="Somerset">Somerset </option> <option value="Staffordshire">Staffordshire </option> <option value="Stirlingshire">Stirlingshire </option> <option value="Suffolk">Suffolk </option> <option value="Surrey">Surrey </option> <option value="Sussex">Sussex </option> <option value="Sutherland">Sutherland </option> <option value="Warwickshire">Warwickshire </option> <option value="West Lothian">West Lothian </option> <option value="Westmorland">Westmorland </option> <option value="Wigtownshire">Wigtownshire </option> <option value="Wiltshire">Wiltshire </option> <option value="Worcestershire">Worcestershire </option> <option value="Yorkshire">Yorkshire </option> </select> </li> <li> Postcode:<br> <input type="text" name="postcode" id="postcode"> </li> <li> Country*:<br> <select name="country"> <option value="">Country...</option> <option value="Afganistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="American Samoa">American Samoa</option> <option value="Andorra">Andorra</option> <option value="Angola">Angola</option> <option value="Anguilla">Anguilla</option> <option value="Antigua & Barbuda">Antigua & Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia">Armenia</option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Benin">Benin</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bonaire">Bonaire</option> <option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option> <option value="Botswana">Botswana</option> <option value="Brazil">Brazil</option> <option value="British Indian Ocean Ter">British Indian Ocean Ter</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Burkina Faso">Burkina Faso</option> <option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option> <option value="Cameroon">Cameroon</option> <option value="Canada">Canada</option> <option value="Canary Islands">Canary Islands</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Central African Republic">Central African Republic</option> <option value="Chad">Chad</option> <option value="Channel Islands">Channel Islands</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmas Island">Christmas Island</option> <option value="Cocos Island">Cocos Island</option> <option value="Colombia">Colombia</option> <option value="Comoros">Comoros</option> <option value="Congo">Congo</option> <option value="Cook Islands">Cook Islands</option> <option value="Costa Rica">Costa Rica</option> <option value="Cote DIvoire">Cote D'Ivoire</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Curaco">Curacao</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Djibouti">Djibouti</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="East Timor">East Timor</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Equatorial Guinea">Equatorial Guinea</option> <option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option> <option value="Ethiopia">Ethiopia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guiana">French Guiana</option> <option value="French Polynesia">French Polynesia</option> <option value="French Southern Ter">French Southern Ter</option> <option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option> <option value="Georgia">Georgia</option> <option value="Germany">Germany</option> <option value="Ghana">Ghana</option> <option value="Gibraltar">Gibraltar</option> <option value="Great Britain">Great Britain</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guam">Guam</option> <option value="Guatemala">Guatemala</option> <option value="Guinea">Guinea</option> <option value="Guyana">Guyana</option> <option value="Haiti">Haiti</option> <option value="Hawaii">Hawaii</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Iran">Iran</option> <option value="Iraq">Iraq</option> <option value="Ireland">Ireland</option> <option value="Isle of Man">Isle of Man</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati">Kiribati</option> <option value="Korea North">Korea North</option> <option value="Korea Sout">Korea South</option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Laos">Laos</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Lesotho">Lesotho</option> <option value="Liberia">Liberia</option> <option value="Libya">Libya</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macau">Macau</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malaysia">Malaysia</option> <option value="Malawi">Malawi</option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Martinique">Martinique</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mayotte">Mayotte</option> <option value="Mexico">Mexico</option> <option value="Midway Islands">Midway Islands</option> <option value="Moldova">Moldova</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Montserrat">Montserrat</option> <option value="Morocco">Morocco</option> <option value="Mozambique">Mozambique</option> <option value="Myanmar">Myanmar</option> <option value="Nambia">Nambia</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherland Antilles">Netherland Antilles</option> <option value="Netherlands">Netherlands (Holland, Europe)</option> <option value="Nevis">Nevis</option> <option value="New Caledonia">New Caledonia</option> <option value="New Zealand">New Zealand</option> <option value="Nicaragua">Nicaragua</option> <option value="Niger">Niger</option> <option value="Nigeria">Nigeria</option> <option value="Niue">Niue</option> <option value="Norfolk Island">Norfolk Island</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau Island">Palau Island</option> <option value="Palestine">Palestine</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru">Peru</option> <option value="Phillipines">Philippines</option> <option value="Pitcairn Island">Pitcairn Island</option> <option value="Poland">Poland</option> <option value="Portugal">Portugal</option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Republic of Montenegro">Republic of Montenegro</option> <option value="Republic of Serbia">Republic of Serbia</option> <option value="Reunion">Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Rwanda">Rwanda</option> <option value="St Barthelemy">St Barthelemy</option> <option value="St Eustatius">St Eustatius</option> <option value="St Helena">St Helena</option> <option value="St Kitts-Nevis">St Kitts-Nevis</option> <option value="St Lucia">St Lucia</option> <option value="St Maarten">St Maarten</option> <option value="St Pierre & Miquelon">St Pierre & Miquelon</option> <option value="St Vincent & Grenadines">St Vincent & Grenadines</option> <option value="Saipan">Saipan</option> <option value="Samoa">Samoa</option> <option value="Samoa American">Samoa American</option> <option value="San Marino">San Marino</option> <option value="Sao Tome & Principe">Sao Tome & Principe</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Senegal">Senegal</option> <option value="Seychelles">Seychelles</option> <option value="Sierra Leone">Sierra Leone</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia">Slovenia</option> <option value="Solomon Islands">Solomon Islands</option> <option value="Somalia">Somalia</option> <option value="South Africa">South Africa</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option> <option value="Swaziland">Swaziland</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syria">Syria</option> <option value="Tahiti">Tahiti</option> <option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option> <option value="Tanzania">Tanzania</option> <option value="Thailand">Thailand</option> <option value="Togo">Togo</option> <option value="Tokelau">Tokelau</option> <option value="Tonga">Tonga</option> <option value="Trinidad & Tobago">Trinidad & Tobago</option> <option value="Tunisia">Tunisia</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks & Caicos Is">Turks & Caicos Is</option> <option value="Tuvalu">Tuvalu</option> <option value="Uganda">Uganda</option> <option value="Ukraine">Ukraine</option> <option value="United Arab Erimates">United Arab Emirates</option> <option value="United Kingdom">United Kingdom</option> <option value="United States of America">United States of America</option> <option value="Uraguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City State">Vatican City State</option> <option value="Venezuela">Venezuela</option> <option value="Vietnam">Vietnam</option> <option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option> <option value="Virgin Islands (USA)">Virgin Islands (USA)</option> <option value="Wake Island">Wake Island</option> <option value="Wallis & Futana Is">Wallis & Futana Is</option> <option value="Yemen">Yemen</option> <option value="Zaire">Zaire</option> <option value="Zambia">Zambia</option> <option value="Zimbabwe">Zimbabwe</option> </select> </li> <li> PayPal Email*:<br> <input type="text" name="paypal_email"> </li> <li> Business*:<br> <select name="business"> <option value="">Please Choose...</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </li> <li> VAT registered:<br> <select name="vat_registered"> <option value="">Please Choose...</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </li> <li> VAT number:<br> <input type="text" name="vat_number"> </li> <li> <input type="submit" name="reg" id="reg" value="Register"> </li> </ul> </form> <form name="Back" method="post" action="login.php"> <ul> <li><input type="submit" name="back" id="back" value="Back"> </li> </ul> </form> <?php } // Frees the memory associated with a result $results->free(); // close connection $con->close(); include 'includes/overall/footer.php'; ?>Any help is much appreciated Paul i cannot figure out why my first result is not displaying properly it successfully shows all results but me first myurl.com/other.php?id=2 now showing any thing kindly help to solved this problem! it seems like problem is in variable $http$ids but dunno how to combine them to get result $Ids always b numeric number <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $http = "myurl.com/other.php?id=" ; $conn=odbc_connect('greeting','',''); if (!$conn) {exit("Connection Failed: " . $conn);} $sql="SELECT * FROM mytable"; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} echo "<table border= 1><tr>"; echo "<th>ID</th>"; echo "<th>Like</th>"; echo "<th>title</th></tr>"; while (odbc_fetch_row($rs)) { $ids=odbc_result($rs,"ID"); $title=odbc_result($rs,"title"); echo "<tr><td>$ids</td>"; echo "<td><fb:like href=\"$http$ids\" layout=\"button_count\" show_faces=\"false\" width=\"100\" font=\"tahoma\" colorscheme=\"dark\"></fb:like> </td>"; echo "<td>$title</td></tr>"; } echo "</table>"; odbc_close($conn); ?> Hi! I want the image of my site to be clickable so that it shows the next image contained in the result set of the sql query. Code: [Select] <?php require_once('includes/connection.inc.php'); $conn = dbConnect(); $sql = 'SELECT filename FROM images ORDER BY image_id DESC LIMIT 1'; $msg = ''; if(!$sql) { echo "Something went wrong with the query. Please try again."; } $result = $conn->query($sql) or die(mysqli_error()); if(mysqli_num_rows($result) == 0) { header('Location: empty_blog.php'); $conn->close(); } else { $row = $result->fetch_row(); $image = $row[0]; } ?> <?php include('header.php'); ?> <div class="content main"> <img id="image" src="images/<?php echo $image; ?>"/> </div> <?php include('includes/footer.inc.php'); ?> All the filenames of the images are contained correctly in the $result variable, all I need to do now is to fetch the next image in the set. How would I go about this? Any help is greatly appreciated! Hello! I am busy developing a script that returns all users that have the cell "Available" set to 1 but I am unsure how to do this, I am familiar with basic SQL and I have made this: $sql = "SELECT * FROM `clans` WHERE `available` =1 LIMIT 0 , 30"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); echo ($row['name']); but it only displays information from the first row found, and I want it to display all the rows found, how can I do this? Thanks - GreenFanta Hi I am building a product search engine using MySql and PHP (Jquery / AJAX). As i am getting the search results i wondered is it possible to count the instances of a category? For example: If i search for "Dell Laptops" i get 400+ results back because it has lots of laptops and accessories. What i am aiming for it to do is while looping through look at the categories and if its the first instanc eof it i want it to begin a count. until it has finished looping and then i can display it. Results: 436 [ Laptops(127) - Accesories (244) - Components(65) ] Im not even sure where to start here so any advice will be helpful Here is the code im using to generate the search: $id = str_replace(" ", "%", "$id"); $q = "SELECT * FROM products WHERE prod_name LIKE '%$id%' order by fee asc LIMIT 20"; Hi, I am new to php but not to programming. I created a script on a windows platform which connects to the mysql database and returns the results of a table. A very basic script which I wrote to simply test my connection worked. The script works fine on my windows machine but not on my new mac. On the mac it simply does not display any records at all. I know that the database connection has been established because there is no error but I can not see why the result set is not being displayed on screen, as I said it worked fine on my windows machine. The Mac has mysql (with data) and apache running for php. Please could someone help as I have no idea what to do now? Script below: Code: [Select] $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'root'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'test'; mysql_select_db($dbname); mysql_select_db("test", $conn); $result = mysql_query("SELECT * FROM new_table"); while($row = mysql_fetch_array($result)) { echo $row['test1'] . " " . $row['test2'] . " " . $row['test3']; echo "<br />"; } mysql_close($con); This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=330221.0 Hello - Suppose I had a MySQL result set that was something like this: ITEM: COLOR: ball red ball blue book red book green book black If I were to use the code: Code: [Select] do { echo $row_myQuery['item'] . " - " . echo $row_myQuery['color'] . "<br />"; } while ($row_myQuery= mysql_fetch_assoc($myQuery)); Then I end up with this: Code: [Select] ball - red ball - blue book - red book - green book - black MY QUESTION: What I'd like to know is, how could I re-write that php code so that I could get an output like this?: Code: [Select] ball - red, blue book - red, green, black Thanks! Hi.. I need help in getting the 3 Months Name from my table field FromMonth and ToMonth. Here is the scenario. First, I select FromMonth and ToMonth. Ex. FromMonth = 5 ToMonth = 7 So it means FromMonth is May ToMonth is July. Now I save the MonthNumber to my database: table- so_month FromMonth = 5 ToMonth = 7 Now I need to get the between Months Name from FromMonth to ToMonth which are (May, June, July). How does it possible? Thank you so much. |