DeanWhitehouse Posted August 2, 2008 Share Posted August 2, 2008 Can anyone help translate this to PHP Dim db, rs, sql, x, m, nowtime $nowtime=Now() Set db = Server.CreateObject("ADODB.Connection") 'db.Open "DSN=allaboutweddings" sql = "SELECT * FROM Categories WHERE FinishDate>Now() order by Categoryname" Set rs = db.Execute(sql) rs.MoveFirst Do While not rs.EOF x=x+1 rs.MoveNext Loop x=x+0.9 col1=x/3 col1 = Round(col1,0) m=0 rs.MoveFirst Do While m<col1 tempcatname=rs("Categoryname") so far i have <?php mysql_connect('host','username','password'); mysql_select_db('db name'); $sql = "SELECT * FROM 'Categories' WHERE 'FinishDate' > Now() ORDER BY 'Categoryname'"; $rs = mysql_query($sql); ?> Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/ Share on other sites More sharing options...
.josh Posted August 2, 2008 Share Posted August 2, 2008 I don't really know asp but from a general coding perspective it looks like you're trying to do this (after the part you already have): Do While not rs.EOF x=x+1 rs.MoveNext Loop looks like you're trying to find out how many rows are returned? that would translate to $x = mysql_num_rows($rs); x=x+0.9 col1=x/3 col1 = Round(col1,0) would be $x = $x + 0.9; $col1 = round($x / 3); m=0 rs.MoveFirst Do While m<col1 tempcatname=rs("Categoryname") I'm assuming this isn't the end of the code, and you are incrementing m in that do while somewhere and doing something with tempcatname? Not really sure how you are using tempcatname but if it's just a simple var being assigned something new on each iteration, it would be: while ($m < $col1) { $t = mysql_fetch_assoc($rs); $tempcatname = $t['Categoryname']; // other code here } translating all that literally kinda makes me think that there is probably a better way to actually "say" it (kind of like how literally translating something from one language to another sounds funny grammar wise, etc..) Maybe if you explain what it is you're trying to do, a more "grammatically correct" way can be given. Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606187 Share on other sites More sharing options...
DeanWhitehouse Posted August 2, 2008 Author Share Posted August 2, 2008 Ok, i don't get why some of that is needed <?php <?php mysql_connect(temp); mysql_select_db(temp); $sql = "SELECT * FROM 'Categories' WHERE 'FinishDate' > Now() ORDER BY 'Categoryname'"; $rs = mysql_query($sql); $rows = mysql_fetch_assoc($rs); rs.MoveFirst $x = mysql_num_rows($rs); $x = $x + 0.9; $col1 = round($x / 3); while ($m < $col1) { $tempcatname = $rows['Categoryname']; ?> <a href="showcats.asp?companytype=<?php echo $tempcatname; ?>&county=<?php echo $_SESSION['SessionCountyPub'];?>">:: <?php echo $tempcatname;?></a><br> <?php rs.MoveNext m=m+1 } ?> </td><td valign="top"><p class="paraspaced" style="margin-left:50px"> <?php m=0 Do While m<col1 tempcatname=rs("Categoryname") ?> <a href="showcats.asp?companytype=<?php echo $tempcatname?>&county=<?php echo $_SESSION['SessionCountyPub'];?>">:: <?php echo $tempcatname?></a><br> <?php rs.MoveNext m=m+1 Loop ?> </td><td valign="top"><p class="paraspaced" style="margin-left:50px"> <?php Do While not rs.EOF tempcatname=rs("Categoryname") ?> <a href="showcats.asp?companytype=<?php echo $tempcatname;?>&county=<?php echo $_SESSION['SessionCountyPub'];?>">:: <?php echo $tempcatname;?></a><br> <?php rs.MoveNext Loop rs.close mysql_close(); ?> </p> </td> </tr> </table> <?php if($_SESSION['SessionCountyPub'] == "") { ?> <p class="para"> </p> <?php } ?> I can do some of it , but i cant understand alot of it , or why it is needed Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606189 Share on other sites More sharing options...
DeanWhitehouse Posted August 2, 2008 Author Share Posted August 2, 2008 Any one help ? please Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606227 Share on other sites More sharing options...
Adam Posted August 2, 2008 Share Posted August 2, 2008 As crayon said, what is it your actually trying to do, in more english? Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606332 Share on other sites More sharing options...
DeanWhitehouse Posted August 2, 2008 Author Share Posted August 2, 2008 Erm to be honest im not to sure, i am doing it for a friend , as there whole site is in ASP and they want it PHP , but as far as what i have translated so far, some of it is not needed Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606349 Share on other sites More sharing options...
.josh Posted August 2, 2008 Share Posted August 2, 2008 umm...no offense, but how do you know whether some of it is needed or not, if you're not sure what it's supposed to be doing? Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606350 Share on other sites More sharing options...
DeanWhitehouse Posted August 2, 2008 Author Share Posted August 2, 2008 Because i know what some of it is in PHP and know that it is not needed, can i just ask is anyone planning on helping translate it , or just question why i am doing it although i have already explained?? ??? Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606389 Share on other sites More sharing options...
.josh Posted August 2, 2008 Share Posted August 2, 2008 I was just asking how you know whether something is necessary or not when you said you didn't know what the script was supposed to be doing. I think that's a valid question, don't you? And anyways, what other part did you need translated? I don't really see any other pieces in there that are different than the earlier pieces that were already translated, that you can't just wash, rinse and repeat, unless I missed something? But more importantly, like I and others have said, we can't really help you all that much unless we know what it is you're trying to do. Going back to the whole language translation thing. Go to any language translator and enter in a sentence and translate it to a different language like say, spanish. Or go to a spanish site, pick a sentence, and try to translate it. It's not going to come out the way we would "normally" say it in english, and in fact, it might not mean the same thing at all! Again, if you want some real help, you need to tell us what it is your script is supposed to be doing. Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606401 Share on other sites More sharing options...
DeanWhitehouse Posted August 2, 2008 Author Share Posted August 2, 2008 This line Do While not rs.EOF I assume it is something like while(rows[''] != ) { } but im not sure, and all the bits that say rs. something I have improvised a bit, but as i havent seen a fully working version of this page, due to the fact they created a test one for me, i can only guesss what it is doing from the code, which is that when you select your location you get shown a number of links and they have the location in the link, Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606420 Share on other sites More sharing options...
.josh Posted August 2, 2008 Share Posted August 2, 2008 It looks like it's for looping through the sql results. With PHP, after you query the database, it returns a result source (assuming it's valid and there are results to return, etc..) and you then have to retrieve the info out of the result source using a number of functions. I assume that since in ASP you are refering to column names from the result, you'll want to use like mysql_fetch_assoc so a basic PHP query scenario would look like this: $sql = "select column from table"; $rs = mysql_query($sql); while($info = mysql_fetch_assoc($rs)) { $x = $info['column']; echo "$x <br />"; } $rs is the result source returned. The loop iterates while the condition is true. What the condition does is grabs the first row in the result source and assigns it to $info and moves an internal pointer to the next row in the result source. Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606425 Share on other sites More sharing options...
DeanWhitehouse Posted August 2, 2008 Author Share Posted August 2, 2008 Ok, so this is what i have , <?php mysql_connect('db3.awardspace.com','crazyemochild_pv','Natasha'); mysql_select_db('crazyemochild_pv'); $sql = "SELECT * FROM 'Categories' WHERE 'FinishDate' > Now() ORDER BY 'Categoryname'"; $rs = mysql_query($sql); $rows = mysql_fetch_assoc($rs); $x = mysql_num_rows($rs); $x = $x + 0.9; $col1 = round($x / 3); $m = 0; while ($m < $col1) { $tempcatname = $rows['Categoryname']; ?> <a href="showcats.asp?companytype=<?php echo $tempcatname; ?>&county=<?php echo $_SESSION['SessionCountyPub'];?>">:: <?php echo $tempcatname;?></a><br> <?php $m = $m+1; } ?> </td><td valign="top"><p class="paraspaced" style="margin-left:50px"> <?php $m=0; while ($m < $col1) { $tempcatname = $rows["Categoryname"]; ?> <a href="showcats.asp?companytype=<?php echo $tempcatname?>&county=<?php echo $_SESSION['SessionCountyPub'];?>">:: <?php echo $tempcatname?></a><br> <?php $m=$m+1; } ?> </td><td valign="top"><p class="paraspaced" style="margin-left:50px"> <?php //Do While not rs.EOF $tempcatname = $rows["Categoryname"]; ?> <a href="showcats.asp?companytype=<?php echo $tempcatname;?>&county=<?php echo $_SESSION['SessionCountyPub'];?>">:: <?php echo $tempcatname;?></a><br> <?php //rs.MoveNext //Loop mysql_close(); ?> </p> </td> </tr> </table> <?php } if(isset($_SESSION['SessionCountyPub']) != "") { ?> <p class="para"> </p> <?php } ?> The lines that are commented are what i am confused about Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606426 Share on other sites More sharing options...
.josh Posted August 3, 2008 Share Posted August 3, 2008 //Do While not rs.EOF $tempcatname = $rows["Categoryname"]; ?> <a href="showcats.asp?companytype=<?php echo $tempcatname;?>&county=<?php echo $_SESSION['SessionCountyPub'];?>">:: <?php echo $tempcatname;?></a><br> <?php //rs.MoveNext //Loop Right. It looks like what I posted before with the mysql_fetch_assoc. That looks like the loop runs as long as there are still rows to do something with in rs and .MoveNext looks like it moves the internal pointer to the next row in rs, just like mysql_fetch_assoc does. Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606436 Share on other sites More sharing options...
DeanWhitehouse Posted August 3, 2008 Author Share Posted August 3, 2008 ok, but i thought the not would mean while something isnt something. e.g. while(mysql_fetch_assoc() != ) instead of while(mysql_fetch_assoc() == ) Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606438 Share on other sites More sharing options...
.josh Posted August 3, 2008 Share Posted August 3, 2008 well in that context it's the same thing. It's like, "while not end of file" Quote Link to comment https://forums.phpfreaks.com/topic/117852-asp-php-help/#findComment-606442 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.