ltoto Posted September 13, 2006 Share Posted September 13, 2006 so I am tryin to do something with a repeat region inside another repeat region, i have used the code below[code]<?php}while ($row_rsDeals = mysql_fetch_assoc($rsDeals)) {if($row_rsPages['Id']== "15"){ $row_rsCountry = mysql_query("SELECT * FROM 'Id' ORDER BY 'countryName' ASC") or die(mysql_error)); while($row_rsCountry=mysql_fetch_array($row_rsCountry)) { echo '<h2>'. $row_rsCountry['countryName'] .'</h2>'; $row_rsRegion = mysql_query("SELECT * FROM `regionName` WHERE countryName = '".$row_rsCountry['Id']."' ORDER BY `region` ASC") or die(mysql_error()); while($row_rsRegion=mysql_fetch_array($row_rsRegion)) { echo '<br />' . $row_rsRegion['regionName'] . '<br />'; } }}}?>[/code]so how it works is that there is a list of countrys, and withing the countrys there are a list of regions from that country, when i use this code though, i get this error:Parse error: parse error, unexpected ')' which is on this line : $row_rsCountry = mysql_query("SELECT * FROM 'Id' ORDER BY 'countryName' ASC") or die(mysql_error));any suggestions Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/ Share on other sites More sharing options...
ToonMariner Posted September 13, 2006 Share Posted September 13, 2006 Yeah,'or die(mysql_error));'change to'or die(mysql_error());' Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90900 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 Try this:[code]$row_rsCountry = mysql_query("SELECT * FROM 'Id' ORDER BY 'countryName' ASC") or die(mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90904 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 oops, I am to slow :) Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90905 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 Thanks a lot, That seems to of fixed that error, but inow have another errorof this line[code]echo"<h2>"$row_rsCountry['countryName']."</h2>";[/code]which isparse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90908 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 That's becouse you use one variable name to define query and result. Try something like this:[code]$row_rsCountry_Q = mysql_query("SELECT * FROM 'Id' ORDER BY 'countryName' ASC") or die(mysql_error));while($row_rsCountry=mysql_fetch_array($row_rsCountry_Q))[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90911 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 that works, i assume i just do the same kind of thing for the next bit of code now to get this error away:Parse error: parse error, unexpected T_VARIABLE inI will give it a go now, thanks alot so far for the help Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90913 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 no problem ;)yes, just change the name of second query as I did... Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90915 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 [code]<?if($row_rsPages['Id'] == "15"){$row_rsCountry_Q = mysql_query("SELECT * FROM 'Id' ORDER BY 'countryName' ASC") or die(mysql_error());while($row_rsCountry=mysql_fetch_array($row_rsCountry_Q))echo $row_rsCountry['countryName'];$row_rsRegion_Q = mysql_query("SELECT * FROM 'Id' ORDER BY 'regionName'= '"$row_rsCountry['Id']."'ORDER BY `countryName` ASC") or die(mysql_error());while($row_rsRegion=mysql_fetch_array($row_rsRegion_Q))echo"<br />"$row_rsRegion['regionName']."<br />";}}}?>[/code]sorry a little confused, so i have done that, but do i now need to change the Q bit?sorry im still a bit of a newb Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90919 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 That code looks ok, what do you mean to change Q bit? Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90922 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 i just got a bit confised, i understnad now, although this code still brings up an error from this line[code]$row_rsRegion_Q = mysql_query("SELECT * FROM 'Id' ORDER BY 'regionName'= '"$row_rsCountry['Id'] "'ORDER BY 'countryName' ASC") or die(mysql_error());[/code]the error isParse error: parse error, unexpected T_VARIABLE in Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90923 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 Try this:[code]<?phpwhile ($row_rsDeals = mysql_fetch_assoc($rsDeals)) {if($row_rsPages['Id']== "15"){$row_rsCountry_Q = mysql_query("SELECT * FROM 'Id' ORDER BY 'countryName' ASC") or die(mysql_error());while($row_rsCountry = mysql_fetch_array($row_rsCountry_Q)){echo '<h2>'. $row_rsCountry['countryName'] .'</h2>';}$row_rsRegion_Q = mysql_query("SELECT * FROM `regionName` WHERE countryName = '".$row_rsCountry['Id']."' ORDER BY `region` ASC") or die(mysql_error());while($row_rsRegion = mysql_fetch_array($row_rsRegion_Q)){echo '<br />' . $row_rsRegion['regionName'] . '<br />';}}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90927 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 that seems to of solved that probelm but gives me this error[b]Parse error: parse error, unexpected $ in[/b]which is the last line of the page with nothing on itEDIT: i seem to have this working now with this code:[code]<?phpif($row_rsPages['Id']== "15"){$row_rsCountry_Q = mysql_query("SELECT * FROM 'Id' ORDER BY 'countryName' ASC") or die(mysql_error());while($row_rsCountry = mysql_fetch_array($row_rsCountry_Q)){echo '<h2>'. $row_rsCountry['countryName'] .'</h2>';}$row_rsRegion_Q = mysql_query("SELECT * FROM 'regionName' WHERE 'countryName' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ASC") or die(mysql_error());while($row_rsRegion = mysql_fetch_array($row_rsRegion_Q)){echo '<br />' . $row_rsRegion['regionName'] . '<br />';}}?>[/code]but have this:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Id' ORDER BY 'countryName' ASC' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90928 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 Try to add WHERE:[code]$row_rsCountry_Q = mysql_query("SELECT * FROM 'Id' WHERE 'id' ORDER BY 'countryName' ASC") or die(mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90931 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 so for example this[code]<?phpif($row_rsPages['Id']== "15"){$row_rsCountry_Q = mysql_query("SELECT * FROM 'Id' WHERE 'Id' ORDER BY 'countryName' ASC") or die(mysql_error());while($row_rsCountry = mysql_fetch_array($row_rsCountry_Q)){echo '<h2>'. $row_rsCountry['countryName'] .'</h2>';}$row_rsRegion_Q = mysql_query("SELECT * FROM 'regionName' WHERE 'countryName' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ASC") or die(mysql_error());while($row_rsRegion = mysql_fetch_array($row_rsRegion_Q)){echo '<br />' . $row_rsRegion['regionName'] . '<br />';}}?>[/code]EDIT: Just noticed that this bring up the same kind of error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Id' WHERE 'Id' ORDER BY 'countryName' ASC' at line 1sorry for being so thick by the way, normally i would spend time trying to figure it out, but I am running out of time now thats all Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90932 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 ok, try to remove ASC at the end:[code]$row_rsCountry_Q = mysql_query("SELECT * FROM 'Id' WHERE 'Id' ORDER BY 'countryName' ") or die(mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90933 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 i tried that but it just takes that bit off of the error, egYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Id' WHERE 'Id' ORDER BY 'countryName'' at line 1so now the code is this[code]$row_rsCountry_Q = mysql_query("SELECT * FROM 'Id' WHERE 'Id' ORDER BY 'countryName' ") or die(mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90935 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 sorry for the double post, but other querys seem to be like this[code]$query_rsVillas = "SELECT * FROM tabPages WHERE Id = 3";$rsVillas = mysql_query($query_rsVillas, $conTotal) or die(mysql_error());[/code]if that helps at all Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90937 Share on other sites More sharing options...
Gruzin Posted September 13, 2006 Share Posted September 13, 2006 hmmm.... Let's try in this way to check out what we are doing wrong:Hope the Id is a table and there is a feild called Id too.[code]$row_rsCountry_Q = mysql_query("SELECT * FROM Id WHERE Id") or die(mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90938 Share on other sites More sharing options...
HuggieBear Posted September 13, 2006 Share Posted September 13, 2006 Is there a column called ID in the table called ID?RegardsRich[size=8pt][b]Edit:[/b] Ooops, beaten to it...[/size] Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90939 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 this error:Table 'totaltravel.Id' doesn't existi think i understand, where it says from Id, i must put the name of the tabe sotabCountry for example is the name of the country tableEDIT: it seems to be error free now, but nothing is actually showing on the page Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90941 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 i made a mistake with the Deals recordset, so the code now is[code]<?phpif($row_rsPages['Id']== "15"){$row_rsCountry_Q = mysql_query("SELECT * FROM tabCountry WHERE 'Id' ORDER BY 'countryName' ") or die(mysql_error());while($row_rsCountry = mysql_fetch_array($row_rsCountry_Q)){echo '<h2>'. $row_rsCountry['countryName'] .'</h2>';}$row_rsRegion_Q = mysql_query("SELECT * FROM tabRegion WHERE 'regionName' = '".$row_rsCountry['Id']."' ORDER BY 'regionName' ") or die(mysql_error());while($row_rsRegion = mysql_fetch_array($row_rsRegion_Q)){echo '<br />' . $row_rsRegion['regionName'] . '<br />';}}?>[/code]i cant see why it is not now showing on the page, so maybe someelse can see Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90951 Share on other sites More sharing options...
HuggieBear Posted September 13, 2006 Share Posted September 13, 2006 [code=php:0]mysql_query("SELECT * FROM tabCountry WHERE 'Id' ORDER BY 'countryName' ") or die(mysql_error());[/code]I'm assuming that with this piece of code that you want to select every country? If so, you can drop the [color=red]WHERE 'id'[/color] as it's not actually doing anything unless you specify something after it, such as [color=red]WHERE id = '$num'[/color]We seem to be going around the houses here, to help us to help you, can you provide us with your table names and a list of the columns in those tables?RegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90961 Share on other sites More sharing options...
ltoto Posted September 13, 2006 Author Share Posted September 13, 2006 The country table is:tabCountry:idcountryNameand the Region Table istabRegion:idregionNamethere is also a table after this , so when they click on region, the list of hotels on that region appear, on a new page:tabHotel:idhotelNamehotelCountryhotelRegionhotelImagehotelDescriptionhotelRatingin the CMS to this, there are drop down menus for The COuntry and Region, in the hotel section.I hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90971 Share on other sites More sharing options...
HuggieBear Posted September 13, 2006 Share Posted September 13, 2006 OK, now it's starting to make sense, did you design the tables or did you get this script from somewhere as a 'pre-built'?I think the database design is slightly out.RegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/20597-solved-2-repeat-regions/#findComment-90977 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.