PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hello having trouble with a simple script. I can get the data out perfect but I need it to display "No Records" if there are no records in the query. Here is my code, I am sorry if it's sloppy! Thanks in advance!
<?php
//******* this is part of a script so assume I already connected to my db
$showzsql = mysql_query("SELECT * FROM shows WHERE bandaide_band = '$bname' ORDER BY sdfdb ASC");
//******************* here is my problem!!!!!
$row = mysql_fetch_row($showzsql);
if($row = 0) {
echo "no records!";
} else {
//*********************************************************
while($x=mysql_fetch_array($showzsql)) {
$sid = $xї"sid"];
$show_date = $xї"show_date"];
$venue = $xї"venue"];
echo "<tr align="center"><td>$show_date</td><td>$venue</td><td><a href="index.php?location=showz&sid=$sid">MORE INFO</a></tr>";
}
?>
<? } ?>
<?php
//******* this is part of a script so assume I already connected to my db
$showzsql = mysql_query("SELECT * FROM shows WHERE bandaide_band = '$bname' ORDER BY sdfdb ASC");
//******************* here is my problem!!!!!
$row = mysql_fetch_row($showzsql);
$rowcount = mysql_num_rows($row);
if($rowcount == '0') {
echo "no records!";
} else {
//*********************************************************
while($x=mysql_fetch_array($showzsql)) {
$sid = $xї"sid"];
$show_date = $xї"show_date"];
$venue = $xї"venue"];
echo "<tr align="center"><td>$show_date</td><td>$venue</td><td><a href="index.php?location=showz&sid=$sid">MORE INFO</a></tr>";
}
?>
<? } ?>
<?php
<?php
//******* this is part of a script so assume I already connected to my db
$showzsql = mysql_query("SELECT * FROM shows WHERE bandaide_band = '$bname' ORDER BY sdfdb ASC");
//******************* here is my problem!!!!!
$row = mysql_fetch_row($showzsql);
if($row = 0) {
echo "no records!";
} else {
//*********************************************************
while($x=mysql_fetch_array($showzsql)) {
$sid = $xї"sid"];
$show_date = $xї"show_date"];
$venue = $xї"venue"];
echo "<tr align="center"><td>$show_date</td><td>$venue</td><td><a href="index.php?location=showz&sid=$sid">MORE INFO</a></tr>";
}
}
?>
?>
<?php
//******* this is part of a script so assume I already connected to my db
$showzsql = mysql_query("SELECT * FROM shows WHERE bandaide_band = '$bname' ORDER BY sdfdb ASC");
//******************* here is my problem!!!!!
$row = mysql_fetch_row($showzsql);
if($row = 0) {
echo "no records!";
} else {
//*********************************************************
while($x=mysql_fetch_array($showzsql)) {
$sid = $xї"sid"];
$show_date = $xї"show_date"];
$venue = $xї"venue"];
echo "<tr align="center"><td>$show_date</td><td>$venue</td><td><a href="index.php?location=showz&sid=$sid">MORE INFO</a></tr>";
}
?>
<? } ?>
<?php
//******* this is part of a script so assume I already connected to my db
$showzsql = mysql_query("SELECT * FROM shows WHERE bandaide_band = '$bname' ORDER BY sdfdb ASC");
//******************* here is my problem!!!!!
$row = mysql_fetch_row($showzsql);
$rowcount = mysql_num_rows($row);
if($rowcount == '0') {
echo "no records!";
} else {
//*********************************************************
while($x=mysql_fetch_array($showzsql)) {
$sid = $xї"sid"];
$show_date = $xї"show_date"];
$venue = $xї"venue"];
echo "<tr align="center"><td>$show_date</td><td>$venue</td><td><a href="index.php?location=showz&sid=$sid">MORE INFO</a></tr>";
}
}
?>
Hush, Volka. I figure, if i think i have it right, move on to another post...don't lniger...and as soon as i saw ur post, I changed it...but sadly it'll take someone else relentlest torrent to make me see it...or an "Almost"
jbdphp, it is better to not use things like $x in your code make it more meaningful, something like $ShowsRecord would better describe what you have returned from the database.
mikeq wrote:jbdphp, it is better to not use things like $x in your code make it more meaningful, something like $ShowsRecord would better describe what you have returned from the database.