karlo 0 Report post Posted February 28, 2005 Ok, here's another. After looking at many PHP codes, I will call it "PHP Shortcuts". Do you still know any other "PHP Shortcuts"?Example, to "print" the visitor's IP address, I use <html><head></head><body><?php print $_SERVER['REMOTE_ADDR']; ?></body></html>After seeing someone's codes, I saw an easy way<?=$_SERVER['REMOTE_ADDR'];?>So, you know any more of that?And for MySQL, I know there are many ways to retrieve the results. But how? Can you really teach me on how to use MySQL in PHP? Especially in LOOPS. I'm planning to create my own CMS. Please help me again. For my first thread, thank you all for helping me. But in this new thread, please help me! Share this post Link to post Share on other sites
OpaQue 15 Report post Posted February 28, 2005 Refer this tutorial posted at our other site Xisto.http://forums.xisto.com/topic/81774-php-writing-a-generic-login-and-register-script/Hope that helps. Share this post Link to post Share on other sites
mobious 0 Report post Posted February 28, 2005 remember that your shortcut method will only work if the short_open_tag config is set to true. anyways for the shortcuts that i know...another way of writing this: if ("red" == "red") { print "red";} else { print "not red";} is this way..."red" == "red" ? print "red" : print "not red"; this is the standard format:[condition] ? [codes to bexecuted when true] : [codes to be executed when false] for your mysql question... i have a simple loop for you. it may be simple but the product of your loop will be a multi-dimensional array. don't mind the code ok. it's just an example.$sql = "SELECT * FROM armor WHERE armor_type = '{$type}' AND SUBSTRING(armor_name, 1, 1) LIKE '{$first_letter}' ORDER BY armor_name ASC";if(!($result = mysql_query($sql))) { die(mysql_error());}while ($item[] = mysql_fetch_array($result, MYSQL_ASSOC));//do the processing of data here. i always use a for.. loop.for ($x = $start; $x < $display_item; $x++) { if ($item[$x]['armor_sold'] == "") { $armor_sold = "N/A"; } else { $armor_sold = explode(":", $item[$x]['armor_sold']); $armor_sold = implode(", ", $armor_sold); }} Share this post Link to post Share on other sites
Mike 0 Report post Posted March 2, 2005 Well, I know some code for MySQL that helps you list everything that is select by the query. I mean, so you don't have to use multiple queries.You would do this: $query=mysql_query(QUERYGOESHERE);while($row=mysql_fetch_row($query)) echo 'WHATYOUWANTTOECHO; THE ROWS SELECT BY THE QUERY'; Here is something that I made using the SQLoops (while())$query=mysql_query("SELECT username,realname,age,location,essay FROM mod_apps WHERE status='Approved'");while($row=mysql_fetch_row($query)) echo '<tr ',shade(),'><td>'.$row[0].'</td><td>'.$row[1].'</td><td>'.$row[2].'</td><td>'.$row[3].'</td><td>'.$row[4].'</td></tr>'; It listed every users mod app that was in the database whos status was 'Approved'. Share this post Link to post Share on other sites
karlo 0 Report post Posted March 3, 2005 remember that your shortcut method will only work if the short_open_tag config is set to true. anyways for the shortcuts that i know... another way of writing this: if ("red" == "red") { print "red";} else { print "not red";} is this way... "red" == "red" ? print "red" : print "not red"; this is the standard format: [condition] ? [codes to bexecuted when true] : [codes to be executed when false] for your mysql question... i have a simple loop for you. it may be simple but the product of your loop will be a multi-dimensional array. don't mind the code ok. it's just an example. $sql = "SELECT * FROM armor WHERE armor_type = '{$type}' AND SUBSTRING(armor_name, 1, 1) LIKE '{$first_letter}' ORDER BY armor_name ASC";if(!($result = mysql_query($sql))) { die(mysql_error());}while ($item[] = mysql_fetch_array($result, MYSQL_ASSOC));//do the processing of data here. i always use a for.. loop.for ($x = $start; $x < $display_item; $x++) { if ($item[$x]['armor_sold'] == "") { $armor_sold = "N/A"; } else { $armor_sold = explode(":", $item[$x]['armor_sold']); $armor_sold = implode(", ", $armor_sold); }} 54796[/snapback] Please explain them to me. I can't understand it. Share this post Link to post Share on other sites
FaLgoR 0 Report post Posted March 4, 2005 And for MySQL, I know there are many ways to retrieve the results. But how? Can you really teach me on how to use MySQL in PHP? Especially in LOOPS. I'm planning to create my own CMS. Please help me again. For my first thread, thank you all for helping me. But in this new thread, please help me! I suggest that u tipe a look at my tutorial of an login sistem with php and mysql, there are many usefull php lines, mysql querys and looping, I'm sure, if you understand that, it will help you alot! Its on Tut forum (and here on php forum too, but there is alot of topics before) Share this post Link to post Share on other sites
FaLgoR 0 Report post Posted March 4, 2005 Here is the link:http://forums.xisto.com/topic/7247-complete-login-system-with-php-mysql/Hope it helps you! =) Share this post Link to post Share on other sites
stevey 0 Report post Posted March 5, 2005 you should really consider exploiting the object oriented features of php especially when it comes to databes and particualarly if you want to create your own cms, its usually faster and simpler to deal with objects than it is to just deal with plain variables, so such google or some php site and find a database class and you will save yourself all the hassle of having to understand databases.. Share this post Link to post Share on other sites
mobious 0 Report post Posted March 5, 2005 that was just a simplified way to write an if..then..else.. statement.the last part is an example of a loop to register the whole rowset into a multi-dimensional array. and then use the for loop to process the each row. Share this post Link to post Share on other sites