Jump to content

Crustyfur

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Crustyfur's Achievements

Member

Member (2/5)

0

Reputation

  1. ello, I am struggling with date functions as always and need some help. I just want to show results from the last 30 days. Thanks in advance. C SELECT COUNT(a.id), a.productid, p.productid, p.producttitle, p.productcode, p.manfid, m.manfid, m.manufacturer, DATE_FORMAT(a.datetime, '%D %M %Y') as a.datetime FROM tt_gear_afflinks_data a, tt_gear_product p, tt_gear_manufacturer m WHERE a.productid = p.productid AND p.manfid = m.manfid AND a.datetime = CURDATE() >= 30 GROUP BY a.productid ORDER BY COUNT(a.id) DESC LIMIT 20
  2. Hi, Having problem get the nested query working and could use some help. I know that GROUP BY is probably causing the issue but I am not sure how to work around it. SELECT s.subcatid, s.subcategory, c.catid, p.catid, p.subcatid, p.active FROM tt_gear_subcategory s, tt_gear_category c, tt_gear_product p WHERE s.subcatid = p.subcatid AND c.catid = p.catid AND p.catid = '$catid' AND p.active = '1' GROUP BY s.subcatid ORDER BY s.subcategory ASC Second Query: $subcatid = $row["p.subcatid"]; $result2 = $db->sql_query("SELECT catid, subcatid, manfid, active FROM tt_gear_product WHERE catid = '$catid' AND subcatid = '$subcatid' AND active = '1' GROUP BY manfid");
  3. Not sure I have the right title. I want to call results based on the first letter. e.g All cars in a list begining with 'A'. Any help appreciated. Thanks
  4. Hi, I need the second query to display its results based on the 'townid' from the first query. I am not sure how to pass it. The page variable is '$countyid'. As you can see I have used a 'townid' of '11' as an example if I dont make any sense. <?php <table cellpadding=\"10\">"; $result = $db->sql_query("SELECT * FROM ft_clubs_town WHERE countyid = '$countyid' ORDER BY town ASC"); $counter = 0; echo "<tr><td valign=\"top\" align=\"left\">"; while($row = $db->sql_fetchrow($result)) { if($counter>25) { echo "</td><td valign=\"top\">"; $counter = 0; } echo $row["town"]; echo "<br />"; $result2 = $db->sql_query("SELECT club FROM ft_clubs WHERE townid = '11' ORDER BY club ASC"); while($row2 = $db->sql_fetchrow($result2)) { echo $row2["club"]; echo "<br />"; } echo "<br />"; $counter++; } echo "</tr>"; echo "</table> ?>
  5. That did it. I was looking at it for so long I was blind to the obvious. Cheers Diego Chris
  6. Is this a error cuased by lack of declaration of $db? <?php function newscommentsent() { global $pagetitle, $result; $pagetitle = "Fleet Town, Hampshire - News Comment Sent"; $result = $db->sql_query("INSERT INTO ".$prefix."_bus_pending (feildname) //--snip ?>
  7. Here's the full job. <?php $result = $db->sql_query("UPDATE ".$prefix."_fixtures SET teamid='".forSql($_POST["teamid"])."',fdate='".forSql($_POST["fdate"])."', ftimeid='".forSql($_POST["ftimeid"])."', fopp='".forSql($_POST["fopp"])."', ftid='".forSql($_POST["ftid"])."', ffor='".forSql($_POST["ffor"])."', fagg='".forSql($_POST["fagg"])."' WHERE fid ='$fid'"); if($result) { echo "This fixture has been succesfully updated. I hope you won! "; } else { echo "<b>There has been an error adding the fixture!</b>"; print_r($db->sql_error($result)); } } list($fid,$teamid,$fdate,$ftimeid,$fopp,$ffor,$fagg,$ftid) = $db->sql_fetchinto("SELECT fid, teamid, fdate, ftimeid, fopp, ffor, fagg, ftid FROM ".$prefix."_fixtures WHERE fid= '$fid'"); echo "<br /><fieldset><legend>Edit Fixtures & Results</legend>"; $teams="<option> -- Select a Team --</option>"; $result = $db->sql_query("SELECT * FROM hh_teams ORDER BY teamid ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["teamid"]==$teamid) $selected = " selected=\"selected\""; $teams.="<option$selected value=\"".$row["teamid"]."\">".$row["team"]."</option>"; } $fixturetime="<option> -- Select a Time --</option>"; $result = $db->sql_query("SELECT * FROM hh_fixtures_time ORDER BY ftime ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["ftimeid"]==$ftimeid) $selected = " selected=\"selected\""; $fixturetime.="<option$selected value=\"".$row["ftimeid"]."\">".$row["ftime"]."</option>"; } $fixturetype="<option> -- Select a Fixture Type --</option>"; $result = $db->sql_query("SELECT * FROM hh_fixtures_type ORDER BY ftid ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["ftid"]==$ftid) $selected = " selected=\"selected\""; $fixturetype.="<option$selected value=\"".$row["ftid"]."\">".$row["ftype"]."</option>"; } $result = $db->sql_query("SELECT * FROM ".$prefix."_fixtures WHERE fid ='$fid'"); if($row = $db->sql_fetchrow($result)) { echo "$status<form action=\"$nukeurl/admin/?op=editfixture&fid=". $row[0] ."\" method=\"post\"> <br /> <center><b>This page allows you to edit fixtures & results.</b></center><br /><br /> <table width=\"100%\"> <tr><td align=\"right\"><b>Team: </b></td><td> <select id=\"teamid\" name=\"teamid\">$teams</select> <a href=\"http://www.heathhoops.com/admin/?op=addteam\">Add a New Team</a> </td></tr> <tr><td width=\"50%\" align=\"right\"><b>Date (YYYY-MM-DD): </b></td><td width=\"50%\" ><input type=\"text\" name=\"fdate\" id=\"fdate\" size=\"30\"/ value=\"". $row["fdate"] ."\"></td></tr> <tr><td align=\"right\"><b>Time: </b></td><td> <select id=\"ftimeid\" name=\"ftimeid\">$fixturetime</select> <a href=\"http://www.heathhoops.com/admin/?op=addtime\">Add a Time</a> </td></tr> <tr><td width=\"50%\" align=\"right\"><b>Opposition: </b></td><td width=\"50%\" ><input type=\"text\" name=\"fopp\" id=\"fopp\" size=\"30\"/ value=\"". $row[4] ."\"></td></tr> <tr><td align=\"right\"><b>Fixture Type: </b></td><td> <select id=\"ftid\" name=\"ftid\">$fixturetype</select> </td></tr> <tr><td align=\"right\"><b>Heath Hoops Score: </b></td><td><input type=\"text\" name=\"ffor\" id=\"ffor\" size=\"5\"/ value=\"". $row[5] ."\"></td><tr> <tr><td align=\"right\"><b>Opposition Score: </b></td><td><input type=\"text\" name=\"fagg\" id=\"fagg\" size=\"5\"/ value=\"". $row[6] ."\"></td><tr> <tr><td height=\"10\" colspan=\"2\"></td></tr> <tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"savebutton\" value=\"Save Fixture\" /></td></tr> </table> </form></fieldset>"; ?>
  8. As per subject. I have a form that allows users to edit entries in the db. Thats all cool. My problem is that if any fields are left blank the form is inserting a '0' value when I need it to remain 'null'. How do I stop it inserting '0' values? Thanks in advance. <?php <input type=\"text\" name=\"ffor\" id=\"ffor\" size=\"5\"/ value=\"". $row["ffor"] ."\"> ?>
  9. Thanks Georg, That worked but I had to change the +1 to -1 ??? Works though Cheers
  10. Crustyfur

    CURDATE()

    Hi guys, I am currently using a simple CURDATE() in my query: fdate > CURDATE() Is there a way of making it +1 day? At the moment it is updating the data 24 hours before I want it too. Cheers Chris
  11. My bad, it was this lines fault. list(...) didnt match the sql. doh <?php list($fid,$teamid,$fdate,$ftime,$fopp,$ftid,$ffor,$fagg) = $db->sql_fetchinto("SELECT fid, teamid, fdate, fdate, fopp, ffor, fagg, ftid FROM ".$prefix."_fixtures WHERE fid= '$fid'"); ?>
  12. just amended a minor error: <?php echo "<select id=\"teamid\" name=\"teamid\">$teams</select>"; echo "<select id=\"ftid\" name=\"ftid\">$fixturetype</select>"; ?>
  13. Hi Guys, I have a problem with script below. First query works a treat, populating drop down and making the relevant entry default. For some reason the second drop down refuses to default. <?php list($fid,$teamid,$fdate,$ftime,$fopp,$ftid,$ffor,$fagg) = $db->sql_fetchinto("SELECT fid, teamid, fdate, fdate, fopp, ffor, fagg, ftid FROM ".$prefix."_fixtures WHERE fid= '$fid'"); $teams="<option> -- Select a Team --</option>"; $result = $db->sql_query("SELECT * FROM hh_teams ORDER BY teamid ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["teamid"]==$teamid) $selected = " selected=\"selected\""; $teams.="<option$selected value=\"".$row["teamid"]."\">".$row["team"]."</option>"; } $fixturetype="<option> -- Select a Fixture Type --</option>"; $result = $db->sql_query("SELECT * FROM hh_fixtures_type ORDER BY ftid ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["ftid"]==$ftid) $selected = " selected=\"selected\""; $fixturetype.="<option$selected value=\"".$row["ftid"]."\">".$row["ftype"]."</option>"; } ?> And the query in the form: <?php echo "<select id=\"teamid\" name=\"teamid\">$teams</select>"; echo "<select id=\"ftype\" name=\"ftype\">$fixturetype</select>"; ?> So $teams works but $fixturetype doesn't. It maybe be obvious to spot by my eyes are hurting now
  14. Hey, I want to call data from the db and display it in a dropdown and make the selected option match the value of the record called. It thats clear? query <?php } $result = $db->sql_query("SELECT * FROM ".$prefix."_fixtures a, ".$prefix."_teams b WHERE a.teamid = b.teamid AND fid ='$fid'"); if($row = $db->sql_fetchrow($result)) { ?> Best I can muster <?php echo "<select name=\"teamid\"> <option value=\"". $row[8] ."\">". $row[9] ."</option> </select>"; ?> As you can see all it does is display the one option and not everything in the list. Thanks in advance.
×
×
  • 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.