Jump to content

Recommended Posts

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

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.