Jump to content

skallsen

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

skallsen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Brilliant! Thank you, it's working great and now I can actually see where it was broken! Suzzy [!--quoteo(post=378302:date=May 29 2006, 11:52 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 29 2006, 11:52 PM) [snapback]378302[/snapback][/div][div class=\'quotemain\'][!--quotec--] I wouldn't use mysqli_field_count() since it's PHP5 only (it's still not so widely used). There is an error with your query. Use this code: [code]$result = mysql_query($addestate) or die(mysql_error());[/code] Which will throw and error if one happens. You can use mysql_affected_rows() to check if a row was actually inserted as well: [a href=\"http://www.php.net/mysql_affected_rows\" target=\"_blank\"]http://www.php.net/mysql_affected_rows[/a] Also, there are is a problem with your code that I can see now: ('$estatename, should be ('$estatename', Yes, the smallest error can cause the entire script to fail. It's something that bothers me in programming. [/quote]
  2. Hey all, I'm so confused on how to use this: mysql_field_count() I'm not even sure it's what I should use in this case. I have this code to insert data into my db: $addestate = "INSERT INTO estate_sale_companies (estatename, estateaddress1, estateaddress2, estatecity, estatestate, estatezip, estatecounty, estatetelephone, estatewebsite, estateemail, estatecontact, contact_MNG, contact_KIC) VALUES ('$estatename, '$estateaddress1', '$estateaddress2', '$estatecity, '$estatestate', '$estatezip', '$estatecounty', '$estatetelephone', '$estatewebsite', '$estateemail', '$estatecontact', '$contact_MNG', '$contact_KIC')"; $result = mysql_query($addestate); The insert isn't working and I want to check the result to see if it worked (if there is a result). How do I do that? I've read the MySQL manual on mysql_field_count() and I cannot figure out how to use it! Can someone give me the code to use to perform a check on this query? Thanks!
  3. Thanks Sanfly! I didn't know about UNION - I messed with it a bit and it ended up working like this: $query = "SELECT * FROM SaleListing l LEFT JOIN Cities c ON l.SaleCity=c.CityID WHERE l.Day1Date = '".$searchdate."' AND c.CityID=".$SaleCity." UNION SELECT * FROM SaleListing l LEFT JOIN Cities c ON l.SaleCity=c.CityID WHERE l.Day2Date = '".$searchdate."' AND c.CityID=".$SaleCity." UNION SELECT * FROM SaleListing l LEFT JOIN Cities c ON l.SaleCity=c.CityID WHERE l.Day3Date = '".$searchdate."' AND c.CityID=".$SaleCity." UNION SELECT * FROM SaleListing l LEFT JOIN Cities c ON l.SaleCity=c.CityID WHERE l.Day4Date = '".$searchdate."' AND c.CityID=".$SaleCity;
  4. I have this query almost working...I just don't know how to do this final comparison. My query: $query = "SELECT a.SaleHeadline, a.SaleCounty, a.StateID, a.SaleCity, a.SaleAddress, a.Day1Date, a.Day1Start, a.Time1Start, a.Day1End, a.Time1End, a.Day2Date, a.Day2Start, a.Time2Start, a.Day2End, a.Time2End, a.Day3Date, a.Day3Start, a.Time3Start, a.Day3End, a.Time3End, a.Day4Date, a.Day4Start, a.Time4Start, a.Day4End, a.Time4End, a.SaleInfo, b.CityID, b.CityName FROM SaleListing a, Cities b WHERE a.SaleCity=b.CityID AND b.CityID=".$SaleCity." AND Day1Date = '".$searchdate."'"; At the end of the query I am searching for a match in Day1Date. I also need to search these columns for a match: Day2Date, Day3Date, Day4Date. the match can be in any of them or just one - if it matches any of those four fields then that row needs to be displayed. I've tried OR (OR Day2Date...OR Day3Date) but that didn't work, gave me repeats of rows where the dates overlapped. Help please! :) TIA
  5. I have this bit of code which displays a date and corresponding start and end times for that date. if( strlen($record['Day1Date']) != NULL) echo $record["Day1Date"].": ".[!--coloro:#FF6666--][span style=\"color:#FF6666\"][!--/coloro--]$record["Day1Start"][!--colorc--][/span][!--/colorc--].$record["Time1Start"]." -".$record["Day1End"].$record["Time1End"]."<br />"; For $record["Day1Start"] I want the time to display hour/min like 4:00. Right now it displays as 04:00:00. I've read a bunch of information on formatting dates but I'm not understanding how to use it in this case. Can someone show me? TIA
  6. Hey all, I need your help. I have to do a join on two tables and output data from both. The two tables are SaleListing and Cities SaleListing.SaleCity has the same number as Cities.CityID I need to query and output all of the data from the SaleListing table and just Cities.CityName (where it matches the SaleListing.SaleCity AND $SaleCity variable). So it would be something like this: City Name Sale Date Sale County Eden Prairie 01-01-2004 Hennepin How do I get and output the data I need from both cities? I've tried about 20 different queries but nothing is working right. I've tried this: $query = "select * from SaleListing sl left join Cities ct on sl.SaleCity=ct.CityId"; and this: $query = "SELECT a.SaleCity, b.CityID, b.CityName FROM SaleListing a,Cities b WHERE a.SaleCity=b.CityID AND a.SaleCity=$SaleCity"; $result = mysql_query($query) or die ("ERROR: " . mysql_error()); while ($record=mysql_fetch_assoc($result)) { echo $record["b.CityName"]; } exit; but neither of them return any records. The data is there in the db and I've run other checks. The query seems to be finding data because it gets past this: if(mysql_num_rows($result)== 0) {} and displays table headers with nothing else in the table. Help please!
  7. Hi all! I'm developing my new site and having trouble with getting an inner join to work with PHP/MySql. I have an inner join that DOES work and looks like this: $query = "SELECT antique_stores.StoreName, antique_stores.StoreAddress1, antique_stores.StoreCity, antique_stores.StoreZip, antique_stores.StoreTelephone FROM antique_stores INNER JOIN Cities ON antique_stores.StoreCity = Cities.CityName WHERE Cities.CityID = ".$city; I want to do something similar but have more requirements: $query = "SELECT * FROM SaleListing INNER JOIN Cities SaleListing.SaleCity = Cities.CityName WHERE SaleCity = ".$SaleCity." AND Day1Date= '".$searchdate."' AND Cities.CityID = ".$SaleCity; I've tested for both variables $SaleCity and $searchdate and they are being successfuly passed. $SaleCity is a number for the city from the Cities db. This query is working great but I really need to substitute the CityName for the SaleCity/CityID number so that it shows the name instead: $query = "SELECT * FROM SaleListing WHERE SaleCity = ".$SaleCity." AND Day1Date= '".$searchdate."'"; Any ideas? Thanks!
×
×
  • 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.