Jump to content

Nismo240

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by Nismo240

  1. Ok well nvm i figured it out mysql_connect($server, $dbuser, $dbpass) or die(mysql_error());mysql_select_db($database) or die(mysql_error());$data = mysql_query("SELECT * FROM `products` WHERE `type` = 'Desktop' AND `make` = 'apple' AND `viewable` = 'y'")or die(mysql_error());$num_rows = mysql_num_rows($data);$x = "0";Print "<table summary='' width='100%' border='0' cellspacing='' cellpadding='10' align='center'>";Print "<tr>";if ($num_rows == 0) { Print "<td align='center' valign='top' width='33%'>[box]Currently Out of This Make.[/box]</td>";} else {while($info = mysql_fetch_array($data)){ extract($info); if ($x == "0"){ Print "</tr><tr>"; } $x++; if ($x == "3"){ $x = "0"; }Print "<td align='center' valign='top' width='33%'>[box]<img class='aligncenter size-thumbnail wp-image-41' title='' src='http://cheaptronics.net/wordpress/wp-content/uploads/". $info['image'] . "' alt='' width='150' height='150' /><strong>". $info['make'] . " " . $info['model'] . " - $". $info['price'] . "</strong><BR>[tooltip text='<b>". $info['make'] . " " . $info['model'] . "</b><BR>". $info['desc'] . "'][More Info][/tooltip][/box]</td>";}}Print "</tr>";Print "</table>"; Works perfect.. if we dont have any Apple Desktops listed then it will show "Sorry we are currently out of stock etc etc.." and if we do have it in stock it will list them 3 per row thank you birbal and justsomeguy for pointing me in the direction of mysql_num_rows();
  2. Im sorry one second, now mysql_connect($server, $dbuser, $dbpass) or die(mysql_error());mysql_select_db($database) or die(mysql_error());$data = mysql_query("SELECT * FROM `products` WHERE `type` = 'Desktop' AND `make` = 'apple' AND `viewable` = 'y'")or die(mysql_error());$num_rows = mysql_num_rows($data);echo "You have " . $num_rows . " number of rows..."; Seems to be outputting Which is correct, thats weird it wasnt working a min ago now it is lol.. well i guess now to move on to the if/else statement..
  3. Ok i appreciate your post, but the code snipplet in my first post is just that a snipplet i have error_reporting(E_ALL); at the top of my page and im not seeing any errors.. also i believe that the $num_rows = mysql_num_rows($data); Isnt right because mysql_connect($server, $dbuser, $dbpass) or die(mysql_error());mysql_select_db($database) or die(mysql_error());$data = mysql_query("SELECT * FROM `products` WHERE `type` = 'Desktop' AND `make` = 'apple' AND `viewable` = 'y'")or die(mysql_error());$num_rows = mysql_num_rows($data);echo "You have " . $num_rows . " number of rows..."; just puts out If i dont mind asking what else could i give to help you guys out ?
  4. When i mean it doesnt work i mean $num_rows = mysql_num_rows($data); either isnt grabbing the info or if ($num_rows == 0) { if ($num_rows = 0) { if (!$num_rows) { these dont work either. When i say they dont work its not showing Print "<td align='center' valign='top' width='33%'>[box]Currently Out of This Make.[/box]</td>"; which you would understand if you read my first post.. but either way i dont get any errors codes either..
  5. ok hmm i tried this // Connects to your Databasemysql_connect($server, $dbuser, $dbpass) or die(mysql_error());mysql_select_db($database) or die(mysql_error());$data = mysql_query("SELECT * FROM `products` WHERE `type` = 'Desktop' AND `make` = 'apple' AND `viewable` = 'y'")or die(mysql_error());$x = "0";Print "<table summary='' width='100%' border='0' cellspacing='' cellpadding='10' align='center'>";Print "<tr>";while($info = mysql_fetch_array($data)){ extract($info); if ($x == "0"){ Print "</tr><tr>"; } $x++; if ($x == "3"){ $x = "0"; }// EMPTY ARRAY CHECK$num_rows = mysql_num_rows($data); if ($num_rows = 0) { Print "<td align='center' valign='top' width='33%'>[box]Currently Out of This Make.[/box]</td>"; } else {Print "<td align='center' valign='top' width='33%'>[box]<img class='aligncenter size-thumbnail wp-image-41' title='' src='http://cheaptronics.net/wordpress/wp-content/uploads/". $info['image'] . "' alt='' width='150' height='150' /><strong>". $info['make'] . " " . $info['model'] . " - $". $info['price'] . "</strong><BR>[tooltip text='<b>". $info['make'] . " " . $info['model'] . "</b><BR>". $info['desc'] . "'][More Info][/tooltip][/box]</td>"; } // END}Print "</tr>";Print "</table>"; didnt work also moved the $num_rows = mysql_num_rows($data); up under $data = mysql_query("SELECT * FROM `products` WHERE `type` = 'Desktop' AND `make` = 'apple' AND `viewable` = 'y'")or die(mysql_error()); doesnt work :/
  6. Hi i have the following code // Connects to your Databasemysql_connect($server, $dbuser, $dbpass) or die(mysql_error());mysql_select_db($database) or die(mysql_error());$data = mysql_query("SELECT * FROM `products` WHERE `type` = 'Desktop' AND `make` = 'apple' AND `viewable` = 'y'")or die(mysql_error());$x = "0";Print "<table summary='' width='100%' border='0' cellspacing='' cellpadding='10' align='center'>";Print "<tr>";while($info = mysql_fetch_array($data)){ extract($info); if ($x == "0"){ Print "</tr><tr>"; } $x++; if ($x == "3"){ $x = "0"; } // EMPTY ARRAY CHECK if ($info) {Print "<td align='center' valign='top' width='33%'>[box]<img class='aligncenter size-thumbnail wp-image-41' title='' src='http://blahblah.net/wordpress/wp-content/uploads/". $info['image'] . "' alt='' width='150' height='150' /><strong>". $info['make'] . " " . $info['model'] . " - $". $info['price'] . "</strong><BR>[tooltip text='<b>". $info['make'] . " " . $info['model'] . "</b><BR>". $info['desc'] . "'][More Info][/tooltip][/box]</td>"; } elseif (empty($info)) { Print "<td align='center' valign='top' width='33%'>[box]Currently Out of This Make.[/box]</td>"; }// END}Print "</tr>";Print "</table>"; My code displays 3 items in a row then drops to a new row, etc.. How ever if my array is empty (Like if there are no Apple Desktops available) i would like it to display something like Sorry we are currently out of Apple Desktops right now. yada yada.. How would i go about doing this correctly.. Thanks.
  7. I'm trying to make a custom display of 2 of the most recent news/blog post in my WordPress but i'm having issue getting the URL for the featured image i gave to each of my post's.. My code is as follows (note that the printed text isn't formatted yet, just wanted a simple layout for testing purposes) <?php$args = array( 'numberposts' => '2', 'order' => 'DESC','post_status' => 'publish' );$recent_posts = wp_get_recent_posts( $args );foreach( $recent_posts as $recent ){$feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );echo 'Post ID: '.$recent["ID"];echo '<BR>';echo 'Post URL: '.get_permalink($recent["ID"]);echo '<BR>';echo 'Post Title: '.$recent["post_title"];echo '<BR>';echo $feat_image; //Will display http://blablah.com/wordpress/blablahblah.jpg etc....echo '<BR>';echo 'Post Content: '.$recent["post_content"];echo '<BR>';echo '<BR>';}?> It all works except for the featured image :/ Thanks in advance
×
×
  • Create New...