newb
Members-
Posts
454 -
Joined
-
Last visited
Everything posted by newb
-
nvmd fixed, heres the code i used to fix if anyone cares. $query = mysql_query("SELECT * FROM table WHERE date >= '$now' ORDER BY max(date) desc"); $i = 0; while ($row = mysql_fetch_assoc($query)) { $cid = $row['cat_id']; $title = $row['name']; $seoname = $row['seourl']; $img = 'images/'.$seoname.'.jpg'; if (!file_exists($img)) { $img = ''; } else { $img = 'images/'.$seoname.'.jpg'; } if (!empty($img)) { $i++; } if (!empty($img) && $i <= 5) { echo '<a href="images/'.$seoname.'/"><img src="'.$img .'" style="width:528px;" alt="" /></a>' . "\n"; } }
-
i think LIMIT will limit the files that dont exist also or smthing so it doesnt work...can anyone help?
-
can anyone help
-
Ok, here's my code: How do i make it so that it outputs a maximum of only 5 results from the query where the img file exists. When I add LIMIT to the sql query it doesnt work so I guess its something else, but I have no clue. Can anyone help? $query = mysql_query("SELECT * FROM table WHERE date >= '$now' ORDER BY max(date) desc"); while ($row = mysql_fetch_assoc($query)) { $cid = $row['cat_id']; $title = $row['name']; $seoname = $row['seourl']; $img = 'images/'.$seoname.'.jpg'; if (!file_exists($img)) { $img = ''; } else { $img = 'images/'.$seoname.'.jpg'; } if (!empty($img)) { echo '<a href="images/'.$seoname.'/"><img src="'.$img .'" style="width:528px;" alt="" /></a>' . "\n"; } } Thanks.
-
worked perfectly, thanks so much!
-
ok, and how do i check if it contains alphanumeric chars after it: for example name-2nd should stay as name-2nd
-
$text = preg_replace('{-(\d+)}e', '-convertNumber("$1")', $text); i have strings im trying to replace like this: name-2 > name-two name-p2 > name-p2 im trying to match and replace the first one and basically ignore the second one. ive included the hyphen in the code. so why isnt this working?
-
$name = preg_replace('{(\d+)}', convertNumber("$1"), $row['name']); why isnt this working?
-
nvmd fixed
-
or just do <input type="submit" name="submit" value="Upload" /> so you wont have to add a hidden line
-
I have an array that has data in it and its being sorted like this: Source 1 (zip): filename.zip Source 1 (jpg): filename.jpg Source 1 (png): filename.png Source 2 (zip): filename.zip Source 2 (jpg): filename.jpg Source 2 (png): filename.png Source 3 (zip): filename.zip Source 3 (jpg): filename.jpg Source 3 (png): filename.png Id like the data to be sorted like this instead, but i dont know how to get it to sort this way: Source 1 (zip): filename.zip Source 2 (zip): filename.zip Source 3 (zip): filename.zip Source 1 (jpg): filename.jpg Source 2 (jpg): filename.jpg Source 3 (jpg): filename.jpg Source 1 (png): filename.png Source 2 (png): filename.png Source 3 (png): filename.png Here's my code: any help is appreciated. thanks. for ($i = 1; $i <= 5; $i++) { $src[$i] = 'Source '.$i.' ('.$ext.'): '.$filename.''; array_multisort($src, SORT_ASC, SORT_STRING); }
-
http://www.webdeveloper.com/forum/showthread.php?t=157158 this is what im trying to do, my code is exact the same as this. does anyone have a solution?
-
I have two arrays: $array1[$i] and $array2[$i] how can i output the contents of both in one single foreach loop?
-
fixed. had to group by varset and category
-
ha that's exactly what i just tried doing. that doesnt work either..but the best try in the thread
-
the diagrams arent that confusing..atleast not to me.. looks pretty straightforward as to what the table looks like atm and what im trying to get it to look like. meh..looks like i just have to figure this out myself then >_<
-
whats not clear in my original post?
-
well that didnt work at all...
-
anyone?
-
what do u need clarified? i pretty much drew out exactly what im trying to achieve in the diagram. im just not sure as to how it should be approached through mysql.
-
ok i have a table thats setup like this: id | category | name | varset 1 | catname1 | item | 0 2 | catname2 | item | 1 3 | catname2 | item | 1 4 | catname2 | item | 1 5 | catname3 | item | 0 6 | catname3 | item | 0 7 | catname4 | item | 1 8 | catname4 | item | 1 9 | catname4 | item | 1 how can i group everything together where its varset is = 1 so its something like this: id | category | name | varset 1 | catname1 | item | 0 2 | catname2 | item | 1 5 | catname3 | item | 0 6 | catname3 | item | 0 7 | catname4 | item | 1 is this possible? how can i do this in mysql /php any help appreciated, thanks
-
ok i have a number problem its probably an easy fix but idk i have rows in my database that are like this: A Thread Title 1: New A Thread Title 10: New A Thread Title 11: New A Thread Title 12: New A Thread Title 13: New A Thread Title 2: New A Thread Title 21: New A Thread Title 22: New A Thread Title 3: New I'd likke them to be like this: A Thread Title 1: New A Thread Title 2: New A Thread Title 3: New A Thread Title 10: New A Thread Title 11: New etc etc.. how can i fix?