Jump to content

w00kie

Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

w00kie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=368075:date=Apr 24 2006, 12:53 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 24 2006, 12:53 PM) [snapback]368075[/snapback][/div][div class=\'quotemain\'][!--quotec--] I think I found the problem... Just a minor misspelled variable in one of my examples... :-( [code]<?php $result = mysql_query("SELECT e_1, e_2, e_3, e_4, e_5, e_6, e_7, e_8, e_9, e_10 FROM f_images", $link); $num_rows = mysql_num_fields($result); $row = mysql_fetch_assoc($result); foreach($row as $k => $v)      if ($v == '') $num_rows--; // I had $num_row originally echo $num_rows; ?>[/code] You can also just add up the entries which are not blank: [code]<?php $result = mysql_query("SELECT e_1, e_2, e_3, e_4, e_5, e_6, e_7, e_8, e_9, e_10 FROM f_images", $link); $num_rows = 0 $row = mysql_fetch_assoc($result); foreach($row as $k => $v)      if ($v != '') $num_rows++; echo $num_rows; ?>[/code] Ken [/quote] Thank you Ken, and thank you for being so patient <3
  2. No Ken, i ran the php script in a seperate PHP file. When i run your array script i get 10, 1 also. but when i run the script you previously posted, it results as 10. even though now i've added .jpgs in e_1, e_2, e_3, e_4 of the database. & also, I dont know if this helps but i previously stated that the images were all on the same row, not individual rows, i dont know if that would change anything.
  3. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] Array ( [e_1] => one.jpg [e_2] => [e_3] => [e_4] => [e_5] => [e_6] => [e_7] => [e_8] => [e_9] => [e_10] => ) [/quote]
  4. [!--quoteo(post=368033:date=Apr 24 2006, 11:09 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 24 2006, 11:09 AM) [snapback]368033[/snapback][/div][div class=\'quotemain\'][!--quotec--] It's a very strange way of doing things, but you can shorten your code considerably: [code]<?php $result = mysql_query("SELECT e_1, e_2, e_3, e_4, e_5, e_6, e_7, e_8, e_9, e_10 FROM f_images", $link); $num_rows = mysql_num_fields($result); $row = mysql_fetch_assoc($result); foreach($row as $k => $v)      if ($v == '') $num_row--; echo $num_rows; ?>[/code] Ken [/quote] Thanks for your responce ken, although i have images in e_2, e_5, e_6, yet it still displays '10'
  5. Nevermind it seems i have solved my problem [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$result = mysql_query("SELECT e_1, e_2, e_3, e_4, e_5, e_6, e_7, e_8, e_9, e_10 FROM f_images", $link); $num_rows = mysql_num_fields($result); if($e_1=="") { echo "There are : <B>"; --$num_rows; if($e_2=="") { --$num_rows; } if($e_3=="") { echo --$num_rows; } } ?> [/quote]
  6. Hey, i have a DB with a list of gallery pictures. Now i want a script to display and let users know how many pictures are in the dababase, which i used mysql_num_fields for. Since all the images are listed in one row, i couldn't use num_rows. now i've tried to set up a script which will check for blank fields in the row, and if it has blank fields then it will decrement the number of images it echo's out For instance, I have 10 images in my DB it echo's "There are 10 images in the database" Now, if i had 9 images, one blank field. I want it to say " There are 9 images in the database" So now it decrements down, and so fourth, Now i wanted to use && or, operators but my syntax is crap and i m not that very advanced at php, i would appreciate the help. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$result = mysql_query("SELECT e_1, e_2, e_3, e_4, e_5, e_6, e_7, e_8, e_9, e_10 FROM f_images", $link); $num_rows = mysql_num_fields($result); if( $e_1 && $e_2 == "") { echo "There are : <B>"; echo --$num_rows; echo "</b> Images in this group\n"; } ?>[/quote]
  7. I have a database with 10 thumbnail pictures, image1, image2, image3 and so fourth when i add a picture, i add the - 'event_images/image1.jpg' for instance which is fine. But, what i need help with is, if the cell for image1, is empty, it doesnt contain a path then to dispaly a Blank image. Such as 'event_images/spacer.jpg' thanks for your help in advanced. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]if ($image_1 == "") { echo "<a href=event_images/blank.jpg><img name=eventimage src=event_images/blank.jpg width=40 height=40 border=2 ></a> "; } else { echo "<a href=event_images/$image_1><img name=eventimage src=event_images/$image_1 width=40 height=40 border=2 ></a> "; }[/quote] Thats what i was thinkinjg, would there be an easier way?
  8. [!--quoteo(post=365978:date=Apr 18 2006, 08:04 AM:name=GingerRobot)--][div class=\'quotetop\']QUOTE(GingerRobot @ Apr 18 2006, 08:04 AM) [snapback]365978[/snapback][/div][div class=\'quotemain\'][!--quotec--] Use mysql_num_rows(); [code] $sql = "SELECT * FROM `fieldname` WHERE `id`='$id'"; $result = mysql_query($sql); $num = mysql_num_rows($result) if($num < 1){ header("location:errorpage.php"); exit; } [/code] [/quote] thank you ever so much :)
  9. Hi, I have MYSQL Rows in a table for instance :- [a href=\"http://localhost/description?id=1\" target=\"_blank\"]http://localhost/description?id=1[/a] now, this is fine. But what i want to do is, when a user enters an INVALID ID, which isn't a row in the MYSQL table to redirect to a different page. Or give an echo saying, this is ID is invalid. so if someone enters [a href=\"http://localhost/description?id=09340350305035\" target=\"_blank\"]http://localhost/description?id=09340350305035[/a] and that ID doesn't exist, it redirects thanks in advance
×
×
  • 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.