avatar.alex Posted May 8, 2007 Share Posted May 8, 2007 I was wondering if all this is correct...I think it is but I'm not sure.... <?php include "connect.php"; $query = "SELECT * FROM sms_cat"; $results = mysql_query($query); $num = mysql_num_rows($result); if($num > 0) { $i = 0; while($i < $num); $name = mysql_result ($result, $i, "name"); $date = mysql_result ($result, $i, "date"); $content = mysql_result ($result, $i, "contect"); ( echo "$name<br>"; echo "$date<br>"; echo "$content<br>"; echo "<hr><br>"; ) ?> Link to comment https://forums.phpfreaks.com/topic/50547-is-this-correct/ Share on other sites More sharing options...
per1os Posted May 8, 2007 Share Posted May 8, 2007 This might work better... <?php include "connect.php"; $query = "SELECT * FROM sms_cat"; $results = mysql_query($query); $num = mysql_num_rows($result); if($num > 0) { while($row = mysql_fetch_assoc($results)) { $name = $row['name']; $date = $row['date']; $content = $row['content']; echo "$name<br>"; echo "$date<br>"; echo "$content<br>"; echo "<hr><br>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/50547-is-this-correct/#findComment-248385 Share on other sites More sharing options...
avatar.alex Posted May 8, 2007 Author Share Posted May 8, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/50547-is-this-correct/#findComment-248387 Share on other sites More sharing options...
Barand Posted May 8, 2007 Share Posted May 8, 2007 As $i is never incremented while($i < $num); will just check if $i < $num forever (or until it times out) Link to comment https://forums.phpfreaks.com/topic/50547-is-this-correct/#findComment-248390 Share on other sites More sharing options...
avatar.alex Posted May 9, 2007 Author Share Posted May 9, 2007 I know something with this isn't right but im not sure <?php include "connect.php"; $query = "SELECT * FROM sms_cat"; $results = mysql_query($query); $num = mysql_num_rows($result); if($num > 0) { $i = 0; while($i < $num); $cat = mysql_result ($result, $i, "cat"); $itemid = mysql_result ($result, $i, "itemid"); $price = mysql_result ($result, $i, "price"); $name = mysql_result ($result, $i, "name"); //This is were I had trouble I did the best I could } $category = $_GET['cat'] //im not sure if this IF statement is correct if(shop.php?cat=$cat) ( echo "<a href=\"shop.php?cat=$cat\">$cat</a>\n"; ) ?> also instead of if(shop.php?cat=$cat) couldn't I just use if(ifset($_GET['cat'])) could someone help me with this one also. Link to comment https://forums.phpfreaks.com/topic/50547-is-this-correct/#findComment-248658 Share on other sites More sharing options...
trq Posted May 9, 2007 Share Posted May 9, 2007 I know something with this isn't right but im not sure How about you tell us what you expect to happen and what is actually happening. And no, this if(shop.php?cat=$cat) means nothing at all (and will generate errors) in php. Link to comment https://forums.phpfreaks.com/topic/50547-is-this-correct/#findComment-248691 Share on other sites More sharing options...
avatar.alex Posted May 9, 2007 Author Share Posted May 9, 2007 I want it so if I clicked on a link that was shop.php?cat=books that will bring up all the items that are in that category Link to comment https://forums.phpfreaks.com/topic/50547-is-this-correct/#findComment-248875 Share on other sites More sharing options...
avatar.alex Posted May 9, 2007 Author Share Posted May 9, 2007 I know something with this isn't right but im not sure How about you tell us what you expect to happen and what is actually happening. And no, this if(shop.php?cat=$cat) means nothing at all (and will generate errors) in php. The wouldn't I use the if(ifset($_GET['cat'])); Link to comment https://forums.phpfreaks.com/topic/50547-is-this-correct/#findComment-249084 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.