![]() |
php help, see example :)
Ok, what i want to do is have the sql load the page based on the modnum entered in the php line (text.php?modnum=1) - ive tried alot of == lines and get errors, how would u simplify this to work :D thanks alot guys! :d
/** SQL QUERY */ if(!isset($modnum)){ $sql = "SELECT id,up_date, up_modelname, up_age, up_from, up_description, up_moviename, up_length, up_buyvideo, up_modelset, keywords FROM $upTable WHERE LOWER(keywords) LIKE '%".$modnum."%' ORDER BY up_date DESC"; } $result = mysql_query($sql, $db_link); |
Quote:
----Code---- if(isset($modnum)) { if($modnum==1) { $sql = "SELECT id,up_date, up_modelname, up_age, up_from, up_description, up_moviename, up_length, up_buyvideo, up_modelset, keywords FROM $upTable WHERE LOWER(keywords) LIKE '%".$modnum."%' ORDER BY up_date DESC"; } } Else { echo 'Variable Not Set'; } ----Code---- You should check to see if the variable $modnum has a value assigned to it. If so, then check to see if that value = 1. If it is, run the sql statement. Hope it helps. Blaze |
Quote:
|
consider the hint with the $_GET
also try [...] FROM ".$upTable." WHERE [...] should work |
Quote:
so modnum=1 would local database field with ID 1 $sql = "SELECT id, up_date, up_modelname, up_age, up_from, up_description, up_moviename, up_length, up_buyvideo, up_modelset, keywords FROM $upTable WHERE $modname=id ORDER BY up_date DESC"; now this would be the logical way, where modname=id but it doesnt load the value, just pulls the blank screen on me :( |
well youre not showing us your code to read the result from mysql or anything. That may be where your problem is. ALso in your first example you use !isset, which means IF ITS NOT SET
the correct way is to use $_GET. Yes, for now it works otherwise, but its the correct way nor is it safe to use variables like that. Also, dont you mean: id=$modname ? try putting id='$modname' (with the comas) |
WHERE id = '" . $modnum . "' LIMIT 1
|
Here is all the code, I hacked job a multipage tour file to attempt this...
[QUOTE=bl4h;11583990]well youre not showing us your code to read the result from mysql or anything[QUOTE]
================================================== ====== <? /** DATABASE CONNECTION */ $DBHOST = "localhost"; $DBLOGIN = "#####"; $DBPASSWORD = "#####"; $DB = "#####"; $memTable = "models"; $db_link = mysql_connect($DBHOST, $DBLOGIN, $DBPASSWORD); if(!mysql_select_db($DB, $db_link)) { echo "Unable to connect to the database server at this time."; exit(); } //SQL Query Selected depending if ?modname=MODELNAME is set in URL if(isset($modname)) { if($modname==1) { $sql = "SELECT id, up_date, up_modelname, up_age, up_from, up_description, up_moviename, up_length, up_buyvideo, up_modelset, keywords FROM $upTable WHERE id='$modname' LIMIT 1 ORDER BY up_date DESC"; } } else { echo '<CENTER><BR><BR><BR><B>Model not selected. Please try again...</B><BR><BR><BR></CENTER>'; } echo $modname; $result = mysql_query( $sql, $db_link ); /** NAVIGATION */ $perPage = 1; //set number of models per page to display //Evaluate current position of user if (!isset($srtCount) || $srtCount<=0){ $srtCount = 1; } $num_rows = mysql_num_rows($result); //get number of rows in db $nextCount=$srtCount+$perPage; $prevCount=$srtCount-$perPage; /** BASIC LISTING */ //Iterate through selections using $srtCount $count=0; while($count<$srtCount){ $rowarray = @mysql_fetch_row($result); $count++; } $i=0; while ($i<$perPage && $rowarray!=FALSE) { $sid = $rowarray[0]; $modelname = $rowarray[1]; $previewname = $rowarray[2]; $age = $rowarray[3]; $location = $rowarray[4]; $sexuality = $rowarray[5]; $maritalstatus = $rowarray[6]; $mycomments = $rowarray[7]; $producerscomments = $rowarray[8]; $turnons = $rowarray[9]; $hobbiesfun = $rowarray[10]; $sexual = $rowarray[11]; $height = $rowarray[12]; $weight = $rowarray[13]; $busty = $rowarray[14]; $food = $rowarray[15]; $photoset1 = $rowarray[16]; $photoset2 = $rowarray[17]; $photoset3 = $rowarray[18]; $photoset4 = $rowarray[19]; $photoset5 = $rowarray[20]; $photodir = $rowarray[21]; $videoloc = $rowarray[22]; $dvd1 = $rowarray[23]; $dvd2 = $rowarray[24]; $dvd3 = $rowarray[25]; $dvd4 = $rowarray[26]; $dvd5 = $rowarray[27]; $dvd6 = $rowarray[28]; $dvd7 = $rowarray[29]; $dvd8 = $rowarray[30]; $dvd9 = $rowarray[31]; $dvd10 = $rowarray[32]; ?> <!-- TEMPLATE --> where the output info goes<BR> <? echo $modelname; ?> <!-- END TEMPLATE --> <?php $i++; $rowarray = @mysql_fetch_row($result); }//end while @mysql_close($db_link); ?> ================================================== ====== Sorry to bug you guys with this :( |
All times are GMT -7. The time now is 10:18 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123